跳转至

mdp

模块:

名称 描述
commands

类:

名称 描述
FlightActionMapper

Map batched normalized actions into controller targets, wrench, or RPM.

FlightMappingConfig

Mapping-range configuration for normalized action scaling.

Mixer

Map batched thrust and moment demands to rotor speed commands.

VehicleParams

Generic multi-rotor vehicle physics.

RotorDynamics

Batched motor dynamics model for rotor thrust and torque.

FlightControlAction

Body torque control action term.

FlightControlActionCfg

See :class:FlightControlAction for more details.

DelayedObservation

A modifier used to return a stochastically delayed (stale) version of

DelayedObservationCfg

Configuration parameters for a delayed observation modifier.

HelixTrajectory

Batched helix trajectory.

LemniscateTrajectory

Batched Bernoulli lemniscate trajectory.

LissajousTrajectory

Batched three-dimensional Lissajous trajectory.

RectangleTrajectory

Batched constant-speed rectangle trajectory in the horizontal plane.

RandomTrajectoryCommand

Trajectory command generator with randomized type and parameters per environment.

RandomTrajectoryCommandCfg

Configuration for randomized trajectory commands.

函数:

名称 描述
randomize_action_term_attr

Randomize a selected action-term attribute.

randomize_controller_params

Randomize controller gains and command limits attached to an action term.

randomize_mixer_params

Randomize mixer parameters attached to an action term.

randomize_rotor_params

Randomize rotor parameters attached to an action term.

randomize_mapping_params

Randomize action-mapper runtime parameters attached to an action term.

target_pos_b

Position of target in body frame.

root_euler_w

Euler angles of the root in world frame.

root_axis_angle_w

Axis-angle of the root in world frame.

root_rotmat_w_flat

Rotation matrix of the root in world frame, flattened to a 9D vector.

lin_vel_l2

Penalize base linear velocity using L2 squared kernel.

ang_vel_l2

Penalize base angular velocity using L2 squared kernel.

pos_error_l2

Penalize asset pos from its target pos using L2 squared kernel.

pos_error_tanh

Penalize asset pos from its target pos using tanh kernel.

yaw_error_l2

Penalize heading error from target heading using L2 squared kernel.

yaw_error_tanh

Penalize heading error from target heading using tanh kernel.

track_lin_vel_z_exp

Reward tracking of linear velocity commands (z axis) using exponential kernel.

track_lin_vel_exp

Reward tracking of linear velocity commands using exponential kernel.

track_yaw_vel_exp

Reward tracking of angular velocity commands (yaw) using exponential kernel.

hover_tracking

Penalize deviation of the collective acceleration command from hover.

bimodal_action_tanh

Penalize bimodal actions using tanh kernel.

bimodal_height_tanh

Penalize bimodal height using tanh kernel.

contact_impulse

Penalize excessive contact impulse (rate of change of contact forces).

bimodal_contacts

Penalize contacts when switching from flight to ground mode.

died

Termination condition based on the robot's height.

属性:

名称 类型 描述
ACTION_KEY_ORDER

Stable policy-action field order derived from the shared controller schema.

ACTION_KEY_ORDER module-attribute

ACTION_KEY_ORDER = tuple(ControllerState.__annotations__)

Stable policy-action field order derived from the shared controller schema.

Only fields present in the active control mask consume action slices.

FlightActionMapper

FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), mapping: FlightMappingConfig | None = None, control_mask: dict | None = None, num_envs: int = 1, device=None, *, backend: BackendName | None = None, xp: ModuleType | None = None)

Map batched normalized actions into controller targets, wrench, or RPM.

Initialize the batched action mapper and backend namespace.

方法:

名称 描述
randomize

Randomize.

action_to_collective_acc

Action to collective acc.

collective_acc_to_thrust

Collective acc to thrust.

action_to_collective_thrust

Action to collective thrust.

decode_action

Decode normalized batched action into a runtime-neutral control request.

map_action

Resolve normalized batched action into simulation rotor RPM commands.

属性:

名称 类型 描述
requires_controller bool

Requires controller.

requires_controller property

requires_controller: bool

Requires controller.

randomize

randomize(env_ids=None, randomization: dict | None = None)

Randomize.

action_to_collective_acc

action_to_collective_acc(action: ArrayLike, mixer) -> ArrayLike

Action to collective acc.

返回:

类型 描述
ArrayLike

The total collective acceleration array.

collective_acc_to_thrust

collective_acc_to_thrust(collective_acc: ArrayLike) -> ArrayLike

Collective acc to thrust.

返回:

类型 描述
ArrayLike

The total thrust array.

action_to_collective_thrust

action_to_collective_thrust(action: ArrayLike, mixer) -> ArrayLike

Action to collective thrust.

返回:

类型 描述
ArrayLike

The total thrust array.

decode_action

decode_action(action: ArrayLike, mixer, *, state: ControllerState | None = None) -> FlightMapping

Decode normalized batched action into a runtime-neutral control request.

返回:

类型 描述
FlightMapping

FlightMapping dictionary containing control requests.

引发:

类型 描述
ValueError

If state is missing when required for control mode.

map_action

map_action(action: ArrayLike, mixer, *, state: ControllerState | None = None, flight_controller: ControllerBase | None = None) -> FlightMapping

Resolve normalized batched action into simulation rotor RPM commands.

返回:

类型 描述
FlightMapping

FlightMapping dictionary containing RPM commands and wrench details.

引发:

类型 描述
ValueError

If flight_controller is missing for mapped modes.

FlightMappingConfig dataclass

FlightMappingConfig(velocity_range: tuple[float, float, float] | None = (3.0, 3.0, 1.5), acceleration_range: tuple[float, float, float] | None = (3.0, 3.0, 2.0), attitude_range: tuple[float, float, float] | None = None, body_rate_range: tuple[float, float, float] | None = (2.0, 2.0, 2.0), rel_rotation: bool = False, rotation_step_len: float | None = None)

Mapping-range configuration for normalized action scaling.

方法:

名称 描述
from_params

Build mapping ranges from vehicle parameters.

resolve

Resolve config overrides into concrete mapping ranges.

from_params classmethod

from_params(params: VehicleParams) -> FlightMappingConfig

Build mapping ranges from vehicle parameters.

返回:

类型 描述
FlightMappingConfig

Instantiated FlightMappingConfig object.

resolve

resolve(params: VehicleParams) -> FlightMappingConfig

Resolve config overrides into concrete mapping ranges.

返回:

类型 描述
FlightMappingConfig

Resolved FlightMappingConfig object.

Mixer

Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device=None, *, backend: BackendName | None = None, xp: ModuleType | None = None, allocation_mode: Literal['pinv', 'saturation'] = 'pinv')

Map batched thrust and moment demands to rotor speed commands.

The default "pinv" allocator applies direct pseudo-inverse allocation. "saturation" enables a staged trim strategy: roll/pitch authority is trimmed first if needed, and yaw authority is allocated from the remaining rotor-speed margin.

Initialize the mixer matrix and backend namespace.

参数:

名称 类型 描述 默认

params

VehicleParams

Vehicle parameters used to build the allocation matrix.

VehicleParams()

num_envs

int

Number of parallel environments represented by the batch.

1

device

Optional backend device, mainly used by Torch.

None

backend

BackendName | None

Explicit Array API backend. If omitted, NumPy is used when device is None and Torch otherwise for compatibility.

None

xp

ModuleType | None

Pre-resolved Array API namespace. Overrides backend.

None

allocation_mode

Literal['pinv', 'saturation']

"pinv" for direct pseudo-inverse allocation or "saturation" for staged saturation-aware allocation.

'pinv'

方法:

名称 描述
randomize

Randomize mixer parameters for selected environments.

calculate_rotor_commands

Allocate [thrust, roll, pitch, yaw] controls to rotor RPM.

randomize

randomize(env_ids=None, randomization: dict | None = None)

Randomize mixer parameters for selected environments.

calculate_rotor_commands

calculate_rotor_commands(control: ArrayLike) -> ArrayLike

Allocate [thrust, roll, pitch, yaw] controls to rotor RPM.

参数:

名称 类型 描述 默认

control

ArrayLike

Batched control array with shape (num_envs, 4).

必需

返回:

类型 描述
ArrayLike

Batched rotor speed magnitudes with shape (num_envs, 4).

VehicleParams dataclass

VehicleParams(*, rho: float = 1.184, g: float = 9.81, sim_dt: float = 0.01, step_dt: float = 0.01, randomization: dict[str, dict[str, tuple[float, float]]] = dict(), mass: float = 2.1, inertia: list = (lambda: [[0.015, 0.0, 0.0], [0.0, 0.0348, 0.0], [0.0, 0.0, 0.042503]])(), x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = math.radians(8.0), diameter: float = 0.476, Cdx: float = 0.5, r_p: float = 0.0775, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = math.radians(14.6), thetaTip: float = math.radians(6.8), theta1: float = math.nan, lock: float = 0.6051, cT: float = math.nan, cM: float = math.nan, spin_dir: tuple[float, float, float, float] = (1.0, 1.0, -1.0, -1.0), tau_f: float = 0.01, tau_m: float = 0.05, max_rpm: float = 10000.0, init_rpm: float = math.nan, rotor_rpm_rate_limit: float = 50000.0, tau_up: float = math.nan, tau_down: float = math.nan, mpc_xy_vel_max: float = 12.0, mpc_z_vel_max_up: float = 3.0, mpc_z_vel_max_dn: float = 1.5, mpc_acc_hor_max: float = 5.0, mpc_acc_up_max: float = 4.0, mpc_acc_down_max: float = 3.0, mpc_man_tilt_max: float = math.radians(35.0), mc_rollrate_max: float = math.radians(220.0), mc_pitchrate_max: float = math.radians(220.0), mc_yawrate_max: float = math.radians(200.0))

Generic multi-rotor vehicle physics.

The base class carries LAV2-compatible defaults for the shared multi-rotor parameters so that VehicleParams() continues to produce a working LAV2-flavoured flight configuration (without track / airframe specifics).

Concrete subclasses add robot-specific locomotion and geometry:

  • TrackVehicleParams — LAV2: tracked ground locomotion + ducted airframe
  • TiltWheelVehicleParams — ATMO: tilting arms + two side motors whose belt transmissions synchronize four wheel shells

方法:

名称 描述
__post_init__

Calculate derived parameters and resolve default sentinels.

属性:

名称 类型 描述
rho float

Air density (kg/m³).

g float

Gravitational acceleration (m/s²).

sim_dt float

Simulation time step (s).

step_dt float

Control time step (s).

randomization dict[str, dict[str, tuple[float, float]]]

Per-component parameter-randomisation scale ranges.

mass float

Total vehicle mass (kg); concrete robot subclasses may override it.

inertia list

Vehicle inertia matrix at its center of mass (kg*m^2).

x float

Arm length in x — rotor moment-arm for roll (m).

y float

Arm length in y — rotor moment-arm for pitch (m).

h float

CG height below rotor plane (m, negative = below).

alpha float

Duct / rotor cant angle about y-axis (rad — 0 for flat rotors like ATMO).

diameter float

Overall vehicle diameter (m).

Cdx float

Body drag coefficient.

r_p float

Propeller radius (m).

Ct float

Thrust coefficient (blade-element).

Cq float

Torque coefficient (blade-element).

theta0 float

Blade root pitch angle (rad).

thetaTip float

Blade tip pitch angle (rad).

theta1 float

Blade twist (rad), defaults to theta0 - thetaTip.

lock float

Lock number.

cT float

Thrust coefficient T = cT·rpm² (N / rpm²); defaults from Ct.

cM float

Reaction-torque coefficient M = cM·rpm² (N·m / rpm²); defaults from Cq.

spin_dir tuple[float, float, float, float]

Rotor spin direction signs; + means clockwise, - means counter-clockwise.

tau_f float

Motor filter time constant (s).

tau_m float

Legacy motor time constant (s).

max_rpm float

Maximum rotor speed (rpm — LAV2 default).

init_rpm float

Initial rotor speed — defaults to 0.2·max_rpm.

rotor_rpm_rate_limit float

Rotor-speed rate-of-change limit (rpm/s).

tau_up float

Motor spin-up time constant (s), defaults to tau_m.

tau_down float

Motor spin-down time constant (s), defaults to tau_m.

mpc_xy_vel_max float

Maximum horizontal velocity setpoint magnitude in m/s (0 - 20).

mpc_z_vel_max_up float

Maximum upward velocity setpoint in m/s (0.5 - 8).

mpc_z_vel_max_dn float

Maximum downward velocity setpoint magnitude in m/s (0.5 - 4).

mpc_acc_hor_max float

Maximum horizontal acceleration setpoint magnitude in m/s^2 (2 - 15).

mpc_acc_up_max float

Maximum upward acceleration setpoint in m/s^2 (2 - 15).

mpc_acc_down_max float

Maximum downward acceleration setpoint magnitude in m/s^2 (2 - 15).

mpc_man_tilt_max float

Maximum manual tilt angle in radians (deg: 0 - 90).

mc_rollrate_max float

Maximum roll-rate setpoint in rad/s (deg/s: 0 - 1800).

mc_pitchrate_max float

Maximum pitch-rate setpoint in rad/s (deg/s: 0 - 1800).

mc_yawrate_max float

Maximum yaw-rate setpoint in rad/s (deg/s: 0 - 1800).

rho class-attribute instance-attribute

rho: float = 1.184

Air density (kg/m³).

g class-attribute instance-attribute

g: float = 9.81

Gravitational acceleration (m/s²).

sim_dt class-attribute instance-attribute

sim_dt: float = 0.01

Simulation time step (s).

step_dt class-attribute instance-attribute

step_dt: float = 0.01

Control time step (s).

randomization class-attribute instance-attribute

randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)

Per-component parameter-randomisation scale ranges.

mass class-attribute instance-attribute

mass: float = 2.1

Total vehicle mass (kg); concrete robot subclasses may override it.

inertia class-attribute instance-attribute

inertia: list = field(default_factory=lambda: [[0.015, 0.0, 0.0], [0.0, 0.0348, 0.0], [0.0, 0.0, 0.042503]])

Vehicle inertia matrix at its center of mass (kg*m^2).

x class-attribute instance-attribute

x: float = 0.0952

Arm length in x — rotor moment-arm for roll (m).

y class-attribute instance-attribute

y: float = 0.114423

Arm length in y — rotor moment-arm for pitch (m).

h class-attribute instance-attribute

h: float = -0.0125

CG height below rotor plane (m, negative = below).

alpha class-attribute instance-attribute

alpha: float = math.radians(8.0)

Duct / rotor cant angle about y-axis (rad — 0 for flat rotors like ATMO).

diameter class-attribute instance-attribute

diameter: float = 0.476

Overall vehicle diameter (m).

Cdx class-attribute instance-attribute

Cdx: float = 0.5

Body drag coefficient.

r_p class-attribute instance-attribute

r_p: float = 0.0775

Propeller radius (m).

Ct class-attribute instance-attribute

Ct: float = 0.666

Thrust coefficient (blade-element).

Cq class-attribute instance-attribute

Cq: float = 0.0716

Torque coefficient (blade-element).

theta0 class-attribute instance-attribute

theta0: float = math.radians(14.6)

Blade root pitch angle (rad).

thetaTip class-attribute instance-attribute

thetaTip: float = math.radians(6.8)

Blade tip pitch angle (rad).

theta1 class-attribute instance-attribute

theta1: float = math.nan

Blade twist (rad), defaults to theta0 - thetaTip.

lock class-attribute instance-attribute

lock: float = 0.6051

Lock number.

cT class-attribute instance-attribute

cT: float = math.nan

Thrust coefficient T = cT·rpm² (N / rpm²); defaults from Ct.

cM class-attribute instance-attribute

cM: float = math.nan

Reaction-torque coefficient M = cM·rpm² (N·m / rpm²); defaults from Cq.

spin_dir class-attribute instance-attribute

spin_dir: tuple[float, float, float, float] = (1.0, 1.0, -1.0, -1.0)

Rotor spin direction signs; + means clockwise, - means counter-clockwise.

LAV2 defaults to rotors 0/1 clockwise and 2/3 counter-clockwise, so the signs are (+,+,-,-).

tau_f class-attribute instance-attribute

tau_f: float = 0.01

Motor filter time constant (s).

tau_m class-attribute instance-attribute

tau_m: float = 0.05

Legacy motor time constant (s).

max_rpm class-attribute instance-attribute

max_rpm: float = 10000.0

Maximum rotor speed (rpm — LAV2 default).

init_rpm class-attribute instance-attribute

init_rpm: float = math.nan

Initial rotor speed — defaults to 0.2·max_rpm.

rotor_rpm_rate_limit class-attribute instance-attribute

rotor_rpm_rate_limit: float = 50000.0

Rotor-speed rate-of-change limit (rpm/s).

tau_up class-attribute instance-attribute

tau_up: float = math.nan

Motor spin-up time constant (s), defaults to tau_m.

tau_down class-attribute instance-attribute

tau_down: float = math.nan

Motor spin-down time constant (s), defaults to tau_m.

mpc_xy_vel_max class-attribute instance-attribute

mpc_xy_vel_max: float = 12.0

Maximum horizontal velocity setpoint magnitude in m/s (0 - 20).

mpc_z_vel_max_up class-attribute instance-attribute

mpc_z_vel_max_up: float = 3.0

Maximum upward velocity setpoint in m/s (0.5 - 8).

mpc_z_vel_max_dn class-attribute instance-attribute

mpc_z_vel_max_dn: float = 1.5

Maximum downward velocity setpoint magnitude in m/s (0.5 - 4).

mpc_acc_hor_max class-attribute instance-attribute

mpc_acc_hor_max: float = 5.0

Maximum horizontal acceleration setpoint magnitude in m/s^2 (2 - 15).

mpc_acc_up_max class-attribute instance-attribute

mpc_acc_up_max: float = 4.0

Maximum upward acceleration setpoint in m/s^2 (2 - 15).

mpc_acc_down_max class-attribute instance-attribute

mpc_acc_down_max: float = 3.0

Maximum downward acceleration setpoint magnitude in m/s^2 (2 - 15).

mpc_man_tilt_max class-attribute instance-attribute

mpc_man_tilt_max: float = math.radians(35.0)

Maximum manual tilt angle in radians (deg: 0 - 90).

mc_rollrate_max class-attribute instance-attribute

mc_rollrate_max: float = math.radians(220.0)

Maximum roll-rate setpoint in rad/s (deg/s: 0 - 1800).

mc_pitchrate_max class-attribute instance-attribute

mc_pitchrate_max: float = math.radians(220.0)

Maximum pitch-rate setpoint in rad/s (deg/s: 0 - 1800).

mc_yawrate_max class-attribute instance-attribute

mc_yawrate_max: float = math.radians(200.0)

Maximum yaw-rate setpoint in rad/s (deg/s: 0 - 1800).

__post_init__

__post_init__()

Calculate derived parameters and resolve default sentinels.

引发:

类型 描述
ValueError

If spin_dir does not contain four signs.

RotorDynamics

RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device=None, *, backend: BackendName | None = None, xp: ModuleType | None = None)

Bases: DynamicsBase

Batched motor dynamics model for rotor thrust and torque.

This is the backend-agnostic Array API implementation. It keeps the same low-pass motor response, RPM rate limiting, quadratic thrust/torque coefficients, and motor-direction torque signs while operating on (num_envs, 4) batches.

See :mod:lav2.dynamics.numpy.rotor and :mod:lav2.dynamics.torch.rotor for the legacy backend-specific implementations.

Initialize rotor dynamics and backend arrays.

参数:

名称 类型 描述 默认

params

VehicleParams

Vehicle parameters used by the motor model.

VehicleParams()

num_envs

int

Number of parallel environments represented by the batch.

1

device

Optional backend device, mainly used by Torch.

None

backend

BackendName | None

Explicit Array API backend name.

None

xp

ModuleType | None

Pre-resolved Array API namespace. Overrides backend.

None

方法:

名称 描述
randomize

Randomize motor parameters for selected environments.

update

Update motor state and return thrust/torque outputs.

reset

Reset selected environments to initial rotor speeds.

属性:

名称 类型 描述
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute

params: VehicleParams = params

Vehicle parameters for the dynamics model.

randomize

randomize(env_ids=None, randomization: dict[str, tuple[float, float]] | None = None)

Randomize motor parameters for selected environments.

update

update(commands: ArrayLike) -> ArrayLike

Update motor state and return thrust/torque outputs.

参数:

名称 类型 描述 默认

commands

ArrayLike

Desired rotor speeds with shape (num_envs, 4).

必需

返回:

类型 描述
ArrayLike

Batched thrusts followed by torques with shape (num_envs, 8).

reset

reset(env_ids=None)

Reset selected environments to initial rotor speeds.

FlightControlAction

FlightControlAction(cfg: FlightControlActionCfg, env: ManagerBasedRLEnv)

Bases: ActionTerm

Body torque control action term.

This action term applies a wrench to the drone body frame based on action commands

属性:

名称 类型 描述
cfg FlightControlActionCfg

The configuration of the action term.

IO_descriptor GenericActionIODescriptor

The IO descriptor of the LAV2 flight control action term.

cfg instance-attribute

cfg: FlightControlActionCfg = cfg

The configuration of the action term.

IO_descriptor property

IO_descriptor: GenericActionIODescriptor

The IO descriptor of the LAV2 flight control action term.

FlightControlActionCfg

Bases: ActionTermCfg

See :class:FlightControlAction for more details.

属性:

名称 类型 描述
class_type type[ActionTerm]

Class of the action term.

asset_name str

Name of the asset in the environment for which the commands are generated.

rotor_body_names tuple[str, ...]

Ordered rotor body names matching controller/mixer rotor order.

params VehicleParams

Vehicle parameters.

gains dict | None

Optional gains configuration for the flight controller.

limits dict | None

Optional command-limit configuration passed directly to the flight controller.

controller str

Controller class name. Options: 'FlightController' (PID), 'GeoControl'.

control_mode str

Control mode, options: cmd_motor_thrusts, cmd_motor_speeds, cmd_ctbm, cmd_ctbr, cmd_ctatt, cmd_ctatt_euler, cmd_ctatt_quat, cmd_ctatt_rotmat, cmd_ctatt_rotvec, cmd_acc, cmd_vel, cmd_vel_ffacc, cmd_pos.

mapping FlightMappingConfig

Action-mapping range overrides resolved against params.

class_type class-attribute instance-attribute

class_type: type[ActionTerm] = FlightControlAction

Class of the action term.

asset_name class-attribute instance-attribute

asset_name: str = 'robot'

Name of the asset in the environment for which the commands are generated.

rotor_body_names class-attribute instance-attribute

rotor_body_names: tuple[str, ...] = ('rotor0', 'rotor1', 'rotor2', 'rotor3')

Ordered rotor body names matching controller/mixer rotor order.

params class-attribute instance-attribute

params: VehicleParams = VehicleParams()

Vehicle parameters.

gains class-attribute instance-attribute

gains: dict | None = None

Optional gains configuration for the flight controller.

limits class-attribute instance-attribute

limits: dict | None = None

Optional command-limit configuration passed directly to the flight controller.

controller class-attribute instance-attribute

controller: str = 'FlightController'

Controller class name. Options: 'FlightController' (PID), 'GeoControl'.

control_mode class-attribute instance-attribute

control_mode: str = 'cmd_motor_speeds'

Control mode, options: cmd_motor_thrusts, cmd_motor_speeds, cmd_ctbm, cmd_ctbr, cmd_ctatt, cmd_ctatt_euler, cmd_ctatt_quat, cmd_ctatt_rotmat, cmd_ctatt_rotvec, cmd_acc, cmd_vel, cmd_vel_ffacc, cmd_pos.

rotorpy ref: - https://github.com/spencerfolk/rotorpy/blob/main/rotorpy/learning/quadrotor_environments.py#L319C1-L350C12 - https://github.com/spencerfolk/rotorpy/blob/main/rotorpy/vehicles/multirotor.py#L997

TODO: also align control modes with px4, see: https://docs.px4.io/v1.14/en/flight_modes/offboard (version is unclear ATM)

mapping class-attribute instance-attribute

mapping: FlightMappingConfig = FlightMappingConfig()

Action-mapping range overrides resolved against params.

The default mapping is an intentional policy-facing behavior rather than a direct reflection of the parameter-derived controller ranges.

DelayedObservation

DelayedObservation(cfg: DelayedObservationCfg, data_dim: tuple[int, ...], device: str)

Bases: ModifierBase

A modifier used to return a stochastically delayed (stale) version of an observation term. This can also be used to model multi-rate observations for non-sensor terms, e.g., pure MDP terms or proprioceptive terms.

This modifier takes an existing observation term/function, pushes each new batched observation into a DelayBuffer, and returns an older sample according to a per-environment integer time-lag. Lags are drawn uniformly from [min_lag, max_lag], with an optional probability to hold the previous lag (to mimic repeated frames). With 'update_period>0' (multi-rate), new lags are applied only on refresh ticks, which occur every update_period policy steps. Between refreshes the realised lag can increase at most by +1 (frame hold). This process is causal: the lag for each environment can only increase by 1 each step, ensuring that the returned observation is never older than the previous step's lagged observation.

Shapes are preserved: the returned tensor has the exact shape of the wrapped term ([num_envs, *obs_shape]).

Configuration: min_lag (int): Minimum time-lag (in steps) to sample. Default 0. max_lag (int): Maximum time-lag (in steps) to sample. Default 3. per_env (bool): If True, sample a different lag for each environment. If False, use the same lag for all envs. Default True. hold_prob (float): Probability in [0, 1] of holding the previous lag instead of sampling a new one. Default 0.0 (always sample new). update_period (int): If > 0, apply new lags every update_period policy steps (models a lower sensor cadence). Between updates, the lag can increase by at most +1 each step (frame hold). If 0 (default), update every step. per_env_phase (bool): Only relevant if update_period > 0. If True, each environment has a different random phase offset for lag updates. If False, all envs update their lag simultaneously. Default True.

Example: .. code-block:: python

# create a height_scan observation using the delayed observation modifier
from isaaclab.utils.modifiers import DelayedObservation

height_scan = ObservationTermCfg(
    func=mdp.height_scan,
    params={"sensor_cfg": SceneEntityCfg("height_scanner")},
    noise=Unoise(n_min=-0.1, n_max=0.1),
    clip=(-1.0, 1.0),
    modifiers=[
        modifiers.DelayedObservationCfg(
            min_lag=0,
            max_lag=3,
            per_env=True,
            hold_prob=0.66,
            update_period=3,
            per_env_phase=True,
        )
    ],
)

Initialize the DelayedObservation modifier.

参数:

名称 类型 描述 默认

cfg

DelayedObservationCfg

Configuration parameters.

必需

方法:

名称 描述
reset

Resets the delay buffer and internal state.

__call__

Add the current data to the delay buffer and return a stale sample

reset

reset(env_ids: Sequence[int] | None = None)

Resets the delay buffer and internal state.

Since the DelayBuffer does not support partial resets, partial resets keep the underlying buffer but temporarily clamp the affected envs' lags to the number of fresh samples observed since reset. This prevents observations from the previous episode from being returned while the delay window refills.

参数:

名称 类型 描述 默认

env_ids

Sequence[int] | None

The environment ids. Defaults to None, in which case all environments are considered.

None

__call__

__call__(data: Tensor) -> torch.Tensor

Add the current data to the delay buffer and return a stale sample according to the current lag for each environment.

参数:

名称 类型 描述 默认

data

Tensor

The data to apply delay to.

必需

返回:

类型 描述
Tensor

Delayed data. Shape is the same as data.

DelayedObservationCfg

Bases: ModifierCfg

Configuration parameters for a delayed observation modifier.

For more information, please check the :class:DelayedObservation class.

属性:

名称 类型 描述
func type[DelayedObservation]

The delayed observation function to be called for applying the delay.

min_lag int

The minimum lag (in number of policy steps) to be applied to the observations. Defaults to 0.

max_lag int

The maximum lag (in number of policy steps) to be applied to the observations.

per_env bool

Whether to use a separate lag for each environment.

hold_prob float

The probability of holding the previous lag when updating the lag.

update_period int

The period (in number of policy steps) at which the lag is updated.

per_env_phase bool

Whether to use a separate phase for each environment when updating the lag.

func class-attribute instance-attribute

func: type[DelayedObservation] = DelayedObservation

The delayed observation function to be called for applying the delay.

min_lag class-attribute instance-attribute

min_lag: int = 0

The minimum lag (in number of policy steps) to be applied to the observations. Defaults to 0.

max_lag class-attribute instance-attribute

max_lag: int = 3

The maximum lag (in number of policy steps) to be applied to the observations.

This value must be greater than or equal to :attr:min_lag.

per_env class-attribute instance-attribute

per_env: bool = True

Whether to use a separate lag for each environment.

hold_prob class-attribute instance-attribute

hold_prob: float = 0.0

The probability of holding the previous lag when updating the lag.

update_period class-attribute instance-attribute

update_period: int = 1

The period (in number of policy steps) at which the lag is updated.

If set to 0, the lag is sampled once at the beginning and remains constant throughout the simulation. If set to a positive integer, the lag is updated every update_period policy steps. Defaults to 1.

This value must be less than or equal to :attr:max_lag if it is greater than 0.

per_env_phase class-attribute instance-attribute

per_env_phase: bool = True

Whether to use a separate phase for each environment when updating the lag.

If set to True, each environment will have its own phase when updating the lag. If set to False, all environments will share the same phase. Defaults to True.

HelixTrajectory dataclass

HelixTrajectory(*, num_envs: int = 1, device: str | None = None, backend: BackendName | None = None, xp: ModuleType | None = None, initialize: bool = True, yaw_from_velocity: bool = True, fixed_yaw: ArrayLike | float = 0.0, attitude: ArrayLike | tuple[float, float] = (0.0, 0.0), body_rate: ArrayLike | tuple[float, float] = (0.0, 0.0), center: ArrayLike | tuple[float, float, float] = (0.0, 0.0, 1.0), radius: ArrayLike | float = 1.0, omega: ArrayLike | float = 0.5, z_amplitude: ArrayLike | float = 0.0, z_frequency: ArrayLike | float = 1.0, z_phase: ArrayLike | float = 0.0)

Bases: SpatialTrajectory

Batched helix trajectory.

方法:

名称 描述
sample_heading

Sample batched yaw and yaw-rate references for time values t.

build_target

Assemble a batched dict target from motion primitives.

__post_init__

Initialize HelixTrajectory.

sample

Sample the helix at time t.

sample_heading

sample_heading(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> tuple[ArrayLike, ArrayLike]

Sample batched yaw and yaw-rate references for time values t.

返回:

类型 描述
tuple[ArrayLike, ArrayLike]

Tuple of yaw and yaw_rate arrays.

build_target

build_target(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> ControllerTarget

Assemble a batched dict target from motion primitives.

返回:

类型 描述
ControllerTarget

The assembled controller target dictionary.

__post_init__

__post_init__()

Initialize HelixTrajectory.

sample

sample(t: ArrayLike) -> ControllerTarget

Sample the helix at time t.

返回:

类型 描述
ControllerTarget

The sampled controller target.

LemniscateTrajectory dataclass

LemniscateTrajectory(*, num_envs: int = 1, device: str | None = None, backend: BackendName | None = None, xp: ModuleType | None = None, initialize: bool = True, yaw_from_velocity: bool = True, fixed_yaw: ArrayLike | float = 0.0, attitude: ArrayLike | tuple[float, float] = (0.0, 0.0), body_rate: ArrayLike | tuple[float, float] = (0.0, 0.0), center: ArrayLike | tuple[float, float, float] = (0.0, 0.0, 1.0), scale: ArrayLike | float = 1.0, omega: ArrayLike | float = 0.5, z_amplitude: ArrayLike | float = 0.0, z_frequency: ArrayLike | float = 1.0, z_phase: ArrayLike | float = 0.0)

Bases: SpatialTrajectory

Batched Bernoulli lemniscate trajectory.

方法:

名称 描述
sample_heading

Sample batched yaw and yaw-rate references for time values t.

build_target

Assemble a batched dict target from motion primitives.

__post_init__

Initialize LemniscateTrajectory.

sample

Sample the lemniscate at time t.

sample_heading

sample_heading(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> tuple[ArrayLike, ArrayLike]

Sample batched yaw and yaw-rate references for time values t.

返回:

类型 描述
tuple[ArrayLike, ArrayLike]

Tuple of yaw and yaw_rate arrays.

build_target

build_target(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> ControllerTarget

Assemble a batched dict target from motion primitives.

返回:

类型 描述
ControllerTarget

The assembled controller target dictionary.

__post_init__

__post_init__()

Initialize LemniscateTrajectory.

sample

sample(t: ArrayLike) -> ControllerTarget

Sample the lemniscate at time t.

返回:

类型 描述
ControllerTarget

The sampled controller target.

LissajousTrajectory dataclass

LissajousTrajectory(*, num_envs: int = 1, device: str | None = None, backend: BackendName | None = None, xp: ModuleType | None = None, initialize: bool = True, yaw_from_velocity: bool = True, fixed_yaw: ArrayLike | float = 0.0, attitude: ArrayLike | tuple[float, float] = (0.0, 0.0), body_rate: ArrayLike | tuple[float, float] = (0.0, 0.0), center: ArrayLike | tuple[float, float, float] = (0.0, 0.0, 1.0), amplitude: ArrayLike | tuple[float, float, float] = (1.0, 1.0, 0.2), frequency: ArrayLike | tuple[float, float, float] = (1.0, 2.0, 0.5), phase: ArrayLike | tuple[float, float, float] = (0.0, 0.0, 0.0), omega: ArrayLike | float = 0.5)

Bases: SpatialTrajectory

Batched three-dimensional Lissajous trajectory.

方法:

名称 描述
sample_heading

Sample batched yaw and yaw-rate references for time values t.

build_target

Assemble a batched dict target from motion primitives.

__post_init__

Initialize LissajousTrajectory.

sample

Sample the Lissajous trajectory at time t.

sample_heading

sample_heading(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> tuple[ArrayLike, ArrayLike]

Sample batched yaw and yaw-rate references for time values t.

返回:

类型 描述
tuple[ArrayLike, ArrayLike]

Tuple of yaw and yaw_rate arrays.

build_target

build_target(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> ControllerTarget

Assemble a batched dict target from motion primitives.

返回:

类型 描述
ControllerTarget

The assembled controller target dictionary.

__post_init__

__post_init__()

Initialize LissajousTrajectory.

sample

sample(t: ArrayLike) -> ControllerTarget

Sample the Lissajous trajectory at time t.

返回:

类型 描述
ControllerTarget

The sampled controller target.

RectangleTrajectory dataclass

RectangleTrajectory(*, num_envs: int = 1, device: str | None = None, backend: BackendName | None = None, xp: ModuleType | None = None, initialize: bool = True, yaw_from_velocity: bool = True, fixed_yaw: ArrayLike | float = 0.0, attitude: ArrayLike | tuple[float, float] = (0.0, 0.0), body_rate: ArrayLike | tuple[float, float] = (0.0, 0.0), center: ArrayLike | tuple[float, float, float] = (0.0, 0.0, 1.0), size: ArrayLike | tuple[float, float] = (2.0, 1.0), speed: ArrayLike | float = 0.5)

Bases: SpatialTrajectory

Batched constant-speed rectangle trajectory in the horizontal plane.

方法:

名称 描述
sample_heading

Sample batched yaw and yaw-rate references for time values t.

build_target

Assemble a batched dict target from motion primitives.

__post_init__

Initialize RectangleTrajectory.

sample

Sample the rectangle trajectory at time t.

sample_heading

sample_heading(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> tuple[ArrayLike, ArrayLike]

Sample batched yaw and yaw-rate references for time values t.

返回:

类型 描述
tuple[ArrayLike, ArrayLike]

Tuple of yaw and yaw_rate arrays.

build_target

build_target(t: ArrayLike, pos: ArrayLike, vel: ArrayLike, acc: ArrayLike) -> ControllerTarget

Assemble a batched dict target from motion primitives.

返回:

类型 描述
ControllerTarget

The assembled controller target dictionary.

__post_init__

__post_init__()

Initialize RectangleTrajectory.

sample

sample(t: ArrayLike) -> ControllerTarget

Sample the rectangle trajectory at time t.

返回:

类型 描述
ControllerTarget

The sampled controller target.

RandomTrajectoryCommand

RandomTrajectoryCommand(cfg: RandomTrajectoryCommandCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Trajectory command generator with randomized type and parameters per environment.

RandomTrajectoryCommandCfg

Bases: CommandTermCfg

Configuration for randomized trajectory commands.

randomize_action_term_attr

randomize_action_term_attr(env: ManagerBasedEnv, env_ids: Tensor | None, action_term_name: str = 'flight_control_action', attr_name: str = '_flight_controller', **kwargs) -> None

Randomize a selected action-term attribute.

randomize_controller_params

randomize_controller_params(env: ManagerBasedEnv, env_ids: Tensor | None, action_term_name: str = 'flight_control_action', controller_attr: str = '_flight_controller', limits: dict | None = None, params: dict[str, tuple[float, float]] | None = None, randomize_gains: bool | dict = False) -> None

Randomize controller gains and command limits attached to an action term.

参数:

名称 类型 描述 默认

limits

dict | None

Min/max limit ranges forwarded to controller.randomize().

None

params

dict[str, tuple[float, float]] | None

Physical parameter ranges (mass, g) for controller.randomize().

None

randomize_gains

bool | dict

False (default) – no gain randomization. True – auto-generate ranges via controller.gains_to_randomization_ranges(). dict – use the given min/max ranges directly.

False

randomize_mixer_params

randomize_mixer_params(env: ManagerBasedEnv, env_ids: Tensor | None, action_term_name: str = 'flight_control_action', mixer_attr: str = '_mixer', param_range: dict[str, tuple[float, float]] | None = None) -> None

Randomize mixer parameters attached to an action term.

randomize_rotor_params

randomize_rotor_params(env: ManagerBasedEnv, env_ids: Tensor | None, action_term_name: str = 'flight_control_action', rotor_attr: str = '_rotor_dynamics', param_range: dict[str, tuple[float, float]] | None = None) -> None

Randomize rotor parameters attached to an action term.

randomize_mapping_params

randomize_mapping_params(env: ManagerBasedEnv, env_ids: Tensor | None, action_term_name: str = 'flight_control_action', mapper_attr: str = '_mapper', param_range: dict[str, tuple[float, float]] | None = None) -> None

Randomize action-mapper runtime parameters attached to an action term.

target_pos_b

target_pos_b(env: ManagerBasedRLEnv, command_name: str | None = None, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Position of target in body frame.

root_euler_w

root_euler_w(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Euler angles of the root in world frame.

root_axis_angle_w

root_axis_angle_w(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Axis-angle of the root in world frame.

root_rotmat_w_flat

root_rotmat_w_flat(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Rotation matrix of the root in world frame, flattened to a 9D vector.

lin_vel_l2

lin_vel_l2(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Penalize base linear velocity using L2 squared kernel.

ang_vel_l2

ang_vel_l2(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Penalize base angular velocity using L2 squared kernel.

pos_error_l2

pos_error_l2(env: ManagerBasedRLEnv, command_name: str) -> torch.Tensor

Penalize asset pos from its target pos using L2 squared kernel.

pos_error_tanh

pos_error_tanh(env: ManagerBasedRLEnv, std: float, command_name: str) -> torch.Tensor

Penalize asset pos from its target pos using tanh kernel.

yaw_error_l2

yaw_error_l2(env: ManagerBasedRLEnv, command_name: str) -> torch.Tensor

Penalize heading error from target heading using L2 squared kernel.

yaw_error_tanh

yaw_error_tanh(env: ManagerBasedRLEnv, std: float, command_name: str) -> torch.Tensor

Penalize heading error from target heading using tanh kernel.

track_lin_vel_z_exp

track_lin_vel_z_exp(env: ManagerBasedRLEnv, std: float, command_name: str, is_bimodal: bool = False, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Reward tracking of linear velocity commands (z axis) using exponential kernel.

track_lin_vel_exp

track_lin_vel_exp(env: ManagerBasedRLEnv, std: float, command_name: str, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Reward tracking of linear velocity commands using exponential kernel.

track_yaw_vel_exp

track_yaw_vel_exp(env: ManagerBasedRLEnv, std: float, command_name: str, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot')) -> torch.Tensor

Reward tracking of angular velocity commands (yaw) using exponential kernel.

hover_tracking

hover_tracking(env: ManagerBasedRLEnv, std: float = 0.1, action_name: str = 'flight_control_action') -> torch.Tensor

Penalize deviation of the collective acceleration command from hover.

This reward applies to any flight action mode whose first action channel directly represents total collective acceleration (cmd_ctatt*, cmd_ctbr, cmd_ctbm, etc.). Other modes return zero.

The penalty measures how far the current collective action sample is from hover acceleration. This encourages the policy to stay near the hover operating point.

bimodal_action_tanh

bimodal_action_tanh(env: ManagerBasedRLEnv, std: float, command_name: str, flight_action_name: str = 'flight_control_action', ground_action_name: str = 'ground_control_action', ground_weight: float = 1.0, flight_weight: float = 1.0) -> torch.Tensor

Penalize bimodal actions using tanh kernel.

bimodal_height_tanh

bimodal_height_tanh(env: ManagerBasedRLEnv, std: float, command_name: str, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot'), ground_weight: float = 1.0, flight_weight: float = 1.0) -> torch.Tensor

Penalize bimodal height using tanh kernel.

contact_impulse

contact_impulse(env: ManagerBasedRLEnv, threshold: float, sensor_cfg: SceneEntityCfg, mode: str = 'threshold') -> torch.Tensor

Penalize excessive contact impulse (rate of change of contact forces).

This function calculates the impulse as the change in contact forces between consecutive time steps and penalizes values that exceed a threshold.

参数:

名称 类型 描述 默认

env

ManagerBasedRLEnv

The learning environment.

必需

threshold

float

Maximum acceptable impulse magnitude. Forces below this are not penalized.

必需

sensor_cfg

SceneEntityCfg

Configuration for the contact sensor, specifying which bodies to monitor.

必需

mode

str

Penalty calculation mode: - "threshold": Penalize only the amount exceeding threshold (continuous) - "binary": Return 1.0 if any impulse exceeds threshold, else 0.0 (discrete) - "total": Return total impulse magnitude regardless of threshold (for monitoring)

'threshold'

返回:

类型 描述
Tensor

torch.Tensor: Penalty value for each environment: - "threshold" mode: Sum of (impulse - threshold) for all violations - "binary" mode: 1.0 if violation exists, 0.0 otherwise - "total" mode: Total impulse magnitude

引发:

类型 描述
ValueError

If the sensor history length is less than 2 or the mode is invalid.

示例:

>>> # Penalize hard landings (impulse > 50 N·s)
>>> impulse_penalty = contact_impulse(
...     env, threshold=50.0,
...     sensor_cfg=SceneEntityCfg("contact_sensor", body_ids=[arml_id, armr_id]),
...     mode="threshold"
... )
>>> rewards["impulse_penalty"] = impulse_penalty * -1.0

bimodal_contacts

bimodal_contacts(env: ManagerBasedRLEnv, command_name: str, threshold: float, sensor_cfg: SceneEntityCfg, mode: str = 'threshold', ground_weight: float = 1.0, flight_weight: float = 1.0) -> torch.Tensor

Penalize contacts when switching from flight to ground mode.

died

died(env: ManagerBasedRLEnv, asset_cfg: SceneEntityCfg = SceneEntityCfg('robot'), min: float = 0.2, max: float = 2.0) -> torch.Tensor

Termination condition based on the robot's height.