Skip to content

lav2

LAV2 package root.

Modules:

Name Description
assets

Asset loading helpers for LAV2.

controller

Controller package for LAV2.

dynamics

Dynamics models for LAV2.

gamepads

Gamepad input helpers for LAV2.

runner

Runner utilities for LAV2 training and evaluation.

tasks

Task packages for supported training frameworks for LAV2.

trajectories

Trajectory implementations package for LAV2.

assets

Asset loading helpers for LAV2.

controller

Controller package for LAV2.

Modules:

Name Description
__main__

Entry point for running the LAV2 controller demo.

base

Base interfaces for LAV2 controllers.

geo

Geometric controllers and helpers for SE(3) tracking.

mapping

Control-mode mapping utilities for NumPy-based controller pipelines.

mixer

Command mixer for mapping thrust/moment demands to rotor speeds.

pid

PID controllers for flight and track control.

run

Interactive MuJoCo runner for flight and track controllers.

torch

Torch-based controller implementations.

utils

Logging utilities for controller runs.

xadap

Python implementation of Learning-based Controller for Extreme Adaptation.

__main__

Entry point for running the LAV2 controller demo.

base

Base interfaces for LAV2 controllers.

Classes:

Name Description
ControllerBase

Abstract controller base class.

ControllerBase

ControllerBase(params: VehicleParams, control_mask: ndarray | Tensor, gains: dict | None = None)

Bases: ABC

Abstract controller base class.

Initialize shared controller state.

Methods:

Name Description
update

Update the controller and return control outputs.

reset

Reset controller state if necessary.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

gains dict | None

Optional gains configuration for derived controllers.

target ndarray | Tensor

Latest target input to the controller.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

gains instance-attribute
gains: dict | None = gains

Optional gains configuration for derived controllers.

target instance-attribute
target: ndarray | Tensor

Latest target input to the controller.

update abstractmethod
update(target, state)

Update the controller and return control outputs.

reset abstractmethod
reset(*args, **kwargs)

Reset controller state if necessary.

geo

Geometric controllers and helpers for SE(3) tracking.

Classes:

Name Description
GeoControl

Python implementation of Geometric Controller.

GeometricAdaptiveController

Python implementation of Geometric Adaptive Controller.

L1_GeoControl

Python implementation of L1 Adaptive Geometric Controller.

Functions:

Name Description
euler_zyx_to_R

Convert ZYX Euler angles into a rotation matrix.

GeoControl

GeoControl(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], gains: dict | None = None)

Bases: ControllerBase

Python implementation of Geometric Controller.

Based on: Taeyoung Lee, Melvin Leok, and N.H. McClamroch. "Geometric Tracking Control of a Quadrotor UAV on SE(3)" [DOI: 10.1109/CDC.2010.5717652].

Initialize gains and error buffers.

Parameters:

Name Type Description Default
params
VehicleParams

Vehicle parameters.

VehicleParams()
control_mask
list[int]

Control mask for target/state channels.

[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
gains
dict | None

Optional geometric gains for keys x/v/R/W.

None

Methods:

Name Description
reset

Reset controller state.

update

Compute thrust and moments from target and state.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

reset
reset()

Reset controller state.

update
update(target: ndarray, state: ndarray) -> np.ndarray

Compute thrust and moments from target and state.

Parameters:

Name Type Description Default
target
ndarray

Desired state vector.

required
state
ndarray

Current state vector.

required

Returns:

Type Description
ndarray

np.ndarray: Control output ordered as [thrust, Mx, My, Mz].

GeometricAdaptiveController

GeometricAdaptiveController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], gains: dict | None = None)

Bases: GeoControl

Python implementation of Geometric Adaptive Controller.

Based on: Farhad A. Goodarzi, Daewon Lee, and Taeyoung Lee. "Geometric Adaptive Tracking Control of a Quadrotor Unmanned Aerial Vehicle on SE(3) for Agile Maneuvers." [DOI: 10.1115/1.4030419].

Initialize adaptive gains and inherited geometry control.

Parameters:

Name Type Description Default
params
VehicleParams

Vehicle parameters.

VehicleParams()
control_mask
list[int]

Control mask for target/state channels.

[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
gains
dict | None

Optional geometric gains for keys x/v/R/W.

None

Methods:

Name Description
update

Adaptive geometric control using target/state vectors (GeoControl layout).

reset

Reset controller state.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

update
update(target: ndarray, state: ndarray) -> np.ndarray

Adaptive geometric control using target/state vectors (GeoControl layout).

Returns:

Type Description
ndarray

np.ndarray: Control output ordered as [thrust, Mx, My, Mz].

reset
reset()

Reset controller state.

L1_GeoControl

L1_GeoControl(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], gains: dict | None = None)

Bases: GeoControl

Python implementation of L1 Adaptive Geometric Controller.

Based on: Zhuohuan Wu, Sheng Cheng, Pan Zhao, Aditya Gahlawat, Kasey A. Ackerman, Arun Lakshmanan, Chengyu Yang, Jiahao Yu, Naira Hovakimyan. "L1Quad: L1 Adaptive Augmentation of Geometric Control for Agile Quadrotors with Performance Guarantees" [arXiv:2302.07208].

Initialize L1 adaptive parameters.

Parameters:

Name Type Description Default
params
VehicleParams

Vehicle parameters.

VehicleParams()
control_mask
list[int]

Control mask for target/state channels.

[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
gains
dict | None

Optional geometric gains for keys x/v/R/W.

None

Methods:

Name Description
update

L1-augmented geometric control using target/state vectors.

reset

Reset controller state.

Attributes:

Name Type Description
dt_L1

For large uncertainties ...

L1_params

Initialization of L1 inputs

params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

dt_L1 instance-attribute
dt_L1 = sim_dt

For large uncertainties ...

L1_params instance-attribute
L1_params = (As_v, As_omega, dt_L1, ctoffq1Thrust, ctoffq1Moment, ctoffq2Moment, mass, g, inertia)

Initialization of L1 inputs

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

update
update(target: ndarray, state: ndarray) -> np.ndarray

L1-augmented geometric control using target/state vectors.

Parameters:

Name Type Description Default
target
ndarray

12-dim vector [x,y,z,vx,vy,vz,roll,pitch,yaw,wx,wy,wz].

required
state
ndarray

12-dim vector [x,y,z,vx,vy,vz,roll,pitch,yaw,wx,wy,wz].

required

Returns:

Type Description
ndarray

np.ndarray: Control output ordered as [thrust, Mx, My, Mz].

reset
reset()

Reset controller state.

euler_zyx_to_R

euler_zyx_to_R(yaw: float, pitch: float, roll: float) -> np.ndarray

Convert ZYX Euler angles into a rotation matrix.

Returns:

Type Description
ndarray

np.ndarray: 3x3 rotation matrix.

mapping

Control-mode mapping utilities for NumPy-based controller pipelines.

Classes:

Name Description
FlightMappingLimits

Per-channel limits used when mapping normalized actions to targets.

FlightMappingResult

Mapped result for a normalized flight action or action batch.

FlightActionMapper

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

Functions:

Name Description
target_to_command

Convert a full 12D target into a compact command vector.

FlightMappingLimits dataclass

FlightMappingLimits(vel_limits: tuple[float, float, float] = (5.0, 5.0, 5.0), att_limits: tuple[float, float, float] = (1.0, 1.0, math.pi), br_limits: tuple[float, float, float] = (2.0, 2.0, 2.0))

Per-channel limits used when mapping normalized actions to targets.

FlightMappingResult dataclass

FlightMappingResult(clamped_action: ndarray | Tensor, rpm_command: ndarray | Tensor, control: ndarray | Tensor | None = None, target: ndarray | Tensor | None = None)

Mapped result for a normalized flight action or action batch.

FlightActionMapper

FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), limits: FlightMappingLimits = FlightMappingLimits())

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

Initialize a NumPy flight action mapper for the selected control mode.

Methods:

Name Description
map_action

Map a normalized action into an RPM command and optional intermediates.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller target expansion step.

requires_controller property
requires_controller: bool

Whether this mode needs a controller target expansion step.

map_action
map_action(action: ndarray, mixer: Mixer, *, state: ndarray | None = None, flight_controller: ControllerBase | None = None) -> FlightMappingResult

Map a normalized action into an RPM command and optional intermediates.

target_to_command

target_to_command(target: ndarray, command_mode: str, state: ndarray | None = None) -> np.ndarray

Convert a full 12D target into a compact command vector.

Parameters:

Name Type Description Default
target
ndarray

Full target state ordered as [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz].

required
command_mode
str

Supported target command mode. Valid values are "tgt_pos", "tgt_vel", "tgt_ctatt", and "tgt_ctbr".

required
state
ndarray | None

Current 12D vehicle state. Required only for "tgt_pos", where the returned command is the body-frame position error and heading error rather than an absolute world-frame pose target.

None

Returns:

Name Type Description
ndarray

np.ndarray: A compact command vector matching the requested command

mode ndarray
  • tgt_pos -> [dx_body, dy_body, dz, dyaw]
  • tgt_vel -> [vx, vy, vz, yaw_rate]
  • tgt_ctatt -> [collective, roll, pitch, yaw_rate]
  • tgt_ctbr -> [collective, wx, wy, wz]

Raises:

Type Description
ValueError

If command_mode is unsupported or state is missing for tgt_pos.

mixer

Command mixer for mapping thrust/moment demands to rotor speeds.

Classes:

Name Description
Mixer

Map thrust and moment demands to rotor commands.

Mixer

Mixer(params: VehicleParams = VehicleParams(), verbose=False)

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the mixer with vehicle parameters and mixer matrix.

Methods:

Name Description
apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

Attributes:

Name Type Description
mat

转速平方到推力扭矩

inv_mat

推力扭矩到转速平方

max_rpm_sq

最大转速平方

min_rpm_sq

最小转速平方

max_wrench

单桨最大推力/力矩

min_wrench

单桨最小推力/力矩

max_collective_thrust

最大总推力

mat instance-attribute
mat = array([[cT * cos(alpha)] * 4, [cT * cos(alpha) * y] * 4, [cT * cos(alpha) * x] * 4, [cT * sin(alpha) * x + cM] * 4]) * array([[1, 1, 1, 1], [-1, 1, 1, -1], [-1, 1, -1, 1], [1, 1, -1, -1]])

转速平方到推力扭矩

inv_mat instance-attribute
inv_mat = pinv(mat)

推力扭矩到转速平方

max_rpm_sq instance-attribute
max_rpm_sq = max_rpm ** 2

最大转速平方

min_rpm_sq instance-attribute
min_rpm_sq = init_rpm ** 2

最小转速平方

max_wrench instance-attribute
max_wrench = mat[:, 1] * max_rpm_sq

单桨最大推力/力矩

min_wrench instance-attribute
min_wrench = mat[:, 1] * min_rpm_sq

单桨最小推力/力矩

max_collective_thrust instance-attribute
max_collective_thrust = max_wrench[0] * 4.0

最大总推力

apply_thrust_curve
apply_thrust_curve(normalized_thrust: float, mode: int = 1) -> float

Apply thrust curve to normalized thrust command.

References
  • cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137
  • cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

Parameters:

Name Type Description Default
normalized_thrust
float

Normalized thrust command [-1, 1].

required
mode
int

Thrust curve mode.

1

Returns:

Name Type Description
float float

Total thrust in Newtons.

Raises:

Type Description
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands
calculate_rotor_commands(control: ndarray) -> np.ndarray

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default
control
ndarray

Desired total thrust and roll/pitch/yaw moments. Shape: (4,).

required

Returns:

Type Description
ndarray

np.ndarray: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). Shape: (4,).

pid

PID controllers for flight and track control.

Classes:

Name Description
PID

Classic PID controller with optional derivative filtering.

FlightController

PID-based flight controller.

TrackController

PID-based track controller.

PID

PID(Kp: Any = 0.0, Ki: Any = 0.0, Kd: Any = 0.0, dt: float = 0.01, N: float = 100.0, integral_limit: Any | None = None)

Classic PID controller with optional derivative filtering.

The internal state shape follows Kp through NumPy broadcasting. This makes scalar and multi-axis gains behave consistently without additional shape bookkeeping.

Initialize PID gains and internal state.

Parameters:

Name Type Description Default
Kp
Any

Proportional gain. Its shape defines the PID state shape.

0.0
Ki
Any

Integral gain broadcast against the PID state.

0.0
Kd
Any

Derivative gain broadcast against the PID state.

0.0
dt
float

Controller time step.

0.01
N
float

First-order derivative filter coefficient.

100.0
integral_limit
Any | None

Optional elementwise clamp for the integral state.

None

Methods:

Name Description
reset

Reset integrator and derivative state.

update

Compute the PID output for the current error.

reset
reset() -> None

Reset integrator and derivative state.

update
update(error: ndarray | float) -> np.ndarray

Compute the PID output for the current error.

Parameters:

Name Type Description Default
error
ndarray | float

Control error compatible with the PID state shape derived from Kp.

required

Returns:

Type Description
ndarray

np.ndarray: Combined P+I+D control output.

FlightController

FlightController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0], gains: dict | None = None, limits: dict | None = None)

Bases: ControllerBase

PID-based flight controller.

Initialize the flight PID controller.

Parameters:

Name Type Description Default
params
VehicleParams

Vehicle parameters used by the controller.

VehicleParams()
control_mask
list[int]

Boolean-like mask indicating which target channels are provided externally and which are filled by the controller.

[1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0]
gains
dict | None

Optional PID gain dictionary. If omitted, the module-level flight defaults are used.

None
limits
dict | None

Optional command-limit configuration. Supported keys include vel_cmd, vel_error and att_cmd. Any key can be set to None to disable that clamp.

None

Methods:

Name Description
reset

Reset all inner PID loops of the flight controller.

update

Compute thrust and moments for the current target/state.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

reset
reset() -> None

Reset all inner PID loops of the flight controller.

update
update(target: ndarray, state: ndarray) -> np.ndarray

Compute thrust and moments for the current target/state.

Parameters:

Name Type Description Default
target
ndarray

Desired state vector with shape (12,) ordered as [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz].

required
state
ndarray

Current state vector with the same ordering as target.

required

Returns:

Type Description
ndarray

np.ndarray: Control output [thrust, roll_moment, pitch_moment, yaw_moment].

TrackController

TrackController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [0, 0, 0, 1, 0, 1], gains: dict | None = None)

Bases: ControllerBase

PID-based track controller.

Initialize the track PID controller.

Parameters:

Name Type Description Default
params
VehicleParams

Vehicle parameters used by the controller.

VehicleParams()
control_mask
list[int]

Boolean-like mask indicating which target channels are provided externally and which are filled by the controller.

[0, 0, 0, 1, 0, 1]
gains
dict | None

Optional PID gain dictionary. If omitted, the module-level track defaults are used.

None

Methods:

Name Description
reset

Reset all inner PID loops of the track controller.

update

Compute track accelerations for the current target/state.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

reset
reset() -> None

Reset all inner PID loops of the track controller.

update
update(target: ndarray, state: ndarray) -> np.ndarray

Compute track accelerations for the current target/state.

Parameters:

Name Type Description Default
target
ndarray

Desired state vector with shape (6,) ordered as [x, y, yaw, u, v, r].

required
state
ndarray

Current state vector with the same ordering as target.

required

Returns:

Type Description
ndarray

np.ndarray: Left and right track acceleration commands [a_l, a_r].

run

Interactive MuJoCo runner for flight and track controllers.

Functions:

Name Description
key_callback

Handle keyboard target updates.

load_callback

Load the MuJoCo model and data for the viewer.

control_callback

Run the control loop for the active mode.

main

Launch the interactive demo with CLI options.

key_callback

key_callback(keycode: int) -> None

Handle keyboard target updates.

load_callback

load_callback() -> tuple[mujoco.MjModel, mujoco.MjData]

Load the MuJoCo model and data for the viewer.

Returns:

Name Type Description
tuple tuple[MjModel, MjData]

(m, d) MuJoCo model and data objects.

control_callback

control_callback(m: MjModel, d: MjData) -> None

Run the control loop for the active mode.

main

main(argv: list[str] | None = None) -> None

Launch the interactive demo with CLI options.

Parameters:

Name Type Description Default
argv
list[str] | None

Optional argument list to parse.

None
Notes

--mode: 0=flight (default), 1=track. --control: Flight controller: pid|geo (default pid). Track: pid. --control-mode: Flight control mode (cmd_pos|cmd_vel|cmd_ctatt|cmd_ctbr). --gamepad: Enable gamepad input. --trajectory: Enable automatic trajectory tracking for flight cmd_pos/cmd_vel only.

torch

Torch-based controller implementations.

Modules:

Name Description
mapping

Control-mode mapping utilities for batched Torch controller pipelines.

mixer

Torch mixer for mapping thrust/moment demands to rotor speeds.

pid

Torch-based PID controllers for batched simulation.

mapping

Control-mode mapping utilities for batched Torch controller pipelines.

Classes:

Name Description
FlightActionMapper

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

Functions:

Name Description
target_to_command

Convert full 12D target batches into compact command vectors.

FlightActionMapper
FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), limits: FlightMappingLimits = FlightMappingLimits(), *, num_envs: int = 1, device: str | device = 'cpu')

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

Initialize a batched Torch flight action mapper for the selected mode.

Methods:

Name Description
map_action

Map a normalized batched action into RPM commands and intermediates.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller target expansion step.

requires_controller property
requires_controller: bool

Whether this mode needs a controller target expansion step.

map_action
map_action(action: Tensor, mixer: Mixer, *, state: Tensor | None = None, flight_controller: ControllerBase | None = None) -> FlightMappingResult

Map a normalized batched action into RPM commands and intermediates.

target_to_command
target_to_command(target: Tensor, command_mode: str, state: Tensor | None = None) -> torch.Tensor

Convert full 12D target batches into compact command vectors.

Parameters:

Name Type Description Default
target
Tensor

Batched target states with shape (N, 12) ordered as [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz].

required
command_mode
str

Supported target command mode. Valid values are "tgt_pos", "tgt_vel", "tgt_ctatt", and "tgt_ctbr".

required
state
Tensor | None

Current batched 12D vehicle state with shape (N, 12). Required only for "tgt_pos", where the returned command is the body-frame position error and heading error.

None

Returns:

Type Description
Tensor

torch.Tensor: A batched compact command tensor with shape (N, 4)

Tensor

matching the requested mode: - tgt_pos -> [dx_body, dy_body, dz, dyaw] - tgt_vel -> [vx, vy, vz, yaw_rate] - tgt_ctatt -> [collective, roll, pitch, yaw_rate] - tgt_ctbr -> [collective, wx, wy, wz]

Raises:

Type Description
ValueError

If command_mode is unsupported or state is missing for tgt_pos.

mixer

Torch mixer for mapping thrust/moment demands to rotor speeds.

Classes:

Name Description
Mixer

Map thrust and moment demands to rotor commands.

Mixer
Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the torch mixer with vehicle parameters and device.

Methods:

Name Description
randomize

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

randomize
randomize(env_ids=None, randomization=None)

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve
apply_thrust_curve(normalized_thrust: Tensor, mode: int = 1) -> torch.Tensor

Apply thrust curve to normalized thrust command.

References

cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137 cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

Parameters:

Name Type Description Default
normalized_thrust Tensor

Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise.

required
mode int

Thrust curve mode.

1

Returns:

Type Description
Tensor

torch.Tensor: Thrust in Newtons with the same shape as normalized_thrust.

Raises:

Type Description
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands
calculate_rotor_commands(control: Tensor) -> torch.Tensor

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default
control Tensor

Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). Shape: (num_envs, 4)

pid

Torch-based PID controllers for batched simulation.

Classes:

Name Description
PID

Vectorized PID controller for multiple environments.

FlightController

PID flight controller (batched).

TrackController

PID track controller (batched).

PID
PID(Kp: Tensor, Ki: Tensor | None = None, Kd: Tensor | None = None, dt: float = 0.01, N: float = 100.0, integral_limit: Tensor | None = None, num_envs: int = 1)

Vectorized PID controller for multiple environments.

Initialize PID gains and state tensors.

Parameters:

Name Type Description Default
Kp
Tensor

Proportional gain tensor with a leading environment dimension.

required
Ki
Tensor | None

Integral gain tensor with the same shape as Kp.

None
Kd
Tensor | None

Derivative gain tensor with the same shape as Kp.

None
dt
float

Controller time step.

0.01
N
float

First-order derivative filter coefficient.

100.0
integral_limit
Tensor | None

Optional clamp applied elementwise to the integral state.

None
num_envs
int

Number of environments.

1

Methods:

Name Description
reset

Reset PID state for selected environments.

update

Compute PID output for the given error tensor.

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Reset PID state for selected environments.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

Indices or slice selecting which environments to reset.

required
update
update(error: Tensor) -> torch.Tensor

Compute PID output for the given error tensor.

Parameters:

Name Type Description Default
error Tensor

Batched control error tensor compatible with the internal state shape determined from Kp.

required

Returns:

Type Description
Tensor

torch.Tensor: Combined P+I+D control output.

FlightController
FlightController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0], gains: dict | None = None, limits: dict | None = None, num_envs: int = 1, device: str | device = 'cpu')

Bases: ControllerBase

PID flight controller (batched).

Initialize the batched flight PID controller.

Methods:

Name Description
randomize

Randomize configured PID gains and command limits for selected environments.

reset

Reset PID loops for selected environments.

update

Update controller.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

randomize
randomize(env_ids=None, gains=None, limits=None)

Randomize configured PID gains and command limits for selected environments.

reset
reset(env_ids)

Reset PID loops for selected environments.

update
update(target: Tensor, state: Tensor) -> torch.Tensor

Update controller.

Parameters:

Name Type Description Default
target Tensor

(N, 12) desired [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz]

required
state Tensor

(N, 12) current state same ordering.

required

Returns:

Type Description
Tensor

torch.Tensor: Tensor of shape (N, 4): [thrust, roll_moment, pitch_moment, yaw_moment].

TrackController
TrackController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [0, 0, 0, 1, 0, 1], gains: dict | None = None, num_envs: int = 1, device: str | device = 'cpu')

Bases: ControllerBase

PID track controller (batched).

Initialize the batched track controller.

Methods:

Name Description
randomize

Randomize configured PID gains for all or selected environments.

reset

Reset PID loops for selected environments.

update

Update controller.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

randomize
randomize(env_ids=None, gains=None)

Randomize configured PID gains for all or selected environments.

reset
reset(env_ids)

Reset PID loops for selected environments.

update
update(target: Tensor, state: Tensor) -> torch.Tensor

Update controller.

Parameters:

Name Type Description Default
target Tensor

(N, 6) desired [x, y, yaw, u, v, r]

required
state Tensor

(N, 6) current state same ordering.

required

Returns:

Type Description
Tensor

torch.Tensor: (N, 2) left/right acceleration commands.

utils

Logging utilities for controller runs.

Classes:

Name Description
Logger

A class for logging and visualization.

Logger

Logger(logging_freq_hz: int, output_folder: str = 'results', num_drones: int = 1, duration_sec: int = 0, colab: bool = False)

A class for logging and visualization.

Stores, saves to file, and plots the kinematic information and RPMs of a simulation with one or more drones.

Initialize logger buffers and output settings.

Note

The order in which information is stored by Logger.log() is not the same as the one in obs["id"]["state"]; see implementation below.

Parameters:

Name Type Description Default
logging_freq_hz
int

Logging frequency in Hz.

required
output_folder
str

Output directory for saved logs.

'results'
num_drones
int

Number of drones.

1
duration_sec
int

Preallocated duration in seconds (0 disables).

0
colab
bool

Enable Colab-friendly plotting.

False

Methods:

Name Description
log

Log entries for a single simulation step.

save

Save the logs to file.

save_as_csv

Save logs as comma separated values.

plot

Plot kinematics and RPMs for all drones.

log
log(drone: int, timestamp: float, state: ndarray, control: ndarray = np.zeros(12))

Log entries for a single simulation step.

Parameters:

Name Type Description Default
drone
int

Drone index for the log entry.

required
timestamp
float

Simulation timestamp.

required
state
ndarray

Drone state vector, shape (20,).

required
control
ndarray

Control target vector, shape (12,).

zeros(12)
save
save()

Save the logs to file.

save_as_csv
save_as_csv(comment: str = '')

Save logs as comma separated values.

Parameters:

Name Type Description Default
comment
str

Added to the folder name.

''
plot
plot()

Plot kinematics and RPMs for all drones.

xadap

Python implementation of Learning-based Controller for Extreme Adaptation.

Based on: Dingqi Zhang, Antonio Loquercio, Jerry Tang, Ting-Hao Wang, Jitendra Malik, Mark W. Mueller. "A Learning-based Quadcopter Controller with Extreme Adaptation" IEEE Transactions on Robotics, 41(2):3948-3964, 2025. https://doi.org/10.1109/TRO.2025.3577037

Classes:

Name Description
ModelType

Enumeration for model normalization variants.

ButterworthFilter

Low-pass filter for smoothing sensor measurements.

NeuralNetworkModel

Neural network model for adaptation.

Xadap_NN_control

Controller combining high-level controller with neural adaptation.

ModelType

Bases: Enum

Enumeration for model normalization variants.

ButterworthFilter

ButterworthFilter(cutoff_freq=30, sample_rate=100)

Low-pass filter for smoothing sensor measurements.

Initialize filter coefficients and buffers.

Parameters:

Name Type Description Default
cutoff_freq
float

Cutoff frequency in Hz.

30
sample_rate
float

Sampling rate in Hz.

100

Methods:

Name Description
run

Filter a new sample and return the smoothed value.

run
run(x_new: ndarray) -> np.ndarray

Filter a new sample and return the smoothed value.

Parameters:

Name Type Description Default
x_new
ndarray

New sample vector.

required

Returns:

Type Description
ndarray

np.ndarray: Filtered sample.

NeuralNetworkModel

NeuralNetworkModel()

Neural network model for adaptation.

Initialize ONNX model paths, load normalization parameters, and activate sessions.

Methods:

Name Description
activate

Initialize ONNX runtime sessions.

normalize_obs

Normalize observations based on model type.

predict

Run inference through both networks.

activate
activate()

Initialize ONNX runtime sessions.

normalize_obs
normalize_obs(obs: ndarray, model_type: ModelType) -> np.ndarray

Normalize observations based on model type.

Parameters:

Name Type Description Default
obs
ndarray

Raw observation array.

required
model_type
ModelType

Which normalization scheme to apply.

required

Returns:

Type Description
ndarray

np.ndarray: Normalized observations.

predict
predict(cur_obs: ndarray, last_act: ndarray, obs_history: ndarray, act_history: ndarray) -> tuple[np.ndarray, np.ndarray]

Run inference through both networks.

Parameters:

Name Type Description Default
cur_obs
ndarray

Current observation vector.

required
last_act
ndarray

Previous action vector.

required
obs_history
ndarray

Flattened observation history.

required
act_history
ndarray

Flattened action history.

required

Returns:

Type Description
tuple[ndarray, ndarray]

tuple[np.ndarray, np.ndarray]: Normalized and raw actions.

Xadap_NN_control

Xadap_NN_control(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], gains: dict | None = None)

Bases: FlightController

Controller combining high-level controller with neural adaptation.

Initialize the hybrid controller and buffers.

Parameters:

Name Type Description Default
params
VehicleParams

Vehicle parameters.

VehicleParams()
control_mask
list[int]

Control mask for target/state channels.

[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
gains
dict | None

Optional PID gains passed to FlightController.

None

Methods:

Name Description
update

Compute thrust and moments from target and state.

reset

Reset controller state and buffers.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

update
update(target: ndarray, state: ndarray) -> np.ndarray

Compute thrust and moments from target and state.

Parameters:

Name Type Description Default
target
ndarray

Desired state vector.

required
state
ndarray

Current state vector.

required

Returns:

Type Description
ndarray

np.ndarray: Control output ordered as [thrust, Mx, My, Mz].

reset
reset(*args, **kwargs)

Reset controller state and buffers.

dynamics

Dynamics models for LAV2.

Modules:

Name Description
base

Base interfaces for LAV2 dynamics models.

params

Vehicle parameter definitions for LAV2.

rotor

Rotor dynamics model for thrust and torque outputs.

torch

Torch-based dynamics models for LAV2.

track

Track dynamics model for ground locomotion.

base

Base interfaces for LAV2 dynamics models.

Classes:

Name Description
DynamicsBase

Abstract dynamics base class.

DynamicsBase

DynamicsBase(params: VehicleParams)

Bases: ABC

Abstract dynamics base class.

Initialize dynamics with vehicle parameters.

Methods:

Name Description
update

Advance dynamics by one step and return outputs.

reset

Reset internal state to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

commands ndarray | Tensor

Latest control commands applied to the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

commands instance-attribute
commands: ndarray | Tensor

Latest control commands applied to the dynamics model.

update abstractmethod
update(*args, **kwargs)

Advance dynamics by one step and return outputs.

reset abstractmethod
reset(*args, **kwargs)

Reset internal state to initial conditions.

params

Vehicle parameter definitions for LAV2.

Classes:

Name Description
VehicleParams

LAV2 vehicle parameters.

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: np.diag([0.11, 0.108, 0.215]).tolist())(), diameter: float = 0.476, Cdx: float = 0.5, x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = 8 * (np.pi / 180), r_p: float = 0.0775, J_m: float = 1e-05, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = 14.6 * (np.pi / 180), thetaTip: float = 6.8 * (np.pi / 180), lock: float = 0.6051, max_rpm: float = 10000.0, init_rpm: float = -1.0, rotor_rpm_rate_limit: float = 50000.0, tau_f: float = 0.01, tau_m: float = 0.05, tau_up: float = -1.0, tau_down: float = -1.0, r_w: float = 0.0285, n_w: int = 4, B: float = 0.136, L: float = 0.23, h_cg: float = 0.078, f: float = 0.01, mu0: float = 0.8, K: float = 20, track_cmd_rate_limit: float = 100, min_throttle_manual: float = 0.08, min_throttle: float = 0.12, max_throttle: float = 1.0, hover_throttle: float = -1)

LAV2 vehicle parameters.

Methods:

Name Description
__post_init__

Calculate derived parameters.

Attributes:

Name Type Description
rho float

空气密度 (kg/m^3)

g float

重力加速度 (m/s^2)

sim_dt float

仿真步长 (s)

step_dt float

控制步长 (s)

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

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass float

质量 (kg)

inertia list

惯性矩阵 (kg*m^2)

diameter float

直径 (m)

Cdx float

空气阻力系数

x float

x方向臂长 (m)

y float

y方向臂长 (m)

h float

重心高度 (m)

alpha float

y方向涵道外倾角度 (rad)

r_p float

螺旋桨半径 (m)

J_m float

电机转动惯量 (kg*m^2)

Ct float

推力系数

Cq float

扭矩系数

theta0 float

桨根角 (rad)

thetaTip float

桨尖角 (rad)

theta1 float

桨叶扭转角 (rad)

lock float

Lock number

max_rpm float

最大转速

init_rpm float

初始转速

rotor_rpm_rate_limit float

旋翼转速变化率限制 (rpm/s)

cT float

转速平方到推力增益 (N/(rpm^2))

cM float

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f float

电机滤波时间常数 (s)

tau_m float

兼容保留的电机时间常数 (s)

tau_up float

电机升速时间常数 (s)

tau_down float

电机降速时间常数 (s)

r_w float

主动轮半径 (m)

n_w int

负重轮个数

B float

两侧履带中心距 (m)

L float

履带节点接地部分长度 (m)

h_cg float

车体质心高度 (m)

f float

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 float

滑转率为1时的摩擦系数

K float

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit float

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual float

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle float

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle float

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle float

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

rho class-attribute instance-attribute
rho: float = 1.184

空气密度 (kg/m^3)

g class-attribute instance-attribute
g: float = 9.81

重力加速度 (m/s^2)

sim_dt class-attribute instance-attribute
sim_dt: float = 0.01

仿真步长 (s)

step_dt class-attribute instance-attribute
step_dt: float = 0.01

控制步长 (s)

randomization class-attribute instance-attribute
randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass class-attribute instance-attribute
mass: float = 2.1

质量 (kg)

inertia class-attribute instance-attribute
inertia: list = field(default_factory=lambda: tolist())

惯性矩阵 (kg*m^2)

diameter class-attribute instance-attribute
diameter: float = 0.476

直径 (m)

Cdx class-attribute instance-attribute
Cdx: float = 0.5

空气阻力系数

x class-attribute instance-attribute
x: float = 0.0952

x方向臂长 (m)

y class-attribute instance-attribute
y: float = 0.114423

y方向臂长 (m)

h class-attribute instance-attribute
h: float = -0.0125

重心高度 (m)

alpha class-attribute instance-attribute
alpha: float = 8 * (pi / 180)

y方向涵道外倾角度 (rad)

r_p class-attribute instance-attribute
r_p: float = 0.0775

螺旋桨半径 (m)

J_m class-attribute instance-attribute
J_m: float = 1e-05

电机转动惯量 (kg*m^2)

Ct class-attribute instance-attribute
Ct: float = 0.666

推力系数

Cq class-attribute instance-attribute
Cq: float = 0.0716

扭矩系数

theta0 class-attribute instance-attribute
theta0: float = 14.6 * (pi / 180)

桨根角 (rad)

thetaTip class-attribute instance-attribute
thetaTip: float = 6.8 * (pi / 180)

桨尖角 (rad)

theta1 class-attribute instance-attribute
theta1: float = field(init=False)

桨叶扭转角 (rad)

lock class-attribute instance-attribute
lock: float = 0.6051

Lock number

max_rpm class-attribute instance-attribute
max_rpm: float = 10000.0

最大转速

init_rpm class-attribute instance-attribute
init_rpm: float = -1.0

初始转速

rotor_rpm_rate_limit class-attribute instance-attribute
rotor_rpm_rate_limit: float = 50000.0

旋翼转速变化率限制 (rpm/s)

cT class-attribute instance-attribute
cT: float = field(init=False)

转速平方到推力增益 (N/(rpm^2))

cM class-attribute instance-attribute
cM: float = field(init=False)

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f class-attribute instance-attribute
tau_f: float = 0.01

电机滤波时间常数 (s)

tau_m class-attribute instance-attribute
tau_m: float = 0.05

兼容保留的电机时间常数 (s)

tau_up class-attribute instance-attribute
tau_up: float = -1.0

电机升速时间常数 (s)

tau_down class-attribute instance-attribute
tau_down: float = -1.0

电机降速时间常数 (s)

r_w class-attribute instance-attribute
r_w: float = 0.0285

主动轮半径 (m)

n_w class-attribute instance-attribute
n_w: int = 4

负重轮个数

B class-attribute instance-attribute
B: float = 0.136

两侧履带中心距 (m)

L class-attribute instance-attribute
L: float = 0.23

履带节点接地部分长度 (m)

h_cg class-attribute instance-attribute
h_cg: float = 0.078

车体质心高度 (m)

f class-attribute instance-attribute
f: float = 0.01

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 class-attribute instance-attribute
mu0: float = 0.8

滑转率为1时的摩擦系数

K class-attribute instance-attribute
K: float = 20

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit class-attribute instance-attribute
track_cmd_rate_limit: float = 100

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual class-attribute instance-attribute
min_throttle_manual: float = 0.08

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle class-attribute instance-attribute
min_throttle: float = 0.12

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle class-attribute instance-attribute
max_throttle: float = 1.0

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle class-attribute instance-attribute
hover_throttle: float = -1

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

__post_init__
__post_init__()

Calculate derived parameters.

rotor

Rotor dynamics model for thrust and torque outputs.

Classes:

Name Description
RotorDynamics

Motor dynamics model for rotor thrust and torque.

RotorDynamics

RotorDynamics(params: VehicleParams = VehicleParams())

Bases: DynamicsBase

Motor dynamics model for rotor thrust and torque.

References
  • Aerial Gym: https://github.com/ntnu-arl/aerial_gym_simulator/blob/main/aerial_gym/control/motor_model.py
  • MARL_cooperative_aerial_manipulation_ext: https://github.com/Aerial-Manipulation-Lab/MARL_cooperative_aerial_manipulation_ext/blob/main/exts/MARL_mav_carry_ext/MARL_mav_carry_ext/controllers/motor_model.py
  • isaac_drone_racer: https://github.com/kousheekc/isaac_drone_racer/blob/master/dynamics/motor.py

Initialize rotor dynamics and rate-limit parameters.

Methods:

Name Description
update

Calculate the output thrust and torque for each motor based on the motor commands.

reset

Reset the rotor model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

update
update(commands: ndarray) -> np.ndarray

Calculate the output thrust and torque for each motor based on the motor commands.

Parameters:

Name Type Description Default
commands
ndarray

Command array for each motor. Shape: (4,)

required

Returns:

Type Description
ndarray

np.ndarray: Thrust and torque array for each motor. Shape: (8,)

reset
reset()

Reset the rotor model to initial conditions.

torch

Torch-based dynamics models for LAV2.

Modules:

Name Description
rotor

Torch rotor dynamics for batched simulation.

track

Torch track dynamics for batched simulation.

rotor

Torch rotor dynamics for batched simulation.

Classes:

Name Description
RotorDynamics

Batched rotor dynamics model.

RotorDynamics
RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched rotor dynamics model.

Initialize batched rotor dynamics on the specified device.

Methods:

Name Description
randomize

Randomize rotor runtime parameters from nominal values.

update

Calculate the output thrust and torque for each motor based on the motor commands.

reset

Resets the rotor model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

randomize
randomize(env_ids: slice | Sequence[int] | Tensor | None = None, randomization: dict[str, tuple[float, float]] | None = None) -> None

Randomize rotor runtime parameters from nominal values.

update
update(commands: Tensor) -> torch.Tensor

Calculate the output thrust and torque for each motor based on the motor commands.

Parameters:

Name Type Description Default
commands Tensor

Command tensor for each motor. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: Thrust and torque tensor for each motor. Shape: (num_envs, 8)

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the rotor model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required

track

Torch track dynamics for batched simulation.

Classes:

Name Description
TrackDynamics

Batched track dynamics model.

TrackDynamics
TrackDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched track dynamics model.

Initialize batched track dynamics on the specified device.

Methods:

Name Description
update

Compute track forces for batched environments.

reset

Resets the track model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

update
update(commands: Tensor, state: Tensor) -> torch.Tensor

Compute track forces for batched environments.

Parameters:

Name Type Description Default
commands Tensor

Shape (num_envs, 2) track commands [left, right].

required
state Tensor

Shape (num_envs, 3) body-frame velocities [u, v, r].

required

Returns:

Type Description
Tensor

torch.Tensor: Tensor of shape (num_envs, 2, n_w, 2) [side, wheel, (Fx, Fy)].

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the track model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required

track

Track dynamics model for ground locomotion.

Classes:

Name Description
TrackDynamics

Track dynamics model for left/right traction forces.

TrackDynamics

TrackDynamics(params: VehicleParams = VehicleParams())

Bases: DynamicsBase

Track dynamics model for left/right traction forces.

Initialize track dynamics geometry and normal load distribution.

Methods:

Name Description
update

Calculate the output force of the tracks based on track commands.

reset

Reset the track model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

update
update(commands: ndarray, state: ndarray) -> np.ndarray

Calculate the output force of the tracks based on track commands.

Parameters:

Name Type Description Default
commands
ndarray

Command array for each track. Shape: (2,)

required
state
ndarray

Current vehicle state array. Shape: (3,)

required

Returns:

Type Description
ndarray

np.ndarray: Force array for each track. Shape: (2, n_w, 2) [side, wheel, (Fx, Fy)]

reset
reset()

Reset the track model to initial conditions.

gamepads

Gamepad input helpers for LAV2.

Modules:

Name Description
common

Shared data structures for gamepad inputs.

sdl2

SDL2 gamepad backend for LAV2.

Classes:

Name Description
Key

Gamepad input abstraction shared across backends.

ControllerEventLoop

Minimal SDL2 controller event loop for LAV2.

Functions:

Name Description
controller_key_from_event

Convert an SDL2 event to a Key.

Key dataclass

Key(keytype: str, index: int, name: str | None = None, value: float | None = None)

Gamepad input abstraction shared across backends.

ControllerEventLoop

ControllerEventLoop(handle_key: Callable[[Key], None], alive: Event | None = None, timeout: int = 2000)

Minimal SDL2 controller event loop for LAV2.

Initialize the controller event loop.

Parameters:

Name Type Description Default

handle_key

Callable[[Key], None]

Callback for parsed keys.

required

alive

Event | None

Control event loop lifetime.

None

timeout

int

SDL wait timeout in milliseconds.

2000

Methods:

Name Description
stop

Stop the event loop.

run

Run the SDL2 event loop until stopped.

stop

stop() -> None

Stop the event loop.

run

run() -> None

Run the SDL2 event loop until stopped.

controller_key_from_event

controller_key_from_event(event: SDL_Event, deadzone: float = 0.05) -> Key | None

Convert an SDL2 event to a Key.

Parameters:

Name Type Description Default

event

SDL_Event

Raw SDL2 event.

required

deadzone

float

Deadzone for analog axes.

0.05

Returns:

Type Description
Key | None

Key | None: Parsed key input, if any.

common

Shared data structures for gamepad inputs.

Classes:

Name Description
Key

Gamepad input abstraction shared across backends.

Key dataclass

Key(keytype: str, index: int, name: str | None = None, value: float | None = None)

Gamepad input abstraction shared across backends.

sdl2

SDL2 gamepad backend for LAV2.

Classes:

Name Description
ControllerEventLoop

Minimal SDL2 controller event loop for LAV2.

Functions:

Name Description
controller_key_from_event

Convert an SDL2 event to a Key.

ControllerEventLoop

ControllerEventLoop(handle_key: Callable[[Key], None], alive: Event | None = None, timeout: int = 2000)

Minimal SDL2 controller event loop for LAV2.

Initialize the controller event loop.

Parameters:

Name Type Description Default
handle_key
Callable[[Key], None]

Callback for parsed keys.

required
alive
Event | None

Control event loop lifetime.

None
timeout
int

SDL wait timeout in milliseconds.

2000

Methods:

Name Description
stop

Stop the event loop.

run

Run the SDL2 event loop until stopped.

stop
stop() -> None

Stop the event loop.

run
run() -> None

Run the SDL2 event loop until stopped.

controller_key_from_event

controller_key_from_event(event: SDL_Event, deadzone: float = 0.05) -> Key | None

Convert an SDL2 event to a Key.

Parameters:

Name Type Description Default
event
SDL_Event

Raw SDL2 event.

required
deadzone
float

Deadzone for analog axes.

0.05

Returns:

Type Description
Key | None

Key | None: Parsed key input, if any.

runner

Runner utilities for LAV2 training and evaluation.

Modules:

Name Description
common

Shared utilities for common runner helpers and play scripts.

skrl

SKRL runner helpers for LAV2.

common

Shared utilities for common runner helpers and play scripts.

Modules:

Name Description
mujoco

Modular play utilities for LAV2 policy deployment.

mujoco

Modular play utilities for LAV2 policy deployment.

This module provides reusable components for playing trained policies in MuJoCo environments with keyboard and gamepad control, supporting various action and command modes.

Design follows lav2.controller.run pattern.

Classes:

Name Description
MuJoCoPlayConfig

Configuration for MuJoCo policy play session.

MuJoCoPlayRunner

Modular runner for MuJoCo policy play sessions with keyboard/gamepad control.

MuJoCoPlayConfig dataclass
MuJoCoPlayConfig(checkpoint_path: str, params: VehicleParams = VehicleParams(), decimation: int = 2, action_mode: str = 'cmd_motor_speeds', command_mode: str = 'tgt_pos', initial_target: ndarray = (lambda: np.array([1.0, 1.0, 1.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]))(), mjcf_path: str = str(files('lav2.assets').joinpath('mjcf/scene.xml')), enable_gamepad: bool = False, trajectory: BaseTrajectory | None = None, pos_inc: tuple[float, float, float] = (1.0, 1.0, 0.5), vel_limits: tuple[float, float, float] = (5.0, 5.0, 5.0), att_limits: tuple[float, float, float] = (1.0, 1.0, np.pi), br_limits: tuple[float, float, float] = (2.0, 2.0, 2.0))

Configuration for MuJoCo policy play session.

Attributes:

Name Type Description
checkpoint_path str

Path to the policy checkpoint (JIT or ONNX).

params VehicleParams

Vehicle parameters (auto-created if None).

decimation int

Control decimation factor.

action_mode str

Action mode - 'cmd_pos', 'cmd_vel', 'cmd_ctatt', 'cmd_ctbr', 'cmd_ctbm', 'cmd_motor_speeds'.

command_mode str

Command mode - 'tgt_pos', 'tgt_vel', 'tgt_ctatt', 'tgt_ctbr'.

initial_target ndarray

Initial target [x,y,z,vx,vy,vz,roll,pitch,yaw,wx,wy,wz].

mjcf_path str

Path to MuJoCo XML scene file.

enable_gamepad bool

Enable gamepad input.

pos_inc tuple[float, float, float]

Positional increment for keyboard control (dx, dy, dz).

vel_limits tuple[float, float, float]

Velocity limits [vx, vy, vz].

att_limits tuple[float, float, float]

Attitude limits [roll, pitch, yaw].

br_limits tuple[float, float, float]

Body rate limits [wx, wy, wz].

Methods:

Name Description
__post_init__

Validate configuration values after initialization.

__post_init__
__post_init__()

Validate configuration values after initialization.

Raises:

Type Description
ValueError

If action_mode or command_mode is not a valid option.

MuJoCoPlayRunner
MuJoCoPlayRunner(cfg: MuJoCoPlayConfig, policy_runner: JITPolicyRunner | ONNXPolicyRunner, obs_extractor: Callable[[MjData, ndarray, ndarray], ndarray] | None = None)

Modular runner for MuJoCo policy play sessions with keyboard/gamepad control.

Provides reusable observation extraction, control loop, and input handling for LAV2 flight control in MuJoCo. Supports multiple action modes following the lav2.controller.run design pattern.

Initialize the play runner.

Parameters:

Name Type Description Default
cfg
MuJoCoPlayConfig

Play cfguration.

required
policy_runner
JITPolicyRunner | ONNXPolicyRunner

Policy runner (JIT or ONNX).

required
obs_extractor
Callable[[MjData, ndarray, ndarray], ndarray] | None

Custom observation extraction function. If None, uses default flight observation extractor. Signature: (d: MjData, target: ndarray, last_action: ndarray) -> obs

None

Methods:

Name Description
key_callback

Handle keyboard input to update target position (tgt_pos mode only).

gamepad_callback

Handle gamepad input following lav2.controller.run pattern.

process_actions

Process policy action and compute RPM commands (control loop).

apply_actions

Apply rotor dynamics and update MuJoCo actuators (simulation loop).

control_callback

Control loop callback for MuJoCo viewer (respects decimation).

load_callback

Load MuJoCo model and data.

run

Launch the MuJoCo viewer and start the play session.

key_callback
key_callback(keycode: int)

Handle keyboard input to update target position (tgt_pos mode only).

Keys 1-8 adjust target position and heading. Note: Currently only supports tgt_pos command mode.

gamepad_callback
gamepad_callback(key: Key) -> None

Handle gamepad input following lav2.controller.run pattern.

Parameters:

Name Type Description Default
key Key

Gamepad key event (axis or button).

required
process_actions
process_actions(m: MjModel, d: MjData)

Process policy action and compute RPM commands (control loop).

This method is called at the decimated control rate.

Parameters:

Name Type Description Default
m MjModel

MuJoCo model.

required
d MjData

MuJoCo data.

required
apply_actions
apply_actions(m: MjModel, d: MjData)

Apply rotor dynamics and update MuJoCo actuators (simulation loop).

This runs at every simulation step, not subject to decimation.

Parameters:

Name Type Description Default
m MjModel

MuJoCo model.

required
d MjData

MuJoCo data.

required
control_callback
control_callback(m: MjModel, d: MjData)

Control loop callback for MuJoCo viewer (respects decimation).

Executes policy inference and command processing, but applies rotor dynamics separately to respect simulation decimation.

Parameters:

Name Type Description Default
m MjModel

MuJoCo model.

required
d MjData

MuJoCo data.

required
load_callback
load_callback() -> tuple[mujoco.MjModel, mujoco.MjData]

Load MuJoCo model and data.

Returns:

Type Description
tuple[MjModel, MjData]

tuple[mujoco.MjModel, mujoco.MjData]: Tuple of (model, data).

run
run()

Launch the MuJoCo viewer and start the play session.

skrl

SKRL runner helpers for LAV2.

Modules:

Name Description
__main__

CLI entry point for SKRL configuration runners.

cfg

SKRL configuration modules for LAV2.

eval

Evaluation helpers for SKRL policies.

isaaclab

SKRL runner for Isaac Lab tasks.

__main__

CLI entry point for SKRL configuration runners.

Functions:

Name Description
get_available_configs

Return available configuration module names.

main

Run a selected SKRL configuration script.

get_available_configs
get_available_configs()

Return available configuration module names.

main
main()

Run a selected SKRL configuration script.

cfg

SKRL configuration modules for LAV2.

Modules:

Name Description
LAV2_base

SKRL configuration for the LAV2 base task.

LAV2_base_moe

SKRL configuration for the LAV2 base MoE task.

LAV2_base_vel

SKRL configuration for the LAV2 base velocity task.

LAV2_navrl

SKRL configuration for the LAV2 NavRL task.

LAV2_base

SKRL configuration for the LAV2 base task.

Classes:

Name Description
Shared

Shared actor-critic model for PPO.

Functions:

Name Description
get_agent_cfg

Return the PPO agent configuration.

get_model_class

Return the model class for the agent.

get_agent_class

Return the agent class.

get_memory_class

Return the memory class.

get_memory_cfg

Return the memory configuration.

get_trainer_class

Return the trainer class.

get_trainer_cfg

Return the trainer configuration.

Shared
Shared(observation_space, state_space, action_space, device, clip_actions=False, clip_log_std=True, min_log_std=-20, max_log_std=2, reduction='sum')

Bases: GaussianMixin, DeterministicMixin, Model

Shared actor-critic model for PPO.

Initialize shared model layers and mixins.

Methods:

Name Description
act

Compute actions or values depending on role.

compute

Compute policy/value outputs depending on role.

act
act(inputs: Any, role: str) -> Any

Compute actions or values depending on role.

Returns:

Type Description
Any

tuple | None: Action outputs for the given role, or None if role is unknown.

compute
compute(inputs: Any, role: str) -> Any

Compute policy/value outputs depending on role.

Returns:

Type Description
Any

tuple | None: (output_tensor, extras_dict) for policy/value roles, or None.

get_agent_cfg
get_agent_cfg() -> Any

Return the PPO agent configuration.

get_model_class
get_model_class() -> Any

Return the model class for the agent.

get_agent_class
get_agent_class() -> Any

Return the agent class.

get_memory_class
get_memory_class() -> Any

Return the memory class.

get_memory_cfg
get_memory_cfg() -> Any

Return the memory configuration.

get_trainer_class
get_trainer_class() -> Any

Return the trainer class.

get_trainer_cfg
get_trainer_cfg() -> Any

Return the trainer configuration.

LAV2_base_moe

SKRL configuration for the LAV2 base MoE task.

Classes:

Name Description
PPO_MoE

PPO variant with MoE bias updates.

MoELayer

Mixture-of-experts layer with top-k routing.

Shared

Shared actor-critic model with MoE trunk.

Functions:

Name Description
get_agent_cfg

Return the PPO agent configuration.

get_model_class

Return the model class for the agent.

get_agent_class

Return the agent class.

get_memory_class

Return the memory class.

get_memory_cfg

Return the memory configuration.

get_trainer_class

Return the trainer class.

get_trainer_cfg

Return the trainer configuration.

PPO_MoE

Bases: PPO

PPO variant with MoE bias updates.

Methods:

Name Description
update

Run PPO update and then update MoE biases.

update
update(*args: Any, **kwargs: Any) -> None

Run PPO update and then update MoE biases.

MoELayer
MoELayer(input_size, output_size, num_experts, k)

Bases: Module

Mixture-of-experts layer with top-k routing.

Initialize experts, gate network, and load-balancing bias.

Methods:

Name Description
forward

Compute routed expert outputs.

forward
forward(x: Tensor) -> torch.Tensor

Compute routed expert outputs.

Returns:

Type Description
Tensor

torch.Tensor: Weighted combination of top-k expert outputs.

Shared
Shared(observation_space, state_space, action_space, device, clip_actions=False, clip_log_std=True, min_log_std=-20, max_log_std=2, reduction='sum')

Bases: GaussianMixin, DeterministicMixin, Model

Shared actor-critic model with MoE trunk.

Initialize the shared MoE actor-critic model.

Methods:

Name Description
act

Compute actions or values depending on role.

compute

Compute policy/value outputs depending on role.

act
act(inputs: Any, role: str) -> Any

Compute actions or values depending on role.

Returns:

Type Description
Any

tuple | None: Action outputs for the given role, or None if role is unknown.

compute
compute(inputs: Any, role: str) -> Any

Compute policy/value outputs depending on role.

Returns:

Type Description
Any

tuple | None: (output_tensor, extras_dict) for policy/value roles, or None.

get_agent_cfg
get_agent_cfg() -> Any

Return the PPO agent configuration.

get_model_class
get_model_class() -> Any

Return the model class for the agent.

get_agent_class
get_agent_class() -> Any

Return the agent class.

get_memory_class
get_memory_class() -> Any

Return the memory class.

get_memory_cfg
get_memory_cfg() -> Any

Return the memory configuration.

get_trainer_class
get_trainer_class() -> Any

Return the trainer class.

get_trainer_cfg
get_trainer_cfg() -> Any

Return the trainer configuration.

LAV2_base_vel

SKRL configuration for the LAV2 base velocity task.

Classes:

Name Description
Shared

Shared actor-critic model for PPO.

Functions:

Name Description
get_agent_cfg

Return the PPO agent configuration.

get_model_class

Return the model class for the agent.

get_agent_class

Return the agent class.

get_memory_class

Return the memory class.

get_memory_cfg

Return the memory configuration.

get_trainer_class

Return the trainer class.

get_trainer_cfg

Return the trainer configuration.

Shared
Shared(observation_space, state_space, action_space, device, clip_actions=False, clip_log_std=True, min_log_std=-20, max_log_std=2, reduction='sum')

Bases: GaussianMixin, DeterministicMixin, Model

Shared actor-critic model for PPO.

Initialize shared model layers and mixins.

Methods:

Name Description
act

Compute actions or values depending on role.

compute

Compute policy/value outputs depending on role.

act
act(inputs: Any, role: str) -> Any

Compute actions or values depending on role.

Returns:

Type Description
Any

tuple | None: Action outputs for the given role, or None if role is unknown.

compute
compute(inputs: Any, role: str) -> Any

Compute policy/value outputs depending on role.

Returns:

Type Description
Any

tuple | None: (output_tensor, extras_dict) for policy/value roles, or None.

get_agent_cfg
get_agent_cfg() -> Any

Return the PPO agent configuration.

get_model_class
get_model_class() -> Any

Return the model class for the agent.

get_agent_class
get_agent_class() -> Any

Return the agent class.

get_memory_class
get_memory_class() -> Any

Return the memory class.

get_memory_cfg
get_memory_cfg() -> Any

Return the memory configuration.

get_trainer_class
get_trainer_class() -> Any

Return the trainer class.

get_trainer_cfg
get_trainer_cfg() -> Any

Return the trainer configuration.

LAV2_navrl

SKRL configuration for the LAV2 NavRL task.

Classes:

Name Description
Shared

Shared actor-critic model with sensor fusion.

Functions:

Name Description
get_agent_cfg

Return the PPO agent configuration.

get_model_class

Return the model class for the agent.

get_agent_class

Return the agent class.

get_memory_class

Return the memory class.

get_memory_cfg

Return the memory configuration.

get_trainer_class

Return the trainer class.

get_trainer_cfg

Return the trainer configuration.

Shared
Shared(observation_space, state_space, action_space, device, clip_actions=False, clip_log_std=True, min_log_std=-20, max_log_std=2, reduction='sum')

Bases: GaussianMixin, DeterministicMixin, Model

Shared actor-critic model with sensor fusion.

Initialize encoders and policy/value heads.

Methods:

Name Description
act

Compute actions or values depending on role.

compute

Compute policy/value outputs depending on role.

act
act(inputs: Any, role: str) -> Any

Compute actions or values depending on role.

Returns:

Type Description
Any

tuple | None: Action outputs for the given role, or None if role is unknown.

compute
compute(inputs: Any, role: str) -> Any

Compute policy/value outputs depending on role.

Returns:

Type Description
Any

tuple | None: (output_tensor, extras_dict) for policy/value roles, or None.

get_agent_cfg
get_agent_cfg() -> Any

Return the PPO agent configuration.

get_model_class
get_model_class() -> Any

Return the model class for the agent.

get_agent_class
get_agent_class() -> Any

Return the agent class.

get_memory_class
get_memory_class() -> Any

Return the memory class.

get_memory_cfg
get_memory_cfg() -> Any

Return the memory configuration.

get_trainer_class
get_trainer_class() -> Any

Return the trainer class.

get_trainer_cfg
get_trainer_cfg() -> Any

Return the trainer configuration.

eval

Evaluation helpers for SKRL policies.

Classes:

Name Description
JITPolicyRunner

TorchScript policy runner.

ONNXPolicyRunner

ONNX policy runner.

Functions:

Name Description
load_agent

Load a trained agent for evaluation/inference.

load_policy

Load a policy as a unified runner supporting JIT or ONNX.

JITPolicyRunner
JITPolicyRunner(model_path: str, device: str | device)

Bases: _BasePolicyRunner

TorchScript policy runner.

Initialize a TorchScript policy runner.

Parameters:

Name Type Description Default
model_path
str

Path to the JIT model.

required
device
str | device

Target device.

required

Methods:

Name Description
act

Compute actions from observations.

act
act(observations: ndarray | Tensor) -> np.ndarray

Compute actions from observations.

Returns:

Type Description
ndarray

np.ndarray: Action array with shape matching the model output.

ONNXPolicyRunner
ONNXPolicyRunner(model_path: str, providers: list | None = None)

Bases: _BasePolicyRunner

ONNX policy runner.

Initialize an ONNX policy runner.

Parameters:

Name Type Description Default
model_path
str

Path to the ONNX model.

required
providers
list | None

Optional ONNX providers list.

None

Raises:

Type Description
RuntimeError

If the ONNX model has no inputs.

Methods:

Name Description
act

Compute actions from observations.

act
act(observations: ndarray | Tensor) -> np.ndarray

Compute actions from observations.

Returns:

Type Description
ndarray

np.ndarray: Action array with shape matching the model output.

load_agent
load_agent(model_cls: type, agent_cfg: Any, checkpoint_path: str, observation_shape: tuple, action_shape: tuple, state_shape: tuple | None = None, device: str | device | None = None) -> tuple

Load a trained agent for evaluation/inference.

Parameters:

Name Type Description Default
model_cls
type

Class of the model (policy).

required
agent_cfg
Any

Agent configuration object.

required
checkpoint_path
str

Path to the checkpoint file.

required
observation_shape
tuple

Tuple defining observation dimensions.

required
action_shape
tuple

Tuple defining action dimensions.

required
state_shape
tuple | None

Tuple defining state dimensions.

None
device
str | device | None

Torch device (auto-detected if None).

None

Returns:

Name Type Description
tuple tuple

(policy, observation_preprocessor, device).

Raises:

Type Description
FileNotFoundError

If the checkpoint file is not found.

ImportError

If gymnasium is not installed.

load_policy
load_policy(model_path: str, device: str | device = 'cpu') -> JITPolicyRunner | ONNXPolicyRunner

Load a policy as a unified runner supporting JIT or ONNX.

The returned object exposes act(observations) and returns numpy actions. Observations may be numpy arrays or torch tensors. A 1-D observation is treated as a single batch and the returned actions are 1-D accordingly.

Returns:

Type Description
JITPolicyRunner | ONNXPolicyRunner

JITPolicyRunner | ONNXPolicyRunner: Loaded policy runner.

Raises:

Type Description
ValueError

If model_path is None.

isaaclab

SKRL runner for Isaac Lab tasks.

Functions:

Name Description
parse_args

Build the CLI argument parser.

run

Run training or evaluation for an Isaac Lab task.

parse_args
parse_args() -> argparse.ArgumentParser

Build the CLI argument parser.

Returns:

Type Description
ArgumentParser

argparse.ArgumentParser: Configured argument parser.

run
run(task_name: str, model_cls: type, agent_cls: type, agent_cfg: Any, memory_cls: type, memory_cfg: dict, trainer_cls: type, trainer_cfg: dict, export_jit: bool = False, export_onnx: bool = False)

Run training or evaluation for an Isaac Lab task.

Parameters:

Name Type Description Default
task_name
str

Isaac Lab task name.

required
model_cls
type

Policy model class.

required
agent_cls
type

Agent class.

required
agent_cfg
Any

Agent configuration object.

required
memory_cls
type

Memory class.

required
memory_cfg
dict

Memory configuration.

required
trainer_cls
type

Trainer class.

required
trainer_cfg
dict

Trainer configuration.

required
export_jit
bool

Whether to export JIT policy.

False
export_onnx
bool

Whether to export ONNX policy.

False

tasks

Task packages for supported training frameworks for LAV2.

Modules:

Name Description
genesis_forge
isaaclab
mjlab

genesis_forge

Modules:

Name Description
LAV2_base
LAV2_base_velocity

LAV2_base

Modules:

Name Description
environment

LAV2 Base Environment using managers to handle everything.

eval
mdp
environment

LAV2 Base Environment using managers to handle everything.

Classes:

Name Description
LAV2BaseEnv

Example training environment for the LAV2 robot.

LAV2BaseEnv
LAV2BaseEnv(num_envs: int = 1, dt: float = 1 / 100, max_episode_length_s: int | None = 10, headless: bool = True)

Bases: ManagedEnvironment

Example training environment for the LAV2 robot.

Methods:

Name Description
config

Configure the environment managers

config
config()

Configure the environment managers

eval

Functions:

Name Description
get_latest_model

Get the last model from the log directory

get_latest_model
get_latest_model(log_dir: str) -> str

Get the last model from the log directory

mdp

Modules:

Name Description
actions
commands
rewards

Classes:

Name Description
FlightActionMapper

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

FlightMappingLimits

Per-channel limits used when mapping normalized actions to targets.

Mixer

Map thrust and moment demands to rotor commands.

FlightController

PID flight controller (batched).

VehicleParams

LAV2 vehicle parameters.

RotorDynamics

Batched rotor dynamics model.

ControlActionManager

Base class for action managers that control actuators.

PositionDebugVisualizerConfig

Defines the configuration for the debug visualizer.

PositionCommandManager

Generates a position command from uniform distribution.

Functions:

Name Description
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.

FlightActionMapper
FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), limits: FlightMappingLimits = FlightMappingLimits(), *, num_envs: int = 1, device: str | device = 'cpu')

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

Initialize a batched Torch flight action mapper for the selected mode.

Methods:

Name Description
map_action

Map a normalized batched action into RPM commands and intermediates.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller target expansion step.

requires_controller property
requires_controller: bool

Whether this mode needs a controller target expansion step.

map_action
map_action(action: Tensor, mixer: Mixer, *, state: Tensor | None = None, flight_controller: ControllerBase | None = None) -> FlightMappingResult

Map a normalized batched action into RPM commands and intermediates.

FlightMappingLimits dataclass
FlightMappingLimits(vel_limits: tuple[float, float, float] = (5.0, 5.0, 5.0), att_limits: tuple[float, float, float] = (1.0, 1.0, math.pi), br_limits: tuple[float, float, float] = (2.0, 2.0, 2.0))

Per-channel limits used when mapping normalized actions to targets.

Mixer
Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the torch mixer with vehicle parameters and device.

Methods:

Name Description
randomize

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

randomize
randomize(env_ids=None, randomization=None)

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve
apply_thrust_curve(normalized_thrust: Tensor, mode: int = 1) -> torch.Tensor

Apply thrust curve to normalized thrust command.

References

cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137 cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

Parameters:

Name Type Description Default
normalized_thrust Tensor

Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise.

required
mode int

Thrust curve mode.

1

Returns:

Type Description
Tensor

torch.Tensor: Thrust in Newtons with the same shape as normalized_thrust.

Raises:

Type Description
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands
calculate_rotor_commands(control: Tensor) -> torch.Tensor

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default
control Tensor

Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). Shape: (num_envs, 4)

FlightController
FlightController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0], gains: dict | None = None, limits: dict | None = None, num_envs: int = 1, device: str | device = 'cpu')

Bases: ControllerBase

PID flight controller (batched).

Initialize the batched flight PID controller.

Methods:

Name Description
randomize

Randomize configured PID gains and command limits for selected environments.

reset

Reset PID loops for selected environments.

update

Update controller.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

randomize
randomize(env_ids=None, gains=None, limits=None)

Randomize configured PID gains and command limits for selected environments.

reset
reset(env_ids)

Reset PID loops for selected environments.

update
update(target: Tensor, state: Tensor) -> torch.Tensor

Update controller.

Parameters:

Name Type Description Default
target Tensor

(N, 12) desired [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz]

required
state Tensor

(N, 12) current state same ordering.

required

Returns:

Type Description
Tensor

torch.Tensor: Tensor of shape (N, 4): [thrust, roll_moment, pitch_moment, yaw_moment].

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: np.diag([0.11, 0.108, 0.215]).tolist())(), diameter: float = 0.476, Cdx: float = 0.5, x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = 8 * (np.pi / 180), r_p: float = 0.0775, J_m: float = 1e-05, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = 14.6 * (np.pi / 180), thetaTip: float = 6.8 * (np.pi / 180), lock: float = 0.6051, max_rpm: float = 10000.0, init_rpm: float = -1.0, rotor_rpm_rate_limit: float = 50000.0, tau_f: float = 0.01, tau_m: float = 0.05, tau_up: float = -1.0, tau_down: float = -1.0, r_w: float = 0.0285, n_w: int = 4, B: float = 0.136, L: float = 0.23, h_cg: float = 0.078, f: float = 0.01, mu0: float = 0.8, K: float = 20, track_cmd_rate_limit: float = 100, min_throttle_manual: float = 0.08, min_throttle: float = 0.12, max_throttle: float = 1.0, hover_throttle: float = -1)

LAV2 vehicle parameters.

Methods:

Name Description
__post_init__

Calculate derived parameters.

Attributes:

Name Type Description
rho float

空气密度 (kg/m^3)

g float

重力加速度 (m/s^2)

sim_dt float

仿真步长 (s)

step_dt float

控制步长 (s)

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

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass float

质量 (kg)

inertia list

惯性矩阵 (kg*m^2)

diameter float

直径 (m)

Cdx float

空气阻力系数

x float

x方向臂长 (m)

y float

y方向臂长 (m)

h float

重心高度 (m)

alpha float

y方向涵道外倾角度 (rad)

r_p float

螺旋桨半径 (m)

J_m float

电机转动惯量 (kg*m^2)

Ct float

推力系数

Cq float

扭矩系数

theta0 float

桨根角 (rad)

thetaTip float

桨尖角 (rad)

theta1 float

桨叶扭转角 (rad)

lock float

Lock number

max_rpm float

最大转速

init_rpm float

初始转速

rotor_rpm_rate_limit float

旋翼转速变化率限制 (rpm/s)

cT float

转速平方到推力增益 (N/(rpm^2))

cM float

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f float

电机滤波时间常数 (s)

tau_m float

兼容保留的电机时间常数 (s)

tau_up float

电机升速时间常数 (s)

tau_down float

电机降速时间常数 (s)

r_w float

主动轮半径 (m)

n_w int

负重轮个数

B float

两侧履带中心距 (m)

L float

履带节点接地部分长度 (m)

h_cg float

车体质心高度 (m)

f float

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 float

滑转率为1时的摩擦系数

K float

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit float

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual float

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle float

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle float

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle float

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

rho class-attribute instance-attribute
rho: float = 1.184

空气密度 (kg/m^3)

g class-attribute instance-attribute
g: float = 9.81

重力加速度 (m/s^2)

sim_dt class-attribute instance-attribute
sim_dt: float = 0.01

仿真步长 (s)

step_dt class-attribute instance-attribute
step_dt: float = 0.01

控制步长 (s)

randomization class-attribute instance-attribute
randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass class-attribute instance-attribute
mass: float = 2.1

质量 (kg)

inertia class-attribute instance-attribute
inertia: list = field(default_factory=lambda: tolist())

惯性矩阵 (kg*m^2)

diameter class-attribute instance-attribute
diameter: float = 0.476

直径 (m)

Cdx class-attribute instance-attribute
Cdx: float = 0.5

空气阻力系数

x class-attribute instance-attribute
x: float = 0.0952

x方向臂长 (m)

y class-attribute instance-attribute
y: float = 0.114423

y方向臂长 (m)

h class-attribute instance-attribute
h: float = -0.0125

重心高度 (m)

alpha class-attribute instance-attribute
alpha: float = 8 * (pi / 180)

y方向涵道外倾角度 (rad)

r_p class-attribute instance-attribute
r_p: float = 0.0775

螺旋桨半径 (m)

J_m class-attribute instance-attribute
J_m: float = 1e-05

电机转动惯量 (kg*m^2)

Ct class-attribute instance-attribute
Ct: float = 0.666

推力系数

Cq class-attribute instance-attribute
Cq: float = 0.0716

扭矩系数

theta0 class-attribute instance-attribute
theta0: float = 14.6 * (pi / 180)

桨根角 (rad)

thetaTip class-attribute instance-attribute
thetaTip: float = 6.8 * (pi / 180)

桨尖角 (rad)

theta1 class-attribute instance-attribute
theta1: float = field(init=False)

桨叶扭转角 (rad)

lock class-attribute instance-attribute
lock: float = 0.6051

Lock number

max_rpm class-attribute instance-attribute
max_rpm: float = 10000.0

最大转速

init_rpm class-attribute instance-attribute
init_rpm: float = -1.0

初始转速

rotor_rpm_rate_limit class-attribute instance-attribute
rotor_rpm_rate_limit: float = 50000.0

旋翼转速变化率限制 (rpm/s)

cT class-attribute instance-attribute
cT: float = field(init=False)

转速平方到推力增益 (N/(rpm^2))

cM class-attribute instance-attribute
cM: float = field(init=False)

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f class-attribute instance-attribute
tau_f: float = 0.01

电机滤波时间常数 (s)

tau_m class-attribute instance-attribute
tau_m: float = 0.05

兼容保留的电机时间常数 (s)

tau_up class-attribute instance-attribute
tau_up: float = -1.0

电机升速时间常数 (s)

tau_down class-attribute instance-attribute
tau_down: float = -1.0

电机降速时间常数 (s)

r_w class-attribute instance-attribute
r_w: float = 0.0285

主动轮半径 (m)

n_w class-attribute instance-attribute
n_w: int = 4

负重轮个数

B class-attribute instance-attribute
B: float = 0.136

两侧履带中心距 (m)

L class-attribute instance-attribute
L: float = 0.23

履带节点接地部分长度 (m)

h_cg class-attribute instance-attribute
h_cg: float = 0.078

车体质心高度 (m)

f class-attribute instance-attribute
f: float = 0.01

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 class-attribute instance-attribute
mu0: float = 0.8

滑转率为1时的摩擦系数

K class-attribute instance-attribute
K: float = 20

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit class-attribute instance-attribute
track_cmd_rate_limit: float = 100

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual class-attribute instance-attribute
min_throttle_manual: float = 0.08

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle class-attribute instance-attribute
min_throttle: float = 0.12

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle class-attribute instance-attribute
max_throttle: float = 1.0

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle class-attribute instance-attribute
hover_throttle: float = -1

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

__post_init__
__post_init__()

Calculate derived parameters.

RotorDynamics
RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched rotor dynamics model.

Initialize batched rotor dynamics on the specified device.

Methods:

Name Description
randomize

Randomize rotor runtime parameters from nominal values.

update

Calculate the output thrust and torque for each motor based on the motor commands.

reset

Resets the rotor model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

randomize
randomize(env_ids: slice | Sequence[int] | Tensor | None = None, randomization: dict[str, tuple[float, float]] | None = None) -> None

Randomize rotor runtime parameters from nominal values.

update
update(commands: Tensor) -> torch.Tensor

Calculate the output thrust and torque for each motor based on the motor commands.

Parameters:

Name Type Description Default
commands Tensor

Command tensor for each motor. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: Thrust and torque tensor for each motor. Shape: (num_envs, 8)

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the rotor model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required
ControlActionManager
ControlActionManager(env: GenesisEnv, delay_step: int = 0, params: VehicleParams = VehicleParams(), gains: dict | None = None, limits: dict | None = None, entity_attr: str = 'robot', control_mode: str = 'cmd_motor_speeds')

Bases: BaseActionManager

Base class for action managers that control actuators.

Parameters:

Name Type Description Default
env GenesisEnv

The environment to manage the DOF actuators for.

required
delay_step int

The number of steps to delay the actions for. This is an easy way to emulate the latency in the system.

0
params VehicleParams

Vehicle physical parameters.

VehicleParams()
entity_attr str

Attribute name on the environment for the robot entity.

'robot'
control_mode str

Control mode string (e.g. 'cmd_motor_speeds').

'cmd_motor_speeds'

Methods:

Name Description
step

Handle the received actions.

reset

Reset environments.

get_actions

Get the current actions for the environments.

Attributes:

Name Type Description
num_actions int

The total number of actions.

action_space tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions Tensor

The actions for for the current step.

raw_actions Tensor

The actions received from the policy, before being converted.

num_actions property
num_actions: int

The total number of actions.

action_space property
action_space: tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions property
actions: Tensor

The actions for for the current step.

raw_actions property
raw_actions: Tensor

The actions received from the policy, before being converted.

step
step(actions: Tensor) -> None

Handle the received actions.

reset
reset(envs_idx: list[int] | None)

Reset environments.

get_actions
get_actions() -> torch.Tensor

Get the current actions for the environments.

PositionDebugVisualizerConfig

Bases: TypedDict

Defines the configuration for the debug visualizer.

Attributes:

Name Type Description
envs_idx list[int]

The indices of the environments to visualize. If None, all environments will be visualized.

sphere_offset float

The vertical offset of the debug arrows from the top of the robot

sphere_radius float

The radius of the shaft of the debug arrows

commanded_color tuple[float, float, float, float]

The color of the commanded velocity arrow

envs_idx instance-attribute
envs_idx: list[int]

The indices of the environments to visualize. If None, all environments will be visualized.

sphere_offset instance-attribute
sphere_offset: float

The vertical offset of the debug arrows from the top of the robot

sphere_radius instance-attribute
sphere_radius: float

The radius of the shaft of the debug arrows

commanded_color instance-attribute
commanded_color: tuple[float, float, float, float]

The color of the commanded velocity arrow

PositionCommandManager
PositionCommandManager(env: GenesisEnv, range: PositionCommandRange, resample_time_sec: float = 5.0, debug_visualizer: bool = False, debug_visualizer_cfg: PositionDebugVisualizerConfig = DEFAULT_VISUALIZER_CONFIG)

Bases: CommandManager

Generates a position command from uniform distribution. The command comprises of a linear velocity in x and y direction and an angular velocity around the z-axis.

IMPORTANT: The position commands are interpreted as world-relative coordinates: - X-axis: x coordinate of the target position - Y-axis: y coordinate of the target position - Z-axis: z coordinate of the target position

Debug visualization:

If `debug_visualizer` is set to True, a target sphere is rendered above
the commanded position.

Visual meaning:

- GREEN: Commanded position for the robot in the world frame

Parameters:

Name Type Description Default
env GenesisEnv

The environment to control

required
range PositionCommandRange

The ranges of linear & angular velocities

required
resample_time_sec float

The time interval between changing the command

5.0
debug_visualizer bool

Enable the debug arrow visualization

False
debug_visualizer_cfg PositionDebugVisualizerConfig

The configuration for the debug visualizer

DEFAULT_VISUALIZER_CONFIG

Example::

class MyEnv(GenesisEnv):
    def config(self):
        # Create a velocity command manager
        self.command_manager = PositionCommandManager(
            self,
            visualize=True,
            range = {
                "lin_vel_x_range": (-1.0, 1.0),
                "lin_vel_y_range": (-1.0, 1.0),
                "ang_vel_z_range": (-0.5, 0.5),
            }
        )

        RewardManager(
            self,
            logging_enabled=True,
            cfg={
                "tracking_lin_vel": {
                    "weight": 1.0,
                    "fn": rewards.command_tracking_lin_vel,
                    "params": {
                        "vel_cmd_manager": self.velocity_command,
                    },
                },
                "tracking_ang_vel": {
                    "weight": 1.0,
                    "fn": rewards.command_tracking_ang_vel,
                    "params": {
                        "vel_cmd_manager": self.velocity_command,
                    },
                },
                # ... other rewards ...
            },
        )

        # Observations
        ObservationManager(
            self,
            cfg={
                "velocity_cmd": {"fn": self.velocity_command.observation},
                # ... other observations ...
            },
        )

Methods:

Name Description
resample_command

Overwrites commands for environments that should be standing still.

build

Build the position command manager

step

Render the command arrows

use_gamepad

Use a connected gamepad to control the command.

Attributes:

Name Type Description
command Tensor

The desired command value. Shape is (num_envs, num_ranges).

command property
command: Tensor

The desired command value. Shape is (num_envs, num_ranges).

resample_command
resample_command(env_ids: list[int])

Overwrites commands for environments that should be standing still.

build
build()

Build the position command manager

step
step()

Render the command arrows

use_gamepad
use_gamepad(gamepad: Gamepad, pos_x_axis: int = 0, pos_y_axis: int = 1, pos_z_axis: int = 2)

Use a connected gamepad to control the command.

Parameters:

Name Type Description Default
gamepad Gamepad

The gamepad to use.

required
pos_x_axis int

Map this gamepad axis index to the position in the x-direction.

0
pos_y_axis int

Map this gamepad axis index to the position in the y-direction.

1
pos_z_axis int

Map this gamepad axis index to the position in the z-direction.

2
lin_vel_l2
lin_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize base linear velocity using L2 squared kernel.

ang_vel_l2
ang_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize base angular velocity using L2 squared kernel.

pos_error_l2
pos_error_l2(env: GenesisEnv, target_pose: Tensor = None, pose_command: CommandManager = None) -> torch.Tensor

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

pos_error_tanh
pos_error_tanh(env: GenesisEnv, target_pose: Tensor = None, std: float = 0.8, pose_command: CommandManager = None) -> torch.Tensor

Penalize asset pos from its target pos using tanh kernel.

actions

Classes:

Name Description
ControlActionManager

Base class for action managers that control actuators.

ControlActionManager
ControlActionManager(env: GenesisEnv, delay_step: int = 0, params: VehicleParams = VehicleParams(), gains: dict | None = None, limits: dict | None = None, entity_attr: str = 'robot', control_mode: str = 'cmd_motor_speeds')

Bases: BaseActionManager

Base class for action managers that control actuators.

Parameters:

Name Type Description Default
env GenesisEnv

The environment to manage the DOF actuators for.

required
delay_step int

The number of steps to delay the actions for. This is an easy way to emulate the latency in the system.

0
params VehicleParams

Vehicle physical parameters.

VehicleParams()
entity_attr str

Attribute name on the environment for the robot entity.

'robot'
control_mode str

Control mode string (e.g. 'cmd_motor_speeds').

'cmd_motor_speeds'

Methods:

Name Description
step

Handle the received actions.

reset

Reset environments.

get_actions

Get the current actions for the environments.

Attributes:

Name Type Description
num_actions int

The total number of actions.

action_space tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions Tensor

The actions for for the current step.

raw_actions Tensor

The actions received from the policy, before being converted.

num_actions property
num_actions: int

The total number of actions.

action_space property
action_space: tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions property
actions: Tensor

The actions for for the current step.

raw_actions property
raw_actions: Tensor

The actions received from the policy, before being converted.

step
step(actions: Tensor) -> None

Handle the received actions.

reset
reset(envs_idx: list[int] | None)

Reset environments.

get_actions
get_actions() -> torch.Tensor

Get the current actions for the environments.

commands

Classes:

Name Description
PositionDebugVisualizerConfig

Defines the configuration for the debug visualizer.

PositionCommandManager

Generates a position command from uniform distribution.

PositionDebugVisualizerConfig

Bases: TypedDict

Defines the configuration for the debug visualizer.

Attributes:

Name Type Description
envs_idx list[int]

The indices of the environments to visualize. If None, all environments will be visualized.

sphere_offset float

The vertical offset of the debug arrows from the top of the robot

sphere_radius float

The radius of the shaft of the debug arrows

commanded_color tuple[float, float, float, float]

The color of the commanded velocity arrow

envs_idx instance-attribute
envs_idx: list[int]

The indices of the environments to visualize. If None, all environments will be visualized.

sphere_offset instance-attribute
sphere_offset: float

The vertical offset of the debug arrows from the top of the robot

sphere_radius instance-attribute
sphere_radius: float

The radius of the shaft of the debug arrows

commanded_color instance-attribute
commanded_color: tuple[float, float, float, float]

The color of the commanded velocity arrow

PositionCommandManager
PositionCommandManager(env: GenesisEnv, range: PositionCommandRange, resample_time_sec: float = 5.0, debug_visualizer: bool = False, debug_visualizer_cfg: PositionDebugVisualizerConfig = DEFAULT_VISUALIZER_CONFIG)

Bases: CommandManager

Generates a position command from uniform distribution. The command comprises of a linear velocity in x and y direction and an angular velocity around the z-axis.

IMPORTANT: The position commands are interpreted as world-relative coordinates: - X-axis: x coordinate of the target position - Y-axis: y coordinate of the target position - Z-axis: z coordinate of the target position

Debug visualization:

If `debug_visualizer` is set to True, a target sphere is rendered above
the commanded position.

Visual meaning:

- GREEN: Commanded position for the robot in the world frame

Parameters:

Name Type Description Default
env GenesisEnv

The environment to control

required
range PositionCommandRange

The ranges of linear & angular velocities

required
resample_time_sec float

The time interval between changing the command

5.0
debug_visualizer bool

Enable the debug arrow visualization

False
debug_visualizer_cfg PositionDebugVisualizerConfig

The configuration for the debug visualizer

DEFAULT_VISUALIZER_CONFIG

Example::

class MyEnv(GenesisEnv):
    def config(self):
        # Create a velocity command manager
        self.command_manager = PositionCommandManager(
            self,
            visualize=True,
            range = {
                "lin_vel_x_range": (-1.0, 1.0),
                "lin_vel_y_range": (-1.0, 1.0),
                "ang_vel_z_range": (-0.5, 0.5),
            }
        )

        RewardManager(
            self,
            logging_enabled=True,
            cfg={
                "tracking_lin_vel": {
                    "weight": 1.0,
                    "fn": rewards.command_tracking_lin_vel,
                    "params": {
                        "vel_cmd_manager": self.velocity_command,
                    },
                },
                "tracking_ang_vel": {
                    "weight": 1.0,
                    "fn": rewards.command_tracking_ang_vel,
                    "params": {
                        "vel_cmd_manager": self.velocity_command,
                    },
                },
                # ... other rewards ...
            },
        )

        # Observations
        ObservationManager(
            self,
            cfg={
                "velocity_cmd": {"fn": self.velocity_command.observation},
                # ... other observations ...
            },
        )

Methods:

Name Description
resample_command

Overwrites commands for environments that should be standing still.

build

Build the position command manager

step

Render the command arrows

use_gamepad

Use a connected gamepad to control the command.

Attributes:

Name Type Description
command Tensor

The desired command value. Shape is (num_envs, num_ranges).

command property
command: Tensor

The desired command value. Shape is (num_envs, num_ranges).

resample_command
resample_command(env_ids: list[int])

Overwrites commands for environments that should be standing still.

build
build()

Build the position command manager

step
step()

Render the command arrows

use_gamepad
use_gamepad(gamepad: Gamepad, pos_x_axis: int = 0, pos_y_axis: int = 1, pos_z_axis: int = 2)

Use a connected gamepad to control the command.

Parameters:

Name Type Description Default
gamepad Gamepad

The gamepad to use.

required
pos_x_axis int

Map this gamepad axis index to the position in the x-direction.

0
pos_y_axis int

Map this gamepad axis index to the position in the y-direction.

1
pos_z_axis int

Map this gamepad axis index to the position in the z-direction.

2
rewards

Functions:

Name Description
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.

lin_vel_l2
lin_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize base linear velocity using L2 squared kernel.

ang_vel_l2
ang_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize base angular velocity using L2 squared kernel.

pos_error_l2
pos_error_l2(env: GenesisEnv, target_pose: Tensor = None, pose_command: CommandManager = None) -> torch.Tensor

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

pos_error_tanh
pos_error_tanh(env: GenesisEnv, target_pose: Tensor = None, std: float = 0.8, pose_command: CommandManager = None) -> torch.Tensor

Penalize asset pos from its target pos using tanh kernel.

LAV2_base_velocity

Modules:

Name Description
environment

LAV2 Base Environment using managers to handle everything.

eval
mdp
environment

LAV2 Base Environment using managers to handle everything.

Classes:

Name Description
LAV2BaseEnv

Example training environment for the LAV2 robot.

LAV2BaseEnv
LAV2BaseEnv(num_envs: int = 1, dt: float = 1 / 100, max_episode_length_s: int | None = 10, headless: bool = True)

Bases: ManagedEnvironment

Example training environment for the LAV2 robot.

Methods:

Name Description
config

Configure the environment managers

config
config()

Configure the environment managers

eval

Functions:

Name Description
get_latest_model

Get the last model from the log directory

get_latest_model
get_latest_model(log_dir: str) -> str

Get the last model from the log directory

mdp

Modules:

Name Description
actions
rewards

Classes:

Name Description
FlightActionMapper

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

Mixer

Map thrust and moment demands to rotor commands.

VehicleParams

LAV2 vehicle parameters.

RotorDynamics

Batched rotor dynamics model.

ControlActionManager

Base class for action managers that control actuators.

FlightActionMapper
FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), limits: FlightMappingLimits = FlightMappingLimits(), *, num_envs: int = 1, device: str | device = 'cpu')

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

Initialize a batched Torch flight action mapper for the selected mode.

Methods:

Name Description
map_action

Map a normalized batched action into RPM commands and intermediates.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller target expansion step.

requires_controller property
requires_controller: bool

Whether this mode needs a controller target expansion step.

map_action
map_action(action: Tensor, mixer: Mixer, *, state: Tensor | None = None, flight_controller: ControllerBase | None = None) -> FlightMappingResult

Map a normalized batched action into RPM commands and intermediates.

Mixer
Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the torch mixer with vehicle parameters and device.

Methods:

Name Description
randomize

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

randomize
randomize(env_ids=None, randomization=None)

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve
apply_thrust_curve(normalized_thrust: Tensor, mode: int = 1) -> torch.Tensor

Apply thrust curve to normalized thrust command.

References

cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137 cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

Parameters:

Name Type Description Default
normalized_thrust Tensor

Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise.

required
mode int

Thrust curve mode.

1

Returns:

Type Description
Tensor

torch.Tensor: Thrust in Newtons with the same shape as normalized_thrust.

Raises:

Type Description
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands
calculate_rotor_commands(control: Tensor) -> torch.Tensor

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default
control Tensor

Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). 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: np.diag([0.11, 0.108, 0.215]).tolist())(), diameter: float = 0.476, Cdx: float = 0.5, x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = 8 * (np.pi / 180), r_p: float = 0.0775, J_m: float = 1e-05, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = 14.6 * (np.pi / 180), thetaTip: float = 6.8 * (np.pi / 180), lock: float = 0.6051, max_rpm: float = 10000.0, init_rpm: float = -1.0, rotor_rpm_rate_limit: float = 50000.0, tau_f: float = 0.01, tau_m: float = 0.05, tau_up: float = -1.0, tau_down: float = -1.0, r_w: float = 0.0285, n_w: int = 4, B: float = 0.136, L: float = 0.23, h_cg: float = 0.078, f: float = 0.01, mu0: float = 0.8, K: float = 20, track_cmd_rate_limit: float = 100, min_throttle_manual: float = 0.08, min_throttle: float = 0.12, max_throttle: float = 1.0, hover_throttle: float = -1)

LAV2 vehicle parameters.

Methods:

Name Description
__post_init__

Calculate derived parameters.

Attributes:

Name Type Description
rho float

空气密度 (kg/m^3)

g float

重力加速度 (m/s^2)

sim_dt float

仿真步长 (s)

step_dt float

控制步长 (s)

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

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass float

质量 (kg)

inertia list

惯性矩阵 (kg*m^2)

diameter float

直径 (m)

Cdx float

空气阻力系数

x float

x方向臂长 (m)

y float

y方向臂长 (m)

h float

重心高度 (m)

alpha float

y方向涵道外倾角度 (rad)

r_p float

螺旋桨半径 (m)

J_m float

电机转动惯量 (kg*m^2)

Ct float

推力系数

Cq float

扭矩系数

theta0 float

桨根角 (rad)

thetaTip float

桨尖角 (rad)

theta1 float

桨叶扭转角 (rad)

lock float

Lock number

max_rpm float

最大转速

init_rpm float

初始转速

rotor_rpm_rate_limit float

旋翼转速变化率限制 (rpm/s)

cT float

转速平方到推力增益 (N/(rpm^2))

cM float

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f float

电机滤波时间常数 (s)

tau_m float

兼容保留的电机时间常数 (s)

tau_up float

电机升速时间常数 (s)

tau_down float

电机降速时间常数 (s)

r_w float

主动轮半径 (m)

n_w int

负重轮个数

B float

两侧履带中心距 (m)

L float

履带节点接地部分长度 (m)

h_cg float

车体质心高度 (m)

f float

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 float

滑转率为1时的摩擦系数

K float

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit float

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual float

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle float

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle float

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle float

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

rho class-attribute instance-attribute
rho: float = 1.184

空气密度 (kg/m^3)

g class-attribute instance-attribute
g: float = 9.81

重力加速度 (m/s^2)

sim_dt class-attribute instance-attribute
sim_dt: float = 0.01

仿真步长 (s)

step_dt class-attribute instance-attribute
step_dt: float = 0.01

控制步长 (s)

randomization class-attribute instance-attribute
randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass class-attribute instance-attribute
mass: float = 2.1

质量 (kg)

inertia class-attribute instance-attribute
inertia: list = field(default_factory=lambda: tolist())

惯性矩阵 (kg*m^2)

diameter class-attribute instance-attribute
diameter: float = 0.476

直径 (m)

Cdx class-attribute instance-attribute
Cdx: float = 0.5

空气阻力系数

x class-attribute instance-attribute
x: float = 0.0952

x方向臂长 (m)

y class-attribute instance-attribute
y: float = 0.114423

y方向臂长 (m)

h class-attribute instance-attribute
h: float = -0.0125

重心高度 (m)

alpha class-attribute instance-attribute
alpha: float = 8 * (pi / 180)

y方向涵道外倾角度 (rad)

r_p class-attribute instance-attribute
r_p: float = 0.0775

螺旋桨半径 (m)

J_m class-attribute instance-attribute
J_m: float = 1e-05

电机转动惯量 (kg*m^2)

Ct class-attribute instance-attribute
Ct: float = 0.666

推力系数

Cq class-attribute instance-attribute
Cq: float = 0.0716

扭矩系数

theta0 class-attribute instance-attribute
theta0: float = 14.6 * (pi / 180)

桨根角 (rad)

thetaTip class-attribute instance-attribute
thetaTip: float = 6.8 * (pi / 180)

桨尖角 (rad)

theta1 class-attribute instance-attribute
theta1: float = field(init=False)

桨叶扭转角 (rad)

lock class-attribute instance-attribute
lock: float = 0.6051

Lock number

max_rpm class-attribute instance-attribute
max_rpm: float = 10000.0

最大转速

init_rpm class-attribute instance-attribute
init_rpm: float = -1.0

初始转速

rotor_rpm_rate_limit class-attribute instance-attribute
rotor_rpm_rate_limit: float = 50000.0

旋翼转速变化率限制 (rpm/s)

cT class-attribute instance-attribute
cT: float = field(init=False)

转速平方到推力增益 (N/(rpm^2))

cM class-attribute instance-attribute
cM: float = field(init=False)

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f class-attribute instance-attribute
tau_f: float = 0.01

电机滤波时间常数 (s)

tau_m class-attribute instance-attribute
tau_m: float = 0.05

兼容保留的电机时间常数 (s)

tau_up class-attribute instance-attribute
tau_up: float = -1.0

电机升速时间常数 (s)

tau_down class-attribute instance-attribute
tau_down: float = -1.0

电机降速时间常数 (s)

r_w class-attribute instance-attribute
r_w: float = 0.0285

主动轮半径 (m)

n_w class-attribute instance-attribute
n_w: int = 4

负重轮个数

B class-attribute instance-attribute
B: float = 0.136

两侧履带中心距 (m)

L class-attribute instance-attribute
L: float = 0.23

履带节点接地部分长度 (m)

h_cg class-attribute instance-attribute
h_cg: float = 0.078

车体质心高度 (m)

f class-attribute instance-attribute
f: float = 0.01

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 class-attribute instance-attribute
mu0: float = 0.8

滑转率为1时的摩擦系数

K class-attribute instance-attribute
K: float = 20

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit class-attribute instance-attribute
track_cmd_rate_limit: float = 100

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual class-attribute instance-attribute
min_throttle_manual: float = 0.08

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle class-attribute instance-attribute
min_throttle: float = 0.12

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle class-attribute instance-attribute
max_throttle: float = 1.0

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle class-attribute instance-attribute
hover_throttle: float = -1

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

__post_init__
__post_init__()

Calculate derived parameters.

RotorDynamics
RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched rotor dynamics model.

Initialize batched rotor dynamics on the specified device.

Methods:

Name Description
randomize

Randomize rotor runtime parameters from nominal values.

update

Calculate the output thrust and torque for each motor based on the motor commands.

reset

Resets the rotor model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

randomize
randomize(env_ids: slice | Sequence[int] | Tensor | None = None, randomization: dict[str, tuple[float, float]] | None = None) -> None

Randomize rotor runtime parameters from nominal values.

update
update(commands: Tensor) -> torch.Tensor

Calculate the output thrust and torque for each motor based on the motor commands.

Parameters:

Name Type Description Default
commands Tensor

Command tensor for each motor. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: Thrust and torque tensor for each motor. Shape: (num_envs, 8)

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the rotor model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required
ControlActionManager
ControlActionManager(env: GenesisEnv, delay_step: int = 0, params: VehicleParams = VehicleParams(), entity_attr: str = 'robot')

Bases: BaseActionManager

Base class for action managers that control actuators.

Parameters:

Name Type Description Default
env GenesisEnv

The environment to manage the DOF actuators for.

required
delay_step int

The number of steps to delay the actions for. This is an easy way to emulate the latency in the system.

0
params VehicleParams

Vehicle physical parameters.

VehicleParams()
entity_attr str

Attribute name on the environment for the robot entity.

'robot'

Methods:

Name Description
step

Handle the received actions.

reset

Reset environments.

get_actions

Get the current actions for the environments.

Attributes:

Name Type Description
num_actions int

The total number of actions.

action_space tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions Tensor

The actions for for the current step.

raw_actions Tensor

The actions received from the policy, before being converted.

num_actions property
num_actions: int

The total number of actions.

action_space property
action_space: tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions property
actions: Tensor

The actions for for the current step.

raw_actions property
raw_actions: Tensor

The actions received from the policy, before being converted.

step
step(actions: Tensor) -> None

Handle the received actions.

reset
reset(envs_idx: list[int] | None)

Reset environments.

get_actions
get_actions() -> torch.Tensor

Get the current actions for the environments.

actions

Classes:

Name Description
ControlActionManager

Base class for action managers that control actuators.

ControlActionManager
ControlActionManager(env: GenesisEnv, delay_step: int = 0, params: VehicleParams = VehicleParams(), entity_attr: str = 'robot')

Bases: BaseActionManager

Base class for action managers that control actuators.

Parameters:

Name Type Description Default
env GenesisEnv

The environment to manage the DOF actuators for.

required
delay_step int

The number of steps to delay the actions for. This is an easy way to emulate the latency in the system.

0
params VehicleParams

Vehicle physical parameters.

VehicleParams()
entity_attr str

Attribute name on the environment for the robot entity.

'robot'

Methods:

Name Description
step

Handle the received actions.

reset

Reset environments.

get_actions

Get the current actions for the environments.

Attributes:

Name Type Description
num_actions int

The total number of actions.

action_space tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions Tensor

The actions for for the current step.

raw_actions Tensor

The actions received from the policy, before being converted.

num_actions property
num_actions: int

The total number of actions.

action_space property
action_space: tuple[float, float]

If using the default action handler, the action space is [-1, 1].

actions property
actions: Tensor

The actions for for the current step.

raw_actions property
raw_actions: Tensor

The actions received from the policy, before being converted.

step
step(actions: Tensor) -> None

Handle the received actions.

reset
reset(envs_idx: list[int] | None)

Reset environments.

get_actions
get_actions() -> torch.Tensor

Get the current actions for the environments.

rewards

Functions:

Name Description
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.

wrap_to_pi

Wraps input angles (in radians) to the range :math:[-\pi, \pi].

lin_vel_l2
lin_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize base linear velocity using L2 squared kernel.

ang_vel_l2
ang_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize base angular velocity using L2 squared kernel.

pos_error_l2
pos_error_l2(env: GenesisEnv, target_pose: Tensor, pose_command: CommandManager = None, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

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

pos_error_tanh
pos_error_tanh(env: GenesisEnv, target_pose: Tensor, pose_command: CommandManager = None, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize asset pos from its target pos using tanh kernel.

yaw_error_l2
yaw_error_l2(env: GenesisEnv, target_pose: Tensor, pose_command: CommandManager = None, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor

Penalize heading error from target heading using L2 squared kernel.

yaw_error_tanh
yaw_error_tanh(env: GenesisEnv, target_pose: Tensor, pose_command: CommandManager = None, entity_attr: str = 'robot', entity_manager: EntityManager = None, std: float = 0.8) -> torch.Tensor

Penalize heading error from target heading.

wrap_to_pi
wrap_to_pi(angles: Tensor) -> torch.Tensor

Wraps input angles (in radians) to the range :math:[-\pi, \pi].

This function wraps angles in radians to the range :math:[-\pi, \pi], such that :math:\pi maps to :math:\pi, and :math:-\pi maps to :math:-\pi. In general, odd positive multiples of :math:\pi are mapped to :math:\pi, and odd negative multiples of :math:\pi are mapped to :math:-\pi.

The function behaves similar to MATLAB's wrapToPi <https://www.mathworks.com/help/map/ref/wraptopi.html>_ function.

Parameters:

Name Type Description Default
angles Tensor

Input angles of any shape.

required

Returns:

Type Description
Tensor

torch.Tensor: Angles in the range :math:[-\pi, \pi].

isaaclab

Modules:

Name Description
LAV2_base
LAV2_base_direct
LAV2_navrl
LAV2_trajectory

LAV2_base

Modules:

Name Description
LAV2_bimodal_vel_env_cfg
LAV2_env_cfg
LAV2_track_env_cfg
LAV2_vel_env_cfg
mdp
LAV2_bimodal_vel_env_cfg

Classes:

Name Description
ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Configuration for the LAV2 environment.

ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

Classes:

Name Description
PolicyCfg

Observations for policy group.

PolicyCfg

Bases: ObservationGroupCfg

Observations for policy group.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Bases: ManagerBasedRLEnvCfg

Configuration for the LAV2 environment.

Methods:

Name Description
__post_init__

Post initialization.

__post_init__
__post_init__() -> None

Post initialization.

LAV2_env_cfg

Classes:

Name Description
ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Configuration for the LAV2 environment.

ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

Classes:

Name Description
PolicyCfg

Observations for policy group.

PolicyCfg

Bases: ObservationGroupCfg

Observations for policy group.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Bases: ManagerBasedRLEnvCfg

Configuration for the LAV2 environment.

Methods:

Name Description
__post_init__

Post initialization.

__post_init__
__post_init__() -> None

Post initialization.

LAV2_track_env_cfg

Classes:

Name Description
ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Configuration for the LAV2 environment.

ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

Classes:

Name Description
PolicyCfg

Observations for policy group.

PolicyCfg

Bases: ObservationGroupCfg

Observations for policy group.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Bases: ManagerBasedRLEnvCfg

Configuration for the LAV2 environment.

Methods:

Name Description
__post_init__

Post initialization.

__post_init__
__post_init__() -> None

Post initialization.

LAV2_vel_env_cfg

Classes:

Name Description
ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Configuration for the LAV2 environment.

ActionsCfg

Action specifications for the MDP.

ObservationsCfg

Observation specifications for the MDP.

Classes:

Name Description
PolicyCfg

Observations for policy group.

PolicyCfg

Bases: ObservationGroupCfg

Observations for policy group.

EventCfg

Configuration for events.

CommandsCfg

Command specifications for the MDP.

RewardsCfg

Reward terms for the MDP.

TerminationsCfg

Termination terms for the MDP.

LAV2EnvCfg

Bases: ManagerBasedRLEnvCfg

Configuration for the LAV2 environment.

Methods:

Name Description
__post_init__

Post initialization.

__post_init__
__post_init__() -> None

Post initialization.

mdp

Modules:

Name Description
actions
commands
events
observations
rewards
terminations

Classes:

Name Description
FlightActionMapper

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

FlightMappingLimits

Per-channel limits used when mapping normalized actions to targets.

Mixer

Map thrust and moment demands to rotor commands.

FlightController

PID flight controller (batched).

VehicleParams

LAV2 vehicle parameters.

RotorDynamics

Batched rotor dynamics model.

TrackDynamics

Batched track dynamics model.

ControlAction

Body torque control action term.

ControlActionCfg

See :class:ControlAction for more details.

TrackControlAction

Track force control action term.

TrackControlActionCfg

See :class:ControlAction for more details.

UniformPoseCommandGlobal

Command generator that generates pose commands containing a 3-D position and heading.

UniformPoseCommandGlobalCfg

Configuration for the uniform 3D-pose command generator.

UniformVelocityGlobalCommand

Command generator that generates a velocity command with uniform distribution.

UniformVelocityGlobalCommandCfg

Configuration for the uniform velocity command generator.

UniformBimodalVelocityCommand

Bimodal velocity command generator with a discrete mode indicator (4+1).

UniformBimodalVelocityCommandCfg

Configuration for the bimodal velocity command generator (flight vs ground).

Functions:

Name Description
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.

target_pos_b

Position of target in body frame.

root_euler_w

Euler angles of the root in world frame.

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.

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.

FlightActionMapper
FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), limits: FlightMappingLimits = FlightMappingLimits(), *, num_envs: int = 1, device: str | device = 'cpu')

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

Initialize a batched Torch flight action mapper for the selected mode.

Methods:

Name Description
map_action

Map a normalized batched action into RPM commands and intermediates.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller target expansion step.

requires_controller property
requires_controller: bool

Whether this mode needs a controller target expansion step.

map_action
map_action(action: Tensor, mixer: Mixer, *, state: Tensor | None = None, flight_controller: ControllerBase | None = None) -> FlightMappingResult

Map a normalized batched action into RPM commands and intermediates.

FlightMappingLimits dataclass
FlightMappingLimits(vel_limits: tuple[float, float, float] = (5.0, 5.0, 5.0), att_limits: tuple[float, float, float] = (1.0, 1.0, math.pi), br_limits: tuple[float, float, float] = (2.0, 2.0, 2.0))

Per-channel limits used when mapping normalized actions to targets.

Mixer
Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the torch mixer with vehicle parameters and device.

Methods:

Name Description
randomize

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

randomize
randomize(env_ids=None, randomization=None)

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve
apply_thrust_curve(normalized_thrust: Tensor, mode: int = 1) -> torch.Tensor

Apply thrust curve to normalized thrust command.

References

cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137 cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

Parameters:

Name Type Description Default
normalized_thrust Tensor

Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise.

required
mode int

Thrust curve mode.

1

Returns:

Type Description
Tensor

torch.Tensor: Thrust in Newtons with the same shape as normalized_thrust.

Raises:

Type Description
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands
calculate_rotor_commands(control: Tensor) -> torch.Tensor

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default
control Tensor

Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). Shape: (num_envs, 4)

FlightController
FlightController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0], gains: dict | None = None, limits: dict | None = None, num_envs: int = 1, device: str | device = 'cpu')

Bases: ControllerBase

PID flight controller (batched).

Initialize the batched flight PID controller.

Methods:

Name Description
randomize

Randomize configured PID gains and command limits for selected environments.

reset

Reset PID loops for selected environments.

update

Update controller.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

randomize
randomize(env_ids=None, gains=None, limits=None)

Randomize configured PID gains and command limits for selected environments.

reset
reset(env_ids)

Reset PID loops for selected environments.

update
update(target: Tensor, state: Tensor) -> torch.Tensor

Update controller.

Parameters:

Name Type Description Default
target Tensor

(N, 12) desired [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz]

required
state Tensor

(N, 12) current state same ordering.

required

Returns:

Type Description
Tensor

torch.Tensor: Tensor of shape (N, 4): [thrust, roll_moment, pitch_moment, yaw_moment].

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: np.diag([0.11, 0.108, 0.215]).tolist())(), diameter: float = 0.476, Cdx: float = 0.5, x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = 8 * (np.pi / 180), r_p: float = 0.0775, J_m: float = 1e-05, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = 14.6 * (np.pi / 180), thetaTip: float = 6.8 * (np.pi / 180), lock: float = 0.6051, max_rpm: float = 10000.0, init_rpm: float = -1.0, rotor_rpm_rate_limit: float = 50000.0, tau_f: float = 0.01, tau_m: float = 0.05, tau_up: float = -1.0, tau_down: float = -1.0, r_w: float = 0.0285, n_w: int = 4, B: float = 0.136, L: float = 0.23, h_cg: float = 0.078, f: float = 0.01, mu0: float = 0.8, K: float = 20, track_cmd_rate_limit: float = 100, min_throttle_manual: float = 0.08, min_throttle: float = 0.12, max_throttle: float = 1.0, hover_throttle: float = -1)

LAV2 vehicle parameters.

Methods:

Name Description
__post_init__

Calculate derived parameters.

Attributes:

Name Type Description
rho float

空气密度 (kg/m^3)

g float

重力加速度 (m/s^2)

sim_dt float

仿真步长 (s)

step_dt float

控制步长 (s)

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

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass float

质量 (kg)

inertia list

惯性矩阵 (kg*m^2)

diameter float

直径 (m)

Cdx float

空气阻力系数

x float

x方向臂长 (m)

y float

y方向臂长 (m)

h float

重心高度 (m)

alpha float

y方向涵道外倾角度 (rad)

r_p float

螺旋桨半径 (m)

J_m float

电机转动惯量 (kg*m^2)

Ct float

推力系数

Cq float

扭矩系数

theta0 float

桨根角 (rad)

thetaTip float

桨尖角 (rad)

theta1 float

桨叶扭转角 (rad)

lock float

Lock number

max_rpm float

最大转速

init_rpm float

初始转速

rotor_rpm_rate_limit float

旋翼转速变化率限制 (rpm/s)

cT float

转速平方到推力增益 (N/(rpm^2))

cM float

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f float

电机滤波时间常数 (s)

tau_m float

兼容保留的电机时间常数 (s)

tau_up float

电机升速时间常数 (s)

tau_down float

电机降速时间常数 (s)

r_w float

主动轮半径 (m)

n_w int

负重轮个数

B float

两侧履带中心距 (m)

L float

履带节点接地部分长度 (m)

h_cg float

车体质心高度 (m)

f float

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 float

滑转率为1时的摩擦系数

K float

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit float

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual float

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle float

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle float

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle float

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

rho class-attribute instance-attribute
rho: float = 1.184

空气密度 (kg/m^3)

g class-attribute instance-attribute
g: float = 9.81

重力加速度 (m/s^2)

sim_dt class-attribute instance-attribute
sim_dt: float = 0.01

仿真步长 (s)

step_dt class-attribute instance-attribute
step_dt: float = 0.01

控制步长 (s)

randomization class-attribute instance-attribute
randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass class-attribute instance-attribute
mass: float = 2.1

质量 (kg)

inertia class-attribute instance-attribute
inertia: list = field(default_factory=lambda: tolist())

惯性矩阵 (kg*m^2)

diameter class-attribute instance-attribute
diameter: float = 0.476

直径 (m)

Cdx class-attribute instance-attribute
Cdx: float = 0.5

空气阻力系数

x class-attribute instance-attribute
x: float = 0.0952

x方向臂长 (m)

y class-attribute instance-attribute
y: float = 0.114423

y方向臂长 (m)

h class-attribute instance-attribute
h: float = -0.0125

重心高度 (m)

alpha class-attribute instance-attribute
alpha: float = 8 * (pi / 180)

y方向涵道外倾角度 (rad)

r_p class-attribute instance-attribute
r_p: float = 0.0775

螺旋桨半径 (m)

J_m class-attribute instance-attribute
J_m: float = 1e-05

电机转动惯量 (kg*m^2)

Ct class-attribute instance-attribute
Ct: float = 0.666

推力系数

Cq class-attribute instance-attribute
Cq: float = 0.0716

扭矩系数

theta0 class-attribute instance-attribute
theta0: float = 14.6 * (pi / 180)

桨根角 (rad)

thetaTip class-attribute instance-attribute
thetaTip: float = 6.8 * (pi / 180)

桨尖角 (rad)

theta1 class-attribute instance-attribute
theta1: float = field(init=False)

桨叶扭转角 (rad)

lock class-attribute instance-attribute
lock: float = 0.6051

Lock number

max_rpm class-attribute instance-attribute
max_rpm: float = 10000.0

最大转速

init_rpm class-attribute instance-attribute
init_rpm: float = -1.0

初始转速

rotor_rpm_rate_limit class-attribute instance-attribute
rotor_rpm_rate_limit: float = 50000.0

旋翼转速变化率限制 (rpm/s)

cT class-attribute instance-attribute
cT: float = field(init=False)

转速平方到推力增益 (N/(rpm^2))

cM class-attribute instance-attribute
cM: float = field(init=False)

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f class-attribute instance-attribute
tau_f: float = 0.01

电机滤波时间常数 (s)

tau_m class-attribute instance-attribute
tau_m: float = 0.05

兼容保留的电机时间常数 (s)

tau_up class-attribute instance-attribute
tau_up: float = -1.0

电机升速时间常数 (s)

tau_down class-attribute instance-attribute
tau_down: float = -1.0

电机降速时间常数 (s)

r_w class-attribute instance-attribute
r_w: float = 0.0285

主动轮半径 (m)

n_w class-attribute instance-attribute
n_w: int = 4

负重轮个数

B class-attribute instance-attribute
B: float = 0.136

两侧履带中心距 (m)

L class-attribute instance-attribute
L: float = 0.23

履带节点接地部分长度 (m)

h_cg class-attribute instance-attribute
h_cg: float = 0.078

车体质心高度 (m)

f class-attribute instance-attribute
f: float = 0.01

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 class-attribute instance-attribute
mu0: float = 0.8

滑转率为1时的摩擦系数

K class-attribute instance-attribute
K: float = 20

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit class-attribute instance-attribute
track_cmd_rate_limit: float = 100

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual class-attribute instance-attribute
min_throttle_manual: float = 0.08

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle class-attribute instance-attribute
min_throttle: float = 0.12

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle class-attribute instance-attribute
max_throttle: float = 1.0

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle class-attribute instance-attribute
hover_throttle: float = -1

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

__post_init__
__post_init__()

Calculate derived parameters.

RotorDynamics
RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched rotor dynamics model.

Initialize batched rotor dynamics on the specified device.

Methods:

Name Description
randomize

Randomize rotor runtime parameters from nominal values.

update

Calculate the output thrust and torque for each motor based on the motor commands.

reset

Resets the rotor model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

randomize
randomize(env_ids: slice | Sequence[int] | Tensor | None = None, randomization: dict[str, tuple[float, float]] | None = None) -> None

Randomize rotor runtime parameters from nominal values.

update
update(commands: Tensor) -> torch.Tensor

Calculate the output thrust and torque for each motor based on the motor commands.

Parameters:

Name Type Description Default
commands Tensor

Command tensor for each motor. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: Thrust and torque tensor for each motor. Shape: (num_envs, 8)

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the rotor model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required
TrackDynamics
TrackDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched track dynamics model.

Initialize batched track dynamics on the specified device.

Methods:

Name Description
update

Compute track forces for batched environments.

reset

Resets the track model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

update
update(commands: Tensor, state: Tensor) -> torch.Tensor

Compute track forces for batched environments.

Parameters:

Name Type Description Default
commands Tensor

Shape (num_envs, 2) track commands [left, right].

required
state Tensor

Shape (num_envs, 3) body-frame velocities [u, v, r].

required

Returns:

Type Description
Tensor

torch.Tensor: Tensor of shape (num_envs, 2, n_w, 2) [side, wheel, (Fx, Fy)].

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the track model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required
ControlAction
ControlAction(cfg: ControlActionCfg, env: ManagerBasedRLEnv)

Bases: ActionTerm

Body torque control action term.

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

Attributes:

Name Type Description
cfg ControlActionCfg

The configuration of the action term.

cfg instance-attribute
cfg: ControlActionCfg = cfg

The configuration of the action term.

ControlActionCfg

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
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.

params VehicleParams

Vehicle parameters.

gains dict | None

Optional gains configuration for the flight controller. See FlightController for details.

limits dict | None

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

control_mode str

Control mode, options: cmd_motor_thrusts, cmd_motor_speeds, cmd_ctbm, cmd_ctbr, cmd_ctatt, cmd_vel, cmd_pos.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = ControlAction

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.

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. See FlightController for details.

limits class-attribute instance-attribute
limits: dict | None = None

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

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_vel, 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)

TrackControlAction
TrackControlAction(cfg: TrackControlActionCfg, env: ManagerBasedRLEnv)

Bases: ActionTerm

Track force control action term.

This action term converts normalized track commands into ground reaction forces applied on each track body.

Attributes:

Name Type Description
cfg TrackControlActionCfg

The configuration of the action term.

cfg instance-attribute
cfg: TrackControlActionCfg = cfg

The configuration of the action term.

TrackControlActionCfg

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
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.

params VehicleParams

Vehicle parameters.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = TrackControlAction

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.

params class-attribute instance-attribute
params: VehicleParams = VehicleParams()

Vehicle parameters.

UniformPoseCommandGlobal
UniformPoseCommandGlobal(cfg: UniformPoseCommandGlobalCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Command generator that generates pose commands containing a 3-D position and heading.

The command generator samples uniform 3D positions around the environment origin. The heading command is either set to point towards the target or is sampled uniformly. This can be configured through the :attr:UniformPoseCommandGlobalCfg.simple_heading parameter in the configuration.

Initialize the command generator class.

Parameters:

Name Type Description Default
cfg UniformPoseCommandGlobalCfg

The configuration parameters for the command generator.

required
env ManagerBasedEnv

The environment object.

required

Attributes:

Name Type Description
cfg UniformPoseCommandGlobalCfg

Configuration for the command generator.

command Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformPoseCommandGlobalCfg

Configuration for the command generator.

command property
command: Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

UniformPoseCommandGlobalCfg

Bases: CommandTermCfg

Configuration for the uniform 3D-pose command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
asset_name str

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

simple_heading bool

Whether to use simple heading or not.

ranges Ranges

Distribution ranges for the position commands.

goal_pose_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal pose visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

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

simple_heading class-attribute instance-attribute
simple_heading: bool = MISSING

Whether to use simple heading or not.

If True, the heading is in the direction of the target position.

ranges class-attribute instance-attribute
ranges: Ranges = MISSING

Distribution ranges for the position commands.

goal_pose_visualizer_cfg class-attribute instance-attribute
goal_pose_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/pose_goal')

The configuration for the goal pose visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
pos_x tuple[float, float]

Range for the x position (in m).

pos_y tuple[float, float]

Range for the y position (in m).

pos_z tuple[float, float]

Range for the z position (in m).

heading tuple[float, float]

Heading range for the position commands (in rad).

pos_x class-attribute instance-attribute
pos_x: tuple[float, float] = MISSING

Range for the x position (in m).

pos_y class-attribute instance-attribute
pos_y: tuple[float, float] = MISSING

Range for the y position (in m).

pos_z class-attribute instance-attribute
pos_z: tuple[float, float] = MISSING

Range for the z position (in m).

heading class-attribute instance-attribute
heading: tuple[float, float] = MISSING

Heading range for the position commands (in rad).

Used only if :attr:simple_heading is False.

UniformVelocityGlobalCommand
UniformVelocityGlobalCommand(cfg: UniformVelocityGlobalCommandCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Command generator that generates a velocity command with uniform distribution.

The command comprises linear velocity in x, y, z directions and an angular velocity around the z-axis. It is given in the robot's base frame.

If the :attr:cfg.heading_command flag is set to True, the angular velocity is computed from the heading error similar to doing a proportional control on the heading error. The target heading is sampled uniformly from the provided range. Otherwise, the angular velocity is sampled uniformly from the provided range.

Mathematically, the angular velocity is computed as follows from the heading command:

.. math::

\omega_z = \frac{1}{2} \text{wrap_to_pi}(\theta_{\text{target}} - \theta_{\text{current}})

Initialize the command generator.

Parameters:

Name Type Description Default
cfg UniformVelocityGlobalCommandCfg

The configuration of the command generator.

required
env ManagerBasedEnv

The environment.

required

Raises:

Type Description
ValueError

If the heading command is active but the heading range is not provided.

Methods:

Name Description
__str__

Return a string representation of the command generator.

Attributes:

Name Type Description
cfg UniformVelocityGlobalCommandCfg

The configuration of the command generator.

command Tensor

The desired base velocity command in the base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformVelocityGlobalCommandCfg

The configuration of the command generator.

command property
command: Tensor

The desired base velocity command in the base frame. Shape is (num_envs, 4).

__str__
__str__() -> str

Return a string representation of the command generator.

UniformVelocityGlobalCommandCfg

Bases: CommandTermCfg

Configuration for the uniform velocity command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the velocity commands.

Attributes:

Name Type Description
asset_name str

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

heading_command bool

Whether to use heading command or angular velocity command. Defaults to False.

heading_control_stiffness float

Scale factor to convert the heading error to angular velocity command. Defaults to 1.0.

rel_standing_envs float

The sampled probability of environments that should be standing still. Defaults to 0.0.

rel_heading_envs float

The sampled probability of environments where the robots follow the heading-based angular velocity command

ranges Ranges

Distribution ranges for the velocity commands.

goal_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

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

heading_command class-attribute instance-attribute
heading_command: bool = False

Whether to use heading command or angular velocity command. Defaults to False.

If True, the angular velocity command is computed from the heading error, where the target heading is sampled uniformly from provided range. Otherwise, the angular velocity command is sampled uniformly from provided range.

heading_control_stiffness class-attribute instance-attribute
heading_control_stiffness: float = 1.0

Scale factor to convert the heading error to angular velocity command. Defaults to 1.0.

rel_standing_envs class-attribute instance-attribute
rel_standing_envs: float = 0.0

The sampled probability of environments that should be standing still. Defaults to 0.0.

rel_heading_envs class-attribute instance-attribute
rel_heading_envs: float = 1.0

The sampled probability of environments where the robots follow the heading-based angular velocity command (the others follow the sampled angular velocity command). Defaults to 1.0.

This parameter is only used if :attr:heading_command is True.

ranges class-attribute instance-attribute
ranges: Ranges = MISSING

Distribution ranges for the velocity commands.

goal_vel_visualizer_cfg class-attribute instance-attribute
goal_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_goal')

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg class-attribute instance-attribute
current_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_current')

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for the velocity commands.

Attributes:

Name Type Description
lin_vel_x tuple[float, float]

Range for the linear-x velocity command (in m/s).

lin_vel_y tuple[float, float]

Range for the linear-y velocity command (in m/s).

lin_vel_z tuple[float, float]

Range for the linear-z velocity command (in m/s).

ang_vel_z tuple[float, float]

Range for the angular-z velocity command (in rad/s).

heading tuple[float, float] | None

Range for the heading command (in rad). Defaults to None.

lin_vel_x class-attribute instance-attribute
lin_vel_x: tuple[float, float] = MISSING

Range for the linear-x velocity command (in m/s).

lin_vel_y class-attribute instance-attribute
lin_vel_y: tuple[float, float] = MISSING

Range for the linear-y velocity command (in m/s).

lin_vel_z class-attribute instance-attribute
lin_vel_z: tuple[float, float] = MISSING

Range for the linear-z velocity command (in m/s).

ang_vel_z class-attribute instance-attribute
ang_vel_z: tuple[float, float] = MISSING

Range for the angular-z velocity command (in rad/s).

heading class-attribute instance-attribute
heading: tuple[float, float] | None = None

Range for the heading command (in rad). Defaults to None.

This parameter is only used if :attr:~UniformVelocityGlobalCommandCfg.heading_command is True.

UniformBimodalVelocityCommand
UniformBimodalVelocityCommand(cfg: UniformBimodalVelocityCommandCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Bimodal velocity command generator with a discrete mode indicator (4+1).

This command samples base-frame velocities with two modes: - Flight mode: uses ranges_flight - Ground mode: uses ranges_ground

The output command augments the 4-D velocity with a 1-D discrete indicator: - 0.0 for flight mode - 1.0 for ground/terrestrial mode

Heading behavior matches UniformVelocityGlobalCommand with optional heading-target proportional control. Ranges are applied per selected mode.

Attributes:

Name Type Description
command Tensor

Return 4-D velocity plus 1-D mode indicator. Shape: (num_envs, 5).

command property
command: Tensor

Return 4-D velocity plus 1-D mode indicator. Shape: (num_envs, 5).

UniformBimodalVelocityCommandCfg

Bases: CommandTermCfg

Configuration for the bimodal velocity command generator (flight vs ground).

Classes:

Name Description
Ranges

Uniform distribution ranges for velocity commands per mode.

Attributes:

Name Type Description
asset_name str

Name of the asset receiving commands.

heading_command bool

Whether to convert heading error to angular velocity (per-mode ranges apply).

heading_control_stiffness float

Scale factor for heading error to yaw rate conversion.

rel_standing_envs float

Probability that an environment should be standing still (zero command).

rel_heading_envs float

Probability that an environment uses heading-based angular velocity when enabled.

rel_flight_envs float

Probability of sampling flight mode (vs ground).

ranges_flight Ranges

Ranges for flight mode sampling.

ranges_ground Ranges

Ranges for ground/terrestrial mode sampling.

goal_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

Name of the asset receiving commands.

heading_command class-attribute instance-attribute
heading_command: bool = False

Whether to convert heading error to angular velocity (per-mode ranges apply).

heading_control_stiffness class-attribute instance-attribute
heading_control_stiffness: float = 1.0

Scale factor for heading error to yaw rate conversion.

rel_standing_envs class-attribute instance-attribute
rel_standing_envs: float = 0.0

Probability that an environment should be standing still (zero command).

rel_heading_envs class-attribute instance-attribute
rel_heading_envs: float = 1.0

Probability that an environment uses heading-based angular velocity when enabled.

rel_flight_envs class-attribute instance-attribute
rel_flight_envs: float = 0.5

Probability of sampling flight mode (vs ground).

ranges_flight class-attribute instance-attribute
ranges_flight: Ranges = MISSING

Ranges for flight mode sampling.

ranges_ground class-attribute instance-attribute
ranges_ground: Ranges = MISSING

Ranges for ground/terrestrial mode sampling.

goal_vel_visualizer_cfg class-attribute instance-attribute
goal_vel_visualizer_cfg: VisualizationMarkersCfg = VisualizationMarkersCfg(prim_path='/Visuals/Command/velocity_goal', markers={'flight': UsdFileCfg(usd_path=f'{ISAAC_NUCLEUS_DIR}/Props/UIElements/arrow_x.usd', scale=(1.0, 0.1, 0.1), visual_material=PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0))), 'ground': UsdFileCfg(usd_path=f'{ISAAC_NUCLEUS_DIR}/Props/UIElements/arrow_x.usd', scale=(1.0, 0.1, 0.1), visual_material=PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0)))})

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg class-attribute instance-attribute
current_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_current')

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for velocity commands per mode.

Attributes:

Name Type Description
lin_vel_x tuple[float, float]

Range for the linear-x velocity command (in m/s).

lin_vel_y tuple[float, float]

Range for the linear-y velocity command (in m/s).

lin_vel_z tuple[float, float]

Range for the linear-z velocity command (in m/s).

ang_vel_z tuple[float, float]

Range for the angular-z velocity command (in rad/s).

heading tuple[float, float] | None

Range for the heading command (in rad). Defaults to None.

lin_vel_x class-attribute instance-attribute
lin_vel_x: tuple[float, float] = MISSING

Range for the linear-x velocity command (in m/s).

lin_vel_y class-attribute instance-attribute
lin_vel_y: tuple[float, float] = MISSING

Range for the linear-y velocity command (in m/s).

lin_vel_z class-attribute instance-attribute
lin_vel_z: tuple[float, float] = MISSING

Range for the linear-z velocity command (in m/s).

ang_vel_z class-attribute instance-attribute
ang_vel_z: tuple[float, float] = MISSING

Range for the angular-z velocity command (in rad/s).

heading class-attribute instance-attribute
heading: tuple[float, float] | None = None

Range for the heading command (in rad). Defaults to None.

This parameter is only used if :attr:~UniformBimodalVelocityCommandCfg.heading_command is True.

randomize_action_term_attr
randomize_action_term_attr(env, env_ids: Tensor | None, action_term_name: str = 'control_action', attr_name: str = '_flight_controller', **kwargs)

Randomize a selected action-term attribute.

randomize_controller_params
randomize_controller_params(env, env_ids: Tensor | None, action_term_name: str = 'control_action', controller_attr: str = '_flight_controller', gains: dict | None = None, limits: dict | None = None)

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

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

Randomize mixer parameters attached to an action term.

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

Randomize rotor 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.

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.

bimodal_action_tanh
bimodal_action_tanh(env: ManagerBasedRLEnv, std: float, command_name: str, flight_action_name: str = 'control_action', ground_action_name: str = 'track_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.

Parameters:

Name Type Description Default
env ManagerBasedRLEnv

The learning environment.

required
threshold float

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

required
sensor_cfg SceneEntityCfg

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

required
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'

Returns:

Type Description
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

Raises:

Type Description
ValueError

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

Examples:

>>> # 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.

actions

Classes:

Name Description
ControlAction

Body torque control action term.

ControlActionCfg

See :class:ControlAction for more details.

TrackControlAction

Track force control action term.

TrackControlActionCfg

See :class:ControlAction for more details.

ControlAction
ControlAction(cfg: ControlActionCfg, env: ManagerBasedRLEnv)

Bases: ActionTerm

Body torque control action term.

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

Attributes:

Name Type Description
cfg ControlActionCfg

The configuration of the action term.

cfg instance-attribute
cfg: ControlActionCfg = cfg

The configuration of the action term.

ControlActionCfg

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
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.

params VehicleParams

Vehicle parameters.

gains dict | None

Optional gains configuration for the flight controller. See FlightController for details.

limits dict | None

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

control_mode str

Control mode, options: cmd_motor_thrusts, cmd_motor_speeds, cmd_ctbm, cmd_ctbr, cmd_ctatt, cmd_vel, cmd_pos.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = ControlAction

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.

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. See FlightController for details.

limits class-attribute instance-attribute
limits: dict | None = None

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

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_vel, 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)

TrackControlAction
TrackControlAction(cfg: TrackControlActionCfg, env: ManagerBasedRLEnv)

Bases: ActionTerm

Track force control action term.

This action term converts normalized track commands into ground reaction forces applied on each track body.

Attributes:

Name Type Description
cfg TrackControlActionCfg

The configuration of the action term.

cfg instance-attribute
cfg: TrackControlActionCfg = cfg

The configuration of the action term.

TrackControlActionCfg

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
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.

params VehicleParams

Vehicle parameters.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = TrackControlAction

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.

params class-attribute instance-attribute
params: VehicleParams = VehicleParams()

Vehicle parameters.

commands

Classes:

Name Description
UniformPoseCommandGlobal

Command generator that generates pose commands containing a 3-D position and heading.

UniformPoseCommandGlobalCfg

Configuration for the uniform 3D-pose command generator.

UniformVelocityGlobalCommand

Command generator that generates a velocity command with uniform distribution.

UniformVelocityGlobalCommandCfg

Configuration for the uniform velocity command generator.

UniformBimodalVelocityCommand

Bimodal velocity command generator with a discrete mode indicator (4+1).

UniformBimodalVelocityCommandCfg

Configuration for the bimodal velocity command generator (flight vs ground).

UniformPoseCommandGlobal
UniformPoseCommandGlobal(cfg: UniformPoseCommandGlobalCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Command generator that generates pose commands containing a 3-D position and heading.

The command generator samples uniform 3D positions around the environment origin. The heading command is either set to point towards the target or is sampled uniformly. This can be configured through the :attr:UniformPoseCommandGlobalCfg.simple_heading parameter in the configuration.

Initialize the command generator class.

Parameters:

Name Type Description Default
cfg UniformPoseCommandGlobalCfg

The configuration parameters for the command generator.

required
env ManagerBasedEnv

The environment object.

required

Attributes:

Name Type Description
cfg UniformPoseCommandGlobalCfg

Configuration for the command generator.

command Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformPoseCommandGlobalCfg

Configuration for the command generator.

command property
command: Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

UniformPoseCommandGlobalCfg

Bases: CommandTermCfg

Configuration for the uniform 3D-pose command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
asset_name str

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

simple_heading bool

Whether to use simple heading or not.

ranges Ranges

Distribution ranges for the position commands.

goal_pose_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal pose visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

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

simple_heading class-attribute instance-attribute
simple_heading: bool = MISSING

Whether to use simple heading or not.

If True, the heading is in the direction of the target position.

ranges class-attribute instance-attribute
ranges: Ranges = MISSING

Distribution ranges for the position commands.

goal_pose_visualizer_cfg class-attribute instance-attribute
goal_pose_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/pose_goal')

The configuration for the goal pose visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
pos_x tuple[float, float]

Range for the x position (in m).

pos_y tuple[float, float]

Range for the y position (in m).

pos_z tuple[float, float]

Range for the z position (in m).

heading tuple[float, float]

Heading range for the position commands (in rad).

pos_x class-attribute instance-attribute
pos_x: tuple[float, float] = MISSING

Range for the x position (in m).

pos_y class-attribute instance-attribute
pos_y: tuple[float, float] = MISSING

Range for the y position (in m).

pos_z class-attribute instance-attribute
pos_z: tuple[float, float] = MISSING

Range for the z position (in m).

heading class-attribute instance-attribute
heading: tuple[float, float] = MISSING

Heading range for the position commands (in rad).

Used only if :attr:simple_heading is False.

UniformVelocityGlobalCommand
UniformVelocityGlobalCommand(cfg: UniformVelocityGlobalCommandCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Command generator that generates a velocity command with uniform distribution.

The command comprises linear velocity in x, y, z directions and an angular velocity around the z-axis. It is given in the robot's base frame.

If the :attr:cfg.heading_command flag is set to True, the angular velocity is computed from the heading error similar to doing a proportional control on the heading error. The target heading is sampled uniformly from the provided range. Otherwise, the angular velocity is sampled uniformly from the provided range.

Mathematically, the angular velocity is computed as follows from the heading command:

.. math::

\omega_z = \frac{1}{2} \text{wrap_to_pi}(\theta_{\text{target}} - \theta_{\text{current}})

Initialize the command generator.

Parameters:

Name Type Description Default
cfg UniformVelocityGlobalCommandCfg

The configuration of the command generator.

required
env ManagerBasedEnv

The environment.

required

Raises:

Type Description
ValueError

If the heading command is active but the heading range is not provided.

Methods:

Name Description
__str__

Return a string representation of the command generator.

Attributes:

Name Type Description
cfg UniformVelocityGlobalCommandCfg

The configuration of the command generator.

command Tensor

The desired base velocity command in the base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformVelocityGlobalCommandCfg

The configuration of the command generator.

command property
command: Tensor

The desired base velocity command in the base frame. Shape is (num_envs, 4).

__str__
__str__() -> str

Return a string representation of the command generator.

UniformVelocityGlobalCommandCfg

Bases: CommandTermCfg

Configuration for the uniform velocity command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the velocity commands.

Attributes:

Name Type Description
asset_name str

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

heading_command bool

Whether to use heading command or angular velocity command. Defaults to False.

heading_control_stiffness float

Scale factor to convert the heading error to angular velocity command. Defaults to 1.0.

rel_standing_envs float

The sampled probability of environments that should be standing still. Defaults to 0.0.

rel_heading_envs float

The sampled probability of environments where the robots follow the heading-based angular velocity command

ranges Ranges

Distribution ranges for the velocity commands.

goal_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

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

heading_command class-attribute instance-attribute
heading_command: bool = False

Whether to use heading command or angular velocity command. Defaults to False.

If True, the angular velocity command is computed from the heading error, where the target heading is sampled uniformly from provided range. Otherwise, the angular velocity command is sampled uniformly from provided range.

heading_control_stiffness class-attribute instance-attribute
heading_control_stiffness: float = 1.0

Scale factor to convert the heading error to angular velocity command. Defaults to 1.0.

rel_standing_envs class-attribute instance-attribute
rel_standing_envs: float = 0.0

The sampled probability of environments that should be standing still. Defaults to 0.0.

rel_heading_envs class-attribute instance-attribute
rel_heading_envs: float = 1.0

The sampled probability of environments where the robots follow the heading-based angular velocity command (the others follow the sampled angular velocity command). Defaults to 1.0.

This parameter is only used if :attr:heading_command is True.

ranges class-attribute instance-attribute
ranges: Ranges = MISSING

Distribution ranges for the velocity commands.

goal_vel_visualizer_cfg class-attribute instance-attribute
goal_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_goal')

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg class-attribute instance-attribute
current_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_current')

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for the velocity commands.

Attributes:

Name Type Description
lin_vel_x tuple[float, float]

Range for the linear-x velocity command (in m/s).

lin_vel_y tuple[float, float]

Range for the linear-y velocity command (in m/s).

lin_vel_z tuple[float, float]

Range for the linear-z velocity command (in m/s).

ang_vel_z tuple[float, float]

Range for the angular-z velocity command (in rad/s).

heading tuple[float, float] | None

Range for the heading command (in rad). Defaults to None.

lin_vel_x class-attribute instance-attribute
lin_vel_x: tuple[float, float] = MISSING

Range for the linear-x velocity command (in m/s).

lin_vel_y class-attribute instance-attribute
lin_vel_y: tuple[float, float] = MISSING

Range for the linear-y velocity command (in m/s).

lin_vel_z class-attribute instance-attribute
lin_vel_z: tuple[float, float] = MISSING

Range for the linear-z velocity command (in m/s).

ang_vel_z class-attribute instance-attribute
ang_vel_z: tuple[float, float] = MISSING

Range for the angular-z velocity command (in rad/s).

heading class-attribute instance-attribute
heading: tuple[float, float] | None = None

Range for the heading command (in rad). Defaults to None.

This parameter is only used if :attr:~UniformVelocityGlobalCommandCfg.heading_command is True.

UniformBimodalVelocityCommand
UniformBimodalVelocityCommand(cfg: UniformBimodalVelocityCommandCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Bimodal velocity command generator with a discrete mode indicator (4+1).

This command samples base-frame velocities with two modes: - Flight mode: uses ranges_flight - Ground mode: uses ranges_ground

The output command augments the 4-D velocity with a 1-D discrete indicator: - 0.0 for flight mode - 1.0 for ground/terrestrial mode

Heading behavior matches UniformVelocityGlobalCommand with optional heading-target proportional control. Ranges are applied per selected mode.

Attributes:

Name Type Description
command Tensor

Return 4-D velocity plus 1-D mode indicator. Shape: (num_envs, 5).

command property
command: Tensor

Return 4-D velocity plus 1-D mode indicator. Shape: (num_envs, 5).

UniformBimodalVelocityCommandCfg

Bases: CommandTermCfg

Configuration for the bimodal velocity command generator (flight vs ground).

Classes:

Name Description
Ranges

Uniform distribution ranges for velocity commands per mode.

Attributes:

Name Type Description
asset_name str

Name of the asset receiving commands.

heading_command bool

Whether to convert heading error to angular velocity (per-mode ranges apply).

heading_control_stiffness float

Scale factor for heading error to yaw rate conversion.

rel_standing_envs float

Probability that an environment should be standing still (zero command).

rel_heading_envs float

Probability that an environment uses heading-based angular velocity when enabled.

rel_flight_envs float

Probability of sampling flight mode (vs ground).

ranges_flight Ranges

Ranges for flight mode sampling.

ranges_ground Ranges

Ranges for ground/terrestrial mode sampling.

goal_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

Name of the asset receiving commands.

heading_command class-attribute instance-attribute
heading_command: bool = False

Whether to convert heading error to angular velocity (per-mode ranges apply).

heading_control_stiffness class-attribute instance-attribute
heading_control_stiffness: float = 1.0

Scale factor for heading error to yaw rate conversion.

rel_standing_envs class-attribute instance-attribute
rel_standing_envs: float = 0.0

Probability that an environment should be standing still (zero command).

rel_heading_envs class-attribute instance-attribute
rel_heading_envs: float = 1.0

Probability that an environment uses heading-based angular velocity when enabled.

rel_flight_envs class-attribute instance-attribute
rel_flight_envs: float = 0.5

Probability of sampling flight mode (vs ground).

ranges_flight class-attribute instance-attribute
ranges_flight: Ranges = MISSING

Ranges for flight mode sampling.

ranges_ground class-attribute instance-attribute
ranges_ground: Ranges = MISSING

Ranges for ground/terrestrial mode sampling.

goal_vel_visualizer_cfg class-attribute instance-attribute
goal_vel_visualizer_cfg: VisualizationMarkersCfg = VisualizationMarkersCfg(prim_path='/Visuals/Command/velocity_goal', markers={'flight': UsdFileCfg(usd_path=f'{ISAAC_NUCLEUS_DIR}/Props/UIElements/arrow_x.usd', scale=(1.0, 0.1, 0.1), visual_material=PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0))), 'ground': UsdFileCfg(usd_path=f'{ISAAC_NUCLEUS_DIR}/Props/UIElements/arrow_x.usd', scale=(1.0, 0.1, 0.1), visual_material=PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0)))})

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg class-attribute instance-attribute
current_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_current')

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for velocity commands per mode.

Attributes:

Name Type Description
lin_vel_x tuple[float, float]

Range for the linear-x velocity command (in m/s).

lin_vel_y tuple[float, float]

Range for the linear-y velocity command (in m/s).

lin_vel_z tuple[float, float]

Range for the linear-z velocity command (in m/s).

ang_vel_z tuple[float, float]

Range for the angular-z velocity command (in rad/s).

heading tuple[float, float] | None

Range for the heading command (in rad). Defaults to None.

lin_vel_x class-attribute instance-attribute
lin_vel_x: tuple[float, float] = MISSING

Range for the linear-x velocity command (in m/s).

lin_vel_y class-attribute instance-attribute
lin_vel_y: tuple[float, float] = MISSING

Range for the linear-y velocity command (in m/s).

lin_vel_z class-attribute instance-attribute
lin_vel_z: tuple[float, float] = MISSING

Range for the linear-z velocity command (in m/s).

ang_vel_z class-attribute instance-attribute
ang_vel_z: tuple[float, float] = MISSING

Range for the angular-z velocity command (in rad/s).

heading class-attribute instance-attribute
heading: tuple[float, float] | None = None

Range for the heading command (in rad). Defaults to None.

This parameter is only used if :attr:~UniformBimodalVelocityCommandCfg.heading_command is True.

events

Functions:

Name Description
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_action_term_attr
randomize_action_term_attr(env, env_ids: Tensor | None, action_term_name: str = 'control_action', attr_name: str = '_flight_controller', **kwargs)

Randomize a selected action-term attribute.

randomize_controller_params
randomize_controller_params(env, env_ids: Tensor | None, action_term_name: str = 'control_action', controller_attr: str = '_flight_controller', gains: dict | None = None, limits: dict | None = None)

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

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

Randomize mixer parameters attached to an action term.

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

Randomize rotor parameters attached to an action term.

observations

Functions:

Name Description
target_pos_b

Position of target in body frame.

root_euler_w

Euler angles of the root in world frame.

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.

rewards

Functions:

Name Description
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.

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.

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.

bimodal_action_tanh
bimodal_action_tanh(env: ManagerBasedRLEnv, std: float, command_name: str, flight_action_name: str = 'control_action', ground_action_name: str = 'track_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.

Parameters:

Name Type Description Default
env ManagerBasedRLEnv

The learning environment.

required
threshold float

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

required
sensor_cfg SceneEntityCfg

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

required
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'

Returns:

Type Description
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

Raises:

Type Description
ValueError

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

Examples:

>>> # 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.

terminations

Functions:

Name Description
died

Termination condition based on the robot's height.

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.

LAV2_base_direct

Modules:

Name Description
quadcopter_env
quadcopter_env

Classes:

Name Description
QuadcopterEnvWindow

Window manager for the Quadcopter environment.

QuadcopterEnvWindow
QuadcopterEnvWindow(env: QuadcopterEnv, window_name: str = 'IsaacLab')

Bases: BaseEnvWindow

Window manager for the Quadcopter environment.

Initialize the window.

Parameters:

Name Type Description Default
env QuadcopterEnv

The environment object.

required
window_name str

The name of the window. Defaults to "IsaacLab".

'IsaacLab'

LAV2_navrl

Modules:

Name Description
LAV2_navrl_env
LAV2_navrl_env

Classes:

Name Description
LAV2NavRLEnvWindow

Window manager for the Quadcopter environment.

LAV2NavRLEnvWindow
LAV2NavRLEnvWindow(env: LAV2NavRLEnv, window_name: str = 'IsaacLab')

Bases: BaseEnvWindow

Window manager for the Quadcopter environment.

Initialize the window.

Parameters:

Name Type Description Default
env LAV2NavRLEnv

The environment object.

required
window_name str

The name of the window. Defaults to "IsaacLab".

'IsaacLab'

LAV2_trajectory

Modules:

Name Description
LAV2_traj_env_cfg
mdp
LAV2_traj_env_cfg

Classes:

Name Description
ActionsCfg

Action specifications for the MDP.

EventCfg

Configuration for events.

TerminationsCfg

Termination terms for the MDP.

ActionsCfg

Action specifications for the MDP.

EventCfg

Configuration for events.

TerminationsCfg

Termination terms for the MDP.

mdp

Modules:

Name Description
commands

Classes:

Name Description
FlightActionMapper

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

FlightMappingLimits

Per-channel limits used when mapping normalized actions to targets.

Mixer

Map thrust and moment demands to rotor commands.

FlightController

PID flight controller (batched).

VehicleParams

LAV2 vehicle parameters.

RotorDynamics

Batched rotor dynamics model.

TrackDynamics

Batched track dynamics model.

ControlAction

Body torque control action term.

ControlActionCfg

See :class:ControlAction for more details.

TrackControlAction

Track force control action term.

TrackControlActionCfg

See :class:ControlAction for more details.

UniformPoseCommandGlobal

Command generator that generates pose commands containing a 3-D position and heading.

UniformPoseCommandGlobalCfg

Configuration for the uniform 3D-pose command generator.

UniformVelocityGlobalCommand

Command generator that generates a velocity command with uniform distribution.

UniformVelocityGlobalCommandCfg

Configuration for the uniform velocity command generator.

UniformBimodalVelocityCommand

Bimodal velocity command generator with a discrete mode indicator (4+1).

UniformBimodalVelocityCommandCfg

Configuration for the bimodal velocity command generator (flight vs ground).

HelixTrajectory

Batched helix trajectory with optional vertical oscillation.

LemniscateTrajectory

Batched Bernoulli lemniscate trajectory with vertical oscillation.

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.

Functions:

Name Description
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.

target_pos_b

Position of target in body frame.

root_euler_w

Euler angles of the root in world frame.

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.

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.

FlightActionMapper
FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), limits: FlightMappingLimits = FlightMappingLimits(), *, num_envs: int = 1, device: str | device = 'cpu')

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

Initialize a batched Torch flight action mapper for the selected mode.

Methods:

Name Description
map_action

Map a normalized batched action into RPM commands and intermediates.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller target expansion step.

requires_controller property
requires_controller: bool

Whether this mode needs a controller target expansion step.

map_action
map_action(action: Tensor, mixer: Mixer, *, state: Tensor | None = None, flight_controller: ControllerBase | None = None) -> FlightMappingResult

Map a normalized batched action into RPM commands and intermediates.

FlightMappingLimits dataclass
FlightMappingLimits(vel_limits: tuple[float, float, float] = (5.0, 5.0, 5.0), att_limits: tuple[float, float, float] = (1.0, 1.0, math.pi), br_limits: tuple[float, float, float] = (2.0, 2.0, 2.0))

Per-channel limits used when mapping normalized actions to targets.

Mixer
Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the torch mixer with vehicle parameters and device.

Methods:

Name Description
randomize

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

randomize
randomize(env_ids=None, randomization=None)

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve
apply_thrust_curve(normalized_thrust: Tensor, mode: int = 1) -> torch.Tensor

Apply thrust curve to normalized thrust command.

References

cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137 cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

Parameters:

Name Type Description Default
normalized_thrust Tensor

Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise.

required
mode int

Thrust curve mode.

1

Returns:

Type Description
Tensor

torch.Tensor: Thrust in Newtons with the same shape as normalized_thrust.

Raises:

Type Description
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands
calculate_rotor_commands(control: Tensor) -> torch.Tensor

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default
control Tensor

Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). Shape: (num_envs, 4)

FlightController
FlightController(params: VehicleParams = VehicleParams(), control_mask: list[int] = [1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0], gains: dict | None = None, limits: dict | None = None, num_envs: int = 1, device: str | device = 'cpu')

Bases: ControllerBase

PID flight controller (batched).

Initialize the batched flight PID controller.

Methods:

Name Description
randomize

Randomize configured PID gains and command limits for selected environments.

reset

Reset PID loops for selected environments.

update

Update controller.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the controller.

control_mask ndarray | Tensor

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the controller.

control_mask instance-attribute
control_mask: ndarray | Tensor = control_mask

unified control mask for target/state channels, used in update(). e.g. using 9~11 for attitude yaw control.

randomize
randomize(env_ids=None, gains=None, limits=None)

Randomize configured PID gains and command limits for selected environments.

reset
reset(env_ids)

Reset PID loops for selected environments.

update
update(target: Tensor, state: Tensor) -> torch.Tensor

Update controller.

Parameters:

Name Type Description Default
target Tensor

(N, 12) desired [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz]

required
state Tensor

(N, 12) current state same ordering.

required

Returns:

Type Description
Tensor

torch.Tensor: Tensor of shape (N, 4): [thrust, roll_moment, pitch_moment, yaw_moment].

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: np.diag([0.11, 0.108, 0.215]).tolist())(), diameter: float = 0.476, Cdx: float = 0.5, x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = 8 * (np.pi / 180), r_p: float = 0.0775, J_m: float = 1e-05, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = 14.6 * (np.pi / 180), thetaTip: float = 6.8 * (np.pi / 180), lock: float = 0.6051, max_rpm: float = 10000.0, init_rpm: float = -1.0, rotor_rpm_rate_limit: float = 50000.0, tau_f: float = 0.01, tau_m: float = 0.05, tau_up: float = -1.0, tau_down: float = -1.0, r_w: float = 0.0285, n_w: int = 4, B: float = 0.136, L: float = 0.23, h_cg: float = 0.078, f: float = 0.01, mu0: float = 0.8, K: float = 20, track_cmd_rate_limit: float = 100, min_throttle_manual: float = 0.08, min_throttle: float = 0.12, max_throttle: float = 1.0, hover_throttle: float = -1)

LAV2 vehicle parameters.

Methods:

Name Description
__post_init__

Calculate derived parameters.

Attributes:

Name Type Description
rho float

空气密度 (kg/m^3)

g float

重力加速度 (m/s^2)

sim_dt float

仿真步长 (s)

step_dt float

控制步长 (s)

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

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass float

质量 (kg)

inertia list

惯性矩阵 (kg*m^2)

diameter float

直径 (m)

Cdx float

空气阻力系数

x float

x方向臂长 (m)

y float

y方向臂长 (m)

h float

重心高度 (m)

alpha float

y方向涵道外倾角度 (rad)

r_p float

螺旋桨半径 (m)

J_m float

电机转动惯量 (kg*m^2)

Ct float

推力系数

Cq float

扭矩系数

theta0 float

桨根角 (rad)

thetaTip float

桨尖角 (rad)

theta1 float

桨叶扭转角 (rad)

lock float

Lock number

max_rpm float

最大转速

init_rpm float

初始转速

rotor_rpm_rate_limit float

旋翼转速变化率限制 (rpm/s)

cT float

转速平方到推力增益 (N/(rpm^2))

cM float

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f float

电机滤波时间常数 (s)

tau_m float

兼容保留的电机时间常数 (s)

tau_up float

电机升速时间常数 (s)

tau_down float

电机降速时间常数 (s)

r_w float

主动轮半径 (m)

n_w int

负重轮个数

B float

两侧履带中心距 (m)

L float

履带节点接地部分长度 (m)

h_cg float

车体质心高度 (m)

f float

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 float

滑转率为1时的摩擦系数

K float

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit float

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual float

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle float

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle float

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle float

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

rho class-attribute instance-attribute
rho: float = 1.184

空气密度 (kg/m^3)

g class-attribute instance-attribute
g: float = 9.81

重力加速度 (m/s^2)

sim_dt class-attribute instance-attribute
sim_dt: float = 0.01

仿真步长 (s)

step_dt class-attribute instance-attribute
step_dt: float = 0.01

控制步长 (s)

randomization class-attribute instance-attribute
randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass class-attribute instance-attribute
mass: float = 2.1

质量 (kg)

inertia class-attribute instance-attribute
inertia: list = field(default_factory=lambda: tolist())

惯性矩阵 (kg*m^2)

diameter class-attribute instance-attribute
diameter: float = 0.476

直径 (m)

Cdx class-attribute instance-attribute
Cdx: float = 0.5

空气阻力系数

x class-attribute instance-attribute
x: float = 0.0952

x方向臂长 (m)

y class-attribute instance-attribute
y: float = 0.114423

y方向臂长 (m)

h class-attribute instance-attribute
h: float = -0.0125

重心高度 (m)

alpha class-attribute instance-attribute
alpha: float = 8 * (pi / 180)

y方向涵道外倾角度 (rad)

r_p class-attribute instance-attribute
r_p: float = 0.0775

螺旋桨半径 (m)

J_m class-attribute instance-attribute
J_m: float = 1e-05

电机转动惯量 (kg*m^2)

Ct class-attribute instance-attribute
Ct: float = 0.666

推力系数

Cq class-attribute instance-attribute
Cq: float = 0.0716

扭矩系数

theta0 class-attribute instance-attribute
theta0: float = 14.6 * (pi / 180)

桨根角 (rad)

thetaTip class-attribute instance-attribute
thetaTip: float = 6.8 * (pi / 180)

桨尖角 (rad)

theta1 class-attribute instance-attribute
theta1: float = field(init=False)

桨叶扭转角 (rad)

lock class-attribute instance-attribute
lock: float = 0.6051

Lock number

max_rpm class-attribute instance-attribute
max_rpm: float = 10000.0

最大转速

init_rpm class-attribute instance-attribute
init_rpm: float = -1.0

初始转速

rotor_rpm_rate_limit class-attribute instance-attribute
rotor_rpm_rate_limit: float = 50000.0

旋翼转速变化率限制 (rpm/s)

cT class-attribute instance-attribute
cT: float = field(init=False)

转速平方到推力增益 (N/(rpm^2))

cM class-attribute instance-attribute
cM: float = field(init=False)

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f class-attribute instance-attribute
tau_f: float = 0.01

电机滤波时间常数 (s)

tau_m class-attribute instance-attribute
tau_m: float = 0.05

兼容保留的电机时间常数 (s)

tau_up class-attribute instance-attribute
tau_up: float = -1.0

电机升速时间常数 (s)

tau_down class-attribute instance-attribute
tau_down: float = -1.0

电机降速时间常数 (s)

r_w class-attribute instance-attribute
r_w: float = 0.0285

主动轮半径 (m)

n_w class-attribute instance-attribute
n_w: int = 4

负重轮个数

B class-attribute instance-attribute
B: float = 0.136

两侧履带中心距 (m)

L class-attribute instance-attribute
L: float = 0.23

履带节点接地部分长度 (m)

h_cg class-attribute instance-attribute
h_cg: float = 0.078

车体质心高度 (m)

f class-attribute instance-attribute
f: float = 0.01

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 class-attribute instance-attribute
mu0: float = 0.8

滑转率为1时的摩擦系数

K class-attribute instance-attribute
K: float = 20

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit class-attribute instance-attribute
track_cmd_rate_limit: float = 100

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual class-attribute instance-attribute
min_throttle_manual: float = 0.08

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle class-attribute instance-attribute
min_throttle: float = 0.12

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle class-attribute instance-attribute
max_throttle: float = 1.0

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle class-attribute instance-attribute
hover_throttle: float = -1

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

__post_init__
__post_init__()

Calculate derived parameters.

RotorDynamics
RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched rotor dynamics model.

Initialize batched rotor dynamics on the specified device.

Methods:

Name Description
randomize

Randomize rotor runtime parameters from nominal values.

update

Calculate the output thrust and torque for each motor based on the motor commands.

reset

Resets the rotor model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

randomize
randomize(env_ids: slice | Sequence[int] | Tensor | None = None, randomization: dict[str, tuple[float, float]] | None = None) -> None

Randomize rotor runtime parameters from nominal values.

update
update(commands: Tensor) -> torch.Tensor

Calculate the output thrust and torque for each motor based on the motor commands.

Parameters:

Name Type Description Default
commands Tensor

Command tensor for each motor. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: Thrust and torque tensor for each motor. Shape: (num_envs, 8)

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the rotor model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required
TrackDynamics
TrackDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched track dynamics model.

Initialize batched track dynamics on the specified device.

Methods:

Name Description
update

Compute track forces for batched environments.

reset

Resets the track model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

update
update(commands: Tensor, state: Tensor) -> torch.Tensor

Compute track forces for batched environments.

Parameters:

Name Type Description Default
commands Tensor

Shape (num_envs, 2) track commands [left, right].

required
state Tensor

Shape (num_envs, 3) body-frame velocities [u, v, r].

required

Returns:

Type Description
Tensor

torch.Tensor: Tensor of shape (num_envs, 2, n_w, 2) [side, wheel, (Fx, Fy)].

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the track model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required
ControlAction
ControlAction(cfg: ControlActionCfg, env: ManagerBasedRLEnv)

Bases: ActionTerm

Body torque control action term.

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

Attributes:

Name Type Description
cfg ControlActionCfg

The configuration of the action term.

cfg instance-attribute
cfg: ControlActionCfg = cfg

The configuration of the action term.

ControlActionCfg

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
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.

params VehicleParams

Vehicle parameters.

gains dict | None

Optional gains configuration for the flight controller. See FlightController for details.

limits dict | None

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

control_mode str

Control mode, options: cmd_motor_thrusts, cmd_motor_speeds, cmd_ctbm, cmd_ctbr, cmd_ctatt, cmd_vel, cmd_pos.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = ControlAction

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.

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. See FlightController for details.

limits class-attribute instance-attribute
limits: dict | None = None

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

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_vel, 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)

TrackControlAction
TrackControlAction(cfg: TrackControlActionCfg, env: ManagerBasedRLEnv)

Bases: ActionTerm

Track force control action term.

This action term converts normalized track commands into ground reaction forces applied on each track body.

Attributes:

Name Type Description
cfg TrackControlActionCfg

The configuration of the action term.

cfg instance-attribute
cfg: TrackControlActionCfg = cfg

The configuration of the action term.

TrackControlActionCfg

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
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.

params VehicleParams

Vehicle parameters.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = TrackControlAction

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.

params class-attribute instance-attribute
params: VehicleParams = VehicleParams()

Vehicle parameters.

UniformPoseCommandGlobal
UniformPoseCommandGlobal(cfg: UniformPoseCommandGlobalCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Command generator that generates pose commands containing a 3-D position and heading.

The command generator samples uniform 3D positions around the environment origin. The heading command is either set to point towards the target or is sampled uniformly. This can be configured through the :attr:UniformPoseCommandGlobalCfg.simple_heading parameter in the configuration.

Initialize the command generator class.

Parameters:

Name Type Description Default
cfg UniformPoseCommandGlobalCfg

The configuration parameters for the command generator.

required
env ManagerBasedEnv

The environment object.

required

Attributes:

Name Type Description
cfg UniformPoseCommandGlobalCfg

Configuration for the command generator.

command Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformPoseCommandGlobalCfg

Configuration for the command generator.

command property
command: Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

UniformPoseCommandGlobalCfg

Bases: CommandTermCfg

Configuration for the uniform 3D-pose command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
asset_name str

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

simple_heading bool

Whether to use simple heading or not.

ranges Ranges

Distribution ranges for the position commands.

goal_pose_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal pose visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

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

simple_heading class-attribute instance-attribute
simple_heading: bool = MISSING

Whether to use simple heading or not.

If True, the heading is in the direction of the target position.

ranges class-attribute instance-attribute
ranges: Ranges = MISSING

Distribution ranges for the position commands.

goal_pose_visualizer_cfg class-attribute instance-attribute
goal_pose_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/pose_goal')

The configuration for the goal pose visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
pos_x tuple[float, float]

Range for the x position (in m).

pos_y tuple[float, float]

Range for the y position (in m).

pos_z tuple[float, float]

Range for the z position (in m).

heading tuple[float, float]

Heading range for the position commands (in rad).

pos_x class-attribute instance-attribute
pos_x: tuple[float, float] = MISSING

Range for the x position (in m).

pos_y class-attribute instance-attribute
pos_y: tuple[float, float] = MISSING

Range for the y position (in m).

pos_z class-attribute instance-attribute
pos_z: tuple[float, float] = MISSING

Range for the z position (in m).

heading class-attribute instance-attribute
heading: tuple[float, float] = MISSING

Heading range for the position commands (in rad).

Used only if :attr:simple_heading is False.

UniformVelocityGlobalCommand
UniformVelocityGlobalCommand(cfg: UniformVelocityGlobalCommandCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Command generator that generates a velocity command with uniform distribution.

The command comprises linear velocity in x, y, z directions and an angular velocity around the z-axis. It is given in the robot's base frame.

If the :attr:cfg.heading_command flag is set to True, the angular velocity is computed from the heading error similar to doing a proportional control on the heading error. The target heading is sampled uniformly from the provided range. Otherwise, the angular velocity is sampled uniformly from the provided range.

Mathematically, the angular velocity is computed as follows from the heading command:

.. math::

\omega_z = \frac{1}{2} \text{wrap_to_pi}(\theta_{\text{target}} - \theta_{\text{current}})

Initialize the command generator.

Parameters:

Name Type Description Default
cfg UniformVelocityGlobalCommandCfg

The configuration of the command generator.

required
env ManagerBasedEnv

The environment.

required

Raises:

Type Description
ValueError

If the heading command is active but the heading range is not provided.

Methods:

Name Description
__str__

Return a string representation of the command generator.

Attributes:

Name Type Description
cfg UniformVelocityGlobalCommandCfg

The configuration of the command generator.

command Tensor

The desired base velocity command in the base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformVelocityGlobalCommandCfg

The configuration of the command generator.

command property
command: Tensor

The desired base velocity command in the base frame. Shape is (num_envs, 4).

__str__
__str__() -> str

Return a string representation of the command generator.

UniformVelocityGlobalCommandCfg

Bases: CommandTermCfg

Configuration for the uniform velocity command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the velocity commands.

Attributes:

Name Type Description
asset_name str

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

heading_command bool

Whether to use heading command or angular velocity command. Defaults to False.

heading_control_stiffness float

Scale factor to convert the heading error to angular velocity command. Defaults to 1.0.

rel_standing_envs float

The sampled probability of environments that should be standing still. Defaults to 0.0.

rel_heading_envs float

The sampled probability of environments where the robots follow the heading-based angular velocity command

ranges Ranges

Distribution ranges for the velocity commands.

goal_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

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

heading_command class-attribute instance-attribute
heading_command: bool = False

Whether to use heading command or angular velocity command. Defaults to False.

If True, the angular velocity command is computed from the heading error, where the target heading is sampled uniformly from provided range. Otherwise, the angular velocity command is sampled uniformly from provided range.

heading_control_stiffness class-attribute instance-attribute
heading_control_stiffness: float = 1.0

Scale factor to convert the heading error to angular velocity command. Defaults to 1.0.

rel_standing_envs class-attribute instance-attribute
rel_standing_envs: float = 0.0

The sampled probability of environments that should be standing still. Defaults to 0.0.

rel_heading_envs class-attribute instance-attribute
rel_heading_envs: float = 1.0

The sampled probability of environments where the robots follow the heading-based angular velocity command (the others follow the sampled angular velocity command). Defaults to 1.0.

This parameter is only used if :attr:heading_command is True.

ranges class-attribute instance-attribute
ranges: Ranges = MISSING

Distribution ranges for the velocity commands.

goal_vel_visualizer_cfg class-attribute instance-attribute
goal_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_goal')

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg class-attribute instance-attribute
current_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_current')

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for the velocity commands.

Attributes:

Name Type Description
lin_vel_x tuple[float, float]

Range for the linear-x velocity command (in m/s).

lin_vel_y tuple[float, float]

Range for the linear-y velocity command (in m/s).

lin_vel_z tuple[float, float]

Range for the linear-z velocity command (in m/s).

ang_vel_z tuple[float, float]

Range for the angular-z velocity command (in rad/s).

heading tuple[float, float] | None

Range for the heading command (in rad). Defaults to None.

lin_vel_x class-attribute instance-attribute
lin_vel_x: tuple[float, float] = MISSING

Range for the linear-x velocity command (in m/s).

lin_vel_y class-attribute instance-attribute
lin_vel_y: tuple[float, float] = MISSING

Range for the linear-y velocity command (in m/s).

lin_vel_z class-attribute instance-attribute
lin_vel_z: tuple[float, float] = MISSING

Range for the linear-z velocity command (in m/s).

ang_vel_z class-attribute instance-attribute
ang_vel_z: tuple[float, float] = MISSING

Range for the angular-z velocity command (in rad/s).

heading class-attribute instance-attribute
heading: tuple[float, float] | None = None

Range for the heading command (in rad). Defaults to None.

This parameter is only used if :attr:~UniformVelocityGlobalCommandCfg.heading_command is True.

UniformBimodalVelocityCommand
UniformBimodalVelocityCommand(cfg: UniformBimodalVelocityCommandCfg, env: ManagerBasedEnv)

Bases: CommandTerm

Bimodal velocity command generator with a discrete mode indicator (4+1).

This command samples base-frame velocities with two modes: - Flight mode: uses ranges_flight - Ground mode: uses ranges_ground

The output command augments the 4-D velocity with a 1-D discrete indicator: - 0.0 for flight mode - 1.0 for ground/terrestrial mode

Heading behavior matches UniformVelocityGlobalCommand with optional heading-target proportional control. Ranges are applied per selected mode.

Attributes:

Name Type Description
command Tensor

Return 4-D velocity plus 1-D mode indicator. Shape: (num_envs, 5).

command property
command: Tensor

Return 4-D velocity plus 1-D mode indicator. Shape: (num_envs, 5).

UniformBimodalVelocityCommandCfg

Bases: CommandTermCfg

Configuration for the bimodal velocity command generator (flight vs ground).

Classes:

Name Description
Ranges

Uniform distribution ranges for velocity commands per mode.

Attributes:

Name Type Description
asset_name str

Name of the asset receiving commands.

heading_command bool

Whether to convert heading error to angular velocity (per-mode ranges apply).

heading_control_stiffness float

Scale factor for heading error to yaw rate conversion.

rel_standing_envs float

Probability that an environment should be standing still (zero command).

rel_heading_envs float

Probability that an environment uses heading-based angular velocity when enabled.

rel_flight_envs float

Probability of sampling flight mode (vs ground).

ranges_flight Ranges

Ranges for flight mode sampling.

ranges_ground Ranges

Ranges for ground/terrestrial mode sampling.

goal_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg VisualizationMarkersCfg

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

asset_name class-attribute instance-attribute
asset_name: str = MISSING

Name of the asset receiving commands.

heading_command class-attribute instance-attribute
heading_command: bool = False

Whether to convert heading error to angular velocity (per-mode ranges apply).

heading_control_stiffness class-attribute instance-attribute
heading_control_stiffness: float = 1.0

Scale factor for heading error to yaw rate conversion.

rel_standing_envs class-attribute instance-attribute
rel_standing_envs: float = 0.0

Probability that an environment should be standing still (zero command).

rel_heading_envs class-attribute instance-attribute
rel_heading_envs: float = 1.0

Probability that an environment uses heading-based angular velocity when enabled.

rel_flight_envs class-attribute instance-attribute
rel_flight_envs: float = 0.5

Probability of sampling flight mode (vs ground).

ranges_flight class-attribute instance-attribute
ranges_flight: Ranges = MISSING

Ranges for flight mode sampling.

ranges_ground class-attribute instance-attribute
ranges_ground: Ranges = MISSING

Ranges for ground/terrestrial mode sampling.

goal_vel_visualizer_cfg class-attribute instance-attribute
goal_vel_visualizer_cfg: VisualizationMarkersCfg = VisualizationMarkersCfg(prim_path='/Visuals/Command/velocity_goal', markers={'flight': UsdFileCfg(usd_path=f'{ISAAC_NUCLEUS_DIR}/Props/UIElements/arrow_x.usd', scale=(1.0, 0.1, 0.1), visual_material=PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0))), 'ground': UsdFileCfg(usd_path=f'{ISAAC_NUCLEUS_DIR}/Props/UIElements/arrow_x.usd', scale=(1.0, 0.1, 0.1), visual_material=PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0)))})

The configuration for the goal velocity visualization marker. Defaults to GREEN_ARROW_X_MARKER_CFG.

current_vel_visualizer_cfg class-attribute instance-attribute
current_vel_visualizer_cfg: VisualizationMarkersCfg = replace(prim_path='/Visuals/Command/velocity_current')

The configuration for the current velocity visualization marker. Defaults to BLUE_ARROW_X_MARKER_CFG.

Ranges

Uniform distribution ranges for velocity commands per mode.

Attributes:

Name Type Description
lin_vel_x tuple[float, float]

Range for the linear-x velocity command (in m/s).

lin_vel_y tuple[float, float]

Range for the linear-y velocity command (in m/s).

lin_vel_z tuple[float, float]

Range for the linear-z velocity command (in m/s).

ang_vel_z tuple[float, float]

Range for the angular-z velocity command (in rad/s).

heading tuple[float, float] | None

Range for the heading command (in rad). Defaults to None.

lin_vel_x class-attribute instance-attribute
lin_vel_x: tuple[float, float] = MISSING

Range for the linear-x velocity command (in m/s).

lin_vel_y class-attribute instance-attribute
lin_vel_y: tuple[float, float] = MISSING

Range for the linear-y velocity command (in m/s).

lin_vel_z class-attribute instance-attribute
lin_vel_z: tuple[float, float] = MISSING

Range for the linear-z velocity command (in m/s).

ang_vel_z class-attribute instance-attribute
ang_vel_z: tuple[float, float] = MISSING

Range for the angular-z velocity command (in rad/s).

heading class-attribute instance-attribute
heading: tuple[float, float] | None = None

Range for the heading command (in rad). Defaults to None.

This parameter is only used if :attr:~UniformBimodalVelocityCommandCfg.heading_command is True.

HelixTrajectory dataclass
HelixTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, radius: Tensor, omega: Tensor, z_amplitude: Tensor, z_frequency: Tensor, z_phase: Tensor)

Bases: SpatialTrajectory

Batched helix trajectory with optional vertical oscillation.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched helix trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched helix trajectory at time values t.

LemniscateTrajectory dataclass
LemniscateTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, scale: Tensor, omega: Tensor, z_amplitude: Tensor, z_frequency: Tensor, z_phase: Tensor)

Bases: SpatialTrajectory

Batched Bernoulli lemniscate trajectory with vertical oscillation.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched lemniscate trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched lemniscate trajectory at time values t.

LissajousTrajectory dataclass
LissajousTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, amplitude: Tensor, frequency: Tensor, phase: Tensor, omega: Tensor)

Bases: SpatialTrajectory

Batched three-dimensional Lissajous trajectory.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched Lissajous trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched Lissajous trajectory at time values t.

RectangleTrajectory dataclass
RectangleTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, size: Tensor, speed: Tensor)

Bases: SpatialTrajectory

Batched constant-speed rectangle trajectory in the horizontal plane.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched rectangle trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched rectangle trajectory at time values t.

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, env_ids: Tensor | None, action_term_name: str = 'control_action', attr_name: str = '_flight_controller', **kwargs)

Randomize a selected action-term attribute.

randomize_controller_params
randomize_controller_params(env, env_ids: Tensor | None, action_term_name: str = 'control_action', controller_attr: str = '_flight_controller', gains: dict | None = None, limits: dict | None = None)

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

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

Randomize mixer parameters attached to an action term.

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

Randomize rotor 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.

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.

bimodal_action_tanh
bimodal_action_tanh(env: ManagerBasedRLEnv, std: float, command_name: str, flight_action_name: str = 'control_action', ground_action_name: str = 'track_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.

Parameters:

Name Type Description Default
env ManagerBasedRLEnv

The learning environment.

required
threshold float

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

required
sensor_cfg SceneEntityCfg

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

required
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'

Returns:

Type Description
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

Raises:

Type Description
ValueError

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

Examples:

>>> # 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.

commands

Classes:

Name Description
RandomTrajectoryCommand

Trajectory command generator with randomized type and parameters per environment.

RandomTrajectoryCommandCfg

Configuration for randomized trajectory commands.

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.

mjlab

Modules:

Name Description
LAV2_base

LAV2_base

Modules:

Name Description
LAV2_rl_cfg
mdp
LAV2_rl_cfg

Functions:

Name Description
create_LAV2_ppo_runner_cfg

Create RL runner configuration for LAV2 base task.

create_LAV2_ppo_runner_cfg
create_LAV2_ppo_runner_cfg() -> RslRlOnPolicyRunnerCfg

Create RL runner configuration for LAV2 base task.

mdp

Modules:

Name Description
actions
commands
rewards

Classes:

Name Description
FlightActionMapper

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

Mixer

Map thrust and moment demands to rotor commands.

VehicleParams

LAV2 vehicle parameters.

RotorDynamics

Batched rotor dynamics model.

ControlAction

Body torque control action term.

ControlActionCfg

See :class:ControlAction for more details.

UniformPoseCommandGlobal

Command generator that generates pose commands containing a 3-D position and heading.

UniformPoseCommandGlobalCfg

Configuration for the uniform 3D-pose command generator.

Functions:

Name Description
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.

FlightActionMapper
FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), limits: FlightMappingLimits = FlightMappingLimits(), *, num_envs: int = 1, device: str | device = 'cpu')

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

Initialize a batched Torch flight action mapper for the selected mode.

Methods:

Name Description
map_action

Map a normalized batched action into RPM commands and intermediates.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller target expansion step.

requires_controller property
requires_controller: bool

Whether this mode needs a controller target expansion step.

map_action
map_action(action: Tensor, mixer: Mixer, *, state: Tensor | None = None, flight_controller: ControllerBase | None = None) -> FlightMappingResult

Map a normalized batched action into RPM commands and intermediates.

Mixer
Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the torch mixer with vehicle parameters and device.

Methods:

Name Description
randomize

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

randomize
randomize(env_ids=None, randomization=None)

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve
apply_thrust_curve(normalized_thrust: Tensor, mode: int = 1) -> torch.Tensor

Apply thrust curve to normalized thrust command.

References

cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137 cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

Parameters:

Name Type Description Default
normalized_thrust Tensor

Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise.

required
mode int

Thrust curve mode.

1

Returns:

Type Description
Tensor

torch.Tensor: Thrust in Newtons with the same shape as normalized_thrust.

Raises:

Type Description
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands
calculate_rotor_commands(control: Tensor) -> torch.Tensor

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default
control Tensor

Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). 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: np.diag([0.11, 0.108, 0.215]).tolist())(), diameter: float = 0.476, Cdx: float = 0.5, x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = 8 * (np.pi / 180), r_p: float = 0.0775, J_m: float = 1e-05, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = 14.6 * (np.pi / 180), thetaTip: float = 6.8 * (np.pi / 180), lock: float = 0.6051, max_rpm: float = 10000.0, init_rpm: float = -1.0, rotor_rpm_rate_limit: float = 50000.0, tau_f: float = 0.01, tau_m: float = 0.05, tau_up: float = -1.0, tau_down: float = -1.0, r_w: float = 0.0285, n_w: int = 4, B: float = 0.136, L: float = 0.23, h_cg: float = 0.078, f: float = 0.01, mu0: float = 0.8, K: float = 20, track_cmd_rate_limit: float = 100, min_throttle_manual: float = 0.08, min_throttle: float = 0.12, max_throttle: float = 1.0, hover_throttle: float = -1)

LAV2 vehicle parameters.

Methods:

Name Description
__post_init__

Calculate derived parameters.

Attributes:

Name Type Description
rho float

空气密度 (kg/m^3)

g float

重力加速度 (m/s^2)

sim_dt float

仿真步长 (s)

step_dt float

控制步长 (s)

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

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass float

质量 (kg)

inertia list

惯性矩阵 (kg*m^2)

diameter float

直径 (m)

Cdx float

空气阻力系数

x float

x方向臂长 (m)

y float

y方向臂长 (m)

h float

重心高度 (m)

alpha float

y方向涵道外倾角度 (rad)

r_p float

螺旋桨半径 (m)

J_m float

电机转动惯量 (kg*m^2)

Ct float

推力系数

Cq float

扭矩系数

theta0 float

桨根角 (rad)

thetaTip float

桨尖角 (rad)

theta1 float

桨叶扭转角 (rad)

lock float

Lock number

max_rpm float

最大转速

init_rpm float

初始转速

rotor_rpm_rate_limit float

旋翼转速变化率限制 (rpm/s)

cT float

转速平方到推力增益 (N/(rpm^2))

cM float

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f float

电机滤波时间常数 (s)

tau_m float

兼容保留的电机时间常数 (s)

tau_up float

电机升速时间常数 (s)

tau_down float

电机降速时间常数 (s)

r_w float

主动轮半径 (m)

n_w int

负重轮个数

B float

两侧履带中心距 (m)

L float

履带节点接地部分长度 (m)

h_cg float

车体质心高度 (m)

f float

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 float

滑转率为1时的摩擦系数

K float

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit float

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual float

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle float

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle float

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle float

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

rho class-attribute instance-attribute
rho: float = 1.184

空气密度 (kg/m^3)

g class-attribute instance-attribute
g: float = 9.81

重力加速度 (m/s^2)

sim_dt class-attribute instance-attribute
sim_dt: float = 0.01

仿真步长 (s)

step_dt class-attribute instance-attribute
step_dt: float = 0.01

控制步长 (s)

randomization class-attribute instance-attribute
randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)

运行时参数随机化配置,按组件 (e.g. rotor/mixer) 划分为多个 scale 相对范围子表

mass class-attribute instance-attribute
mass: float = 2.1

质量 (kg)

inertia class-attribute instance-attribute
inertia: list = field(default_factory=lambda: tolist())

惯性矩阵 (kg*m^2)

diameter class-attribute instance-attribute
diameter: float = 0.476

直径 (m)

Cdx class-attribute instance-attribute
Cdx: float = 0.5

空气阻力系数

x class-attribute instance-attribute
x: float = 0.0952

x方向臂长 (m)

y class-attribute instance-attribute
y: float = 0.114423

y方向臂长 (m)

h class-attribute instance-attribute
h: float = -0.0125

重心高度 (m)

alpha class-attribute instance-attribute
alpha: float = 8 * (pi / 180)

y方向涵道外倾角度 (rad)

r_p class-attribute instance-attribute
r_p: float = 0.0775

螺旋桨半径 (m)

J_m class-attribute instance-attribute
J_m: float = 1e-05

电机转动惯量 (kg*m^2)

Ct class-attribute instance-attribute
Ct: float = 0.666

推力系数

Cq class-attribute instance-attribute
Cq: float = 0.0716

扭矩系数

theta0 class-attribute instance-attribute
theta0: float = 14.6 * (pi / 180)

桨根角 (rad)

thetaTip class-attribute instance-attribute
thetaTip: float = 6.8 * (pi / 180)

桨尖角 (rad)

theta1 class-attribute instance-attribute
theta1: float = field(init=False)

桨叶扭转角 (rad)

lock class-attribute instance-attribute
lock: float = 0.6051

Lock number

max_rpm class-attribute instance-attribute
max_rpm: float = 10000.0

最大转速

init_rpm class-attribute instance-attribute
init_rpm: float = -1.0

初始转速

rotor_rpm_rate_limit class-attribute instance-attribute
rotor_rpm_rate_limit: float = 50000.0

旋翼转速变化率限制 (rpm/s)

cT class-attribute instance-attribute
cT: float = field(init=False)

转速平方到推力增益 (N/(rpm^2))

cM class-attribute instance-attribute
cM: float = field(init=False)

转速平方到扭矩增益 (N*m/(rpm^2))

tau_f class-attribute instance-attribute
tau_f: float = 0.01

电机滤波时间常数 (s)

tau_m class-attribute instance-attribute
tau_m: float = 0.05

兼容保留的电机时间常数 (s)

tau_up class-attribute instance-attribute
tau_up: float = -1.0

电机升速时间常数 (s)

tau_down class-attribute instance-attribute
tau_down: float = -1.0

电机降速时间常数 (s)

r_w class-attribute instance-attribute
r_w: float = 0.0285

主动轮半径 (m)

n_w class-attribute instance-attribute
n_w: int = 4

负重轮个数

B class-attribute instance-attribute
B: float = 0.136

两侧履带中心距 (m)

L class-attribute instance-attribute
L: float = 0.23

履带节点接地部分长度 (m)

h_cg class-attribute instance-attribute
h_cg: float = 0.078

车体质心高度 (m)

f class-attribute instance-attribute
f: float = 0.01

滚动阻力系数(以干燥混凝土路面或沥青路面为例)

mu0 class-attribute instance-attribute
mu0: float = 0.8

滑转率为1时的摩擦系数

K class-attribute instance-attribute
K: float = 20

依赖于土壤黏聚系数和摩擦特性的常数

track_cmd_rate_limit class-attribute instance-attribute
track_cmd_rate_limit: float = 100

履带主动轮指令变化率限制 (rad/s^2)

min_throttle_manual class-attribute instance-attribute
min_throttle_manual: float = 0.08

MPC_MANTHR_MIN: Minimum manual thrust (0.0 - 1.0). Default: 0.08

min_throttle class-attribute instance-attribute
min_throttle: float = 0.12

MPC_THR_MIN: Minimum thrust in auto thrust control (0.05 - 1.0). Default: 0.12

max_throttle class-attribute instance-attribute
max_throttle: float = 1.0

MPC_THR_MAX: Maximum thrust in auto thrust control (0.0 - 1.0). Default: 1.0

hover_throttle class-attribute instance-attribute
hover_throttle: float = -1

MPC_THR_HOVER: Hover throttle manual (0.1 - 0.8). Default: 0.5 in PX4, calculated hover throttle in LAV2

__post_init__
__post_init__()

Calculate derived parameters.

RotorDynamics
RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Bases: DynamicsBase

Batched rotor dynamics model.

Initialize batched rotor dynamics on the specified device.

Methods:

Name Description
randomize

Randomize rotor runtime parameters from nominal values.

update

Calculate the output thrust and torque for each motor based on the motor commands.

reset

Resets the rotor model to initial conditions.

Attributes:

Name Type Description
params VehicleParams

Vehicle parameters for the dynamics model.

params instance-attribute
params: VehicleParams = params

Vehicle parameters for the dynamics model.

randomize
randomize(env_ids: slice | Sequence[int] | Tensor | None = None, randomization: dict[str, tuple[float, float]] | None = None) -> None

Randomize rotor runtime parameters from nominal values.

update
update(commands: Tensor) -> torch.Tensor

Calculate the output thrust and torque for each motor based on the motor commands.

Parameters:

Name Type Description Default
commands Tensor

Command tensor for each motor. Shape: (num_envs, 4)

required

Returns:

Type Description
Tensor

torch.Tensor: Thrust and torque tensor for each motor. Shape: (num_envs, 8)

reset
reset(env_ids: slice | Sequence[int] | Tensor) -> None

Resets the rotor model to initial conditions.

Parameters:

Name Type Description Default
env_ids slice | Sequence[int] | Tensor

The environment ids to reset.

required
ControlAction
ControlAction(cfg: ControlActionCfg, env: ManagerBasedRlEnv)

Bases: ActionTerm

Body torque control action term.

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

ControlActionCfg dataclass
ControlActionCfg(*, class_type: type[ActionTerm] = ControlAction, entity_name: str = 'robot', params: VehicleParams = VehicleParams())

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
class_type type[ActionTerm]

Class of the action term.

entity_name str

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

params VehicleParams

Vehicle parameters.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = ControlAction

Class of the action term.

entity_name class-attribute instance-attribute
entity_name: str = 'robot'

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

params class-attribute instance-attribute
params: VehicleParams = field(default_factory=VehicleParams)

Vehicle parameters.

UniformPoseCommandGlobal
UniformPoseCommandGlobal(cfg: UniformPoseCommandGlobalCfg, env: ManagerBasedRlEnv)

Bases: CommandTerm

Command generator that generates pose commands containing a 3-D position and heading. The command generator samples uniform 3D positions around the environment origin. The heading command is either set to point towards the target or is sampled uniformly. This can be configured through the :attr:UniformPoseCommandGlobalCfg.simple_heading parameter in the configuration.

Initialize the command generator class.

Parameters:

Name Type Description Default
cfg UniformPoseCommandGlobalCfg

The configuration parameters for the command generator.

required
env ManagerBasedRlEnv

The environment object.

required

Attributes:

Name Type Description
cfg UniformPoseCommandGlobalCfg

Configuration for the command generator.

command Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformPoseCommandGlobalCfg

Configuration for the command generator.

command property
command: Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

UniformPoseCommandGlobalCfg dataclass
UniformPoseCommandGlobalCfg(*, class_type: type = UniformPoseCommandGlobal, entity_name: str, simple_heading: bool, ranges: Ranges, viz: VizCfg = VizCfg())

Bases: CommandTermCfg

Configuration for the uniform 3D-pose command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
entity_name str

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

simple_heading bool

Whether to use simple heading or not.

ranges Ranges

Distribution ranges for the position commands.

entity_name instance-attribute
entity_name: str

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

simple_heading instance-attribute
simple_heading: bool

Whether to use simple heading or not.

If True, the heading is in the direction of the target position.

ranges instance-attribute
ranges: Ranges

Distribution ranges for the position commands.

Ranges dataclass
Ranges(pos_x: tuple[float, float], pos_y: tuple[float, float], pos_z: tuple[float, float], heading: tuple[float, float])

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
pos_x tuple[float, float]

Range for the x position (in m).

pos_y tuple[float, float]

Range for the y position (in m).

pos_z tuple[float, float]

Range for the z position (in m).

heading tuple[float, float]

Heading range for the position commands (in rad).

pos_x instance-attribute
pos_x: tuple[float, float]

Range for the x position (in m).

pos_y instance-attribute
pos_y: tuple[float, float]

Range for the y position (in m).

pos_z instance-attribute
pos_z: tuple[float, float]

Range for the z position (in m).

heading instance-attribute
heading: tuple[float, float]

Heading range for the position commands (in rad).

Used only if :attr:simple_heading is False.

lin_vel_l2
lin_vel_l2(env: ManagerBasedRlEnv, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize base linear velocity using L2 squared kernel.

ang_vel_l2
ang_vel_l2(env: ManagerBasedRlEnv, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize base angular velocity using L2 squared kernel.

pos_error_l2
pos_error_l2(env: ManagerBasedRlEnv, command_name: str, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

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

pos_error_tanh
pos_error_tanh(env: ManagerBasedRlEnv, command_name: str, std: float = 0.8, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize asset pos from its target pos using tanh kernel.

yaw_error_l2
yaw_error_l2(env: ManagerBasedRlEnv, command_name: str, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize heading error from target heading using L2 squared kernel.

yaw_error_tanh
yaw_error_tanh(env: ManagerBasedRlEnv, command_name: str, std: float = 0.8, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize heading error from target heading using tanh kernel.

actions

Classes:

Name Description
ControlAction

Body torque control action term.

ControlActionCfg

See :class:ControlAction for more details.

ControlAction
ControlAction(cfg: ControlActionCfg, env: ManagerBasedRlEnv)

Bases: ActionTerm

Body torque control action term.

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

ControlActionCfg dataclass
ControlActionCfg(*, class_type: type[ActionTerm] = ControlAction, entity_name: str = 'robot', params: VehicleParams = VehicleParams())

Bases: ActionTermCfg

See :class:ControlAction for more details.

Attributes:

Name Type Description
class_type type[ActionTerm]

Class of the action term.

entity_name str

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

params VehicleParams

Vehicle parameters.

class_type class-attribute instance-attribute
class_type: type[ActionTerm] = ControlAction

Class of the action term.

entity_name class-attribute instance-attribute
entity_name: str = 'robot'

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

params class-attribute instance-attribute
params: VehicleParams = field(default_factory=VehicleParams)

Vehicle parameters.

commands

Classes:

Name Description
UniformPoseCommandGlobal

Command generator that generates pose commands containing a 3-D position and heading.

UniformPoseCommandGlobalCfg

Configuration for the uniform 3D-pose command generator.

UniformPoseCommandGlobal
UniformPoseCommandGlobal(cfg: UniformPoseCommandGlobalCfg, env: ManagerBasedRlEnv)

Bases: CommandTerm

Command generator that generates pose commands containing a 3-D position and heading. The command generator samples uniform 3D positions around the environment origin. The heading command is either set to point towards the target or is sampled uniformly. This can be configured through the :attr:UniformPoseCommandGlobalCfg.simple_heading parameter in the configuration.

Initialize the command generator class.

Parameters:

Name Type Description Default
cfg UniformPoseCommandGlobalCfg

The configuration parameters for the command generator.

required
env ManagerBasedRlEnv

The environment object.

required

Attributes:

Name Type Description
cfg UniformPoseCommandGlobalCfg

Configuration for the command generator.

command Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

cfg instance-attribute
cfg: UniformPoseCommandGlobalCfg

Configuration for the command generator.

command property
command: Tensor

The desired 3D-pose in base frame. Shape is (num_envs, 4).

UniformPoseCommandGlobalCfg dataclass
UniformPoseCommandGlobalCfg(*, class_type: type = UniformPoseCommandGlobal, entity_name: str, simple_heading: bool, ranges: Ranges, viz: VizCfg = VizCfg())

Bases: CommandTermCfg

Configuration for the uniform 3D-pose command generator.

Classes:

Name Description
Ranges

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
entity_name str

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

simple_heading bool

Whether to use simple heading or not.

ranges Ranges

Distribution ranges for the position commands.

entity_name instance-attribute
entity_name: str

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

simple_heading instance-attribute
simple_heading: bool

Whether to use simple heading or not.

If True, the heading is in the direction of the target position.

ranges instance-attribute
ranges: Ranges

Distribution ranges for the position commands.

Ranges dataclass
Ranges(pos_x: tuple[float, float], pos_y: tuple[float, float], pos_z: tuple[float, float], heading: tuple[float, float])

Uniform distribution ranges for the position commands.

Attributes:

Name Type Description
pos_x tuple[float, float]

Range for the x position (in m).

pos_y tuple[float, float]

Range for the y position (in m).

pos_z tuple[float, float]

Range for the z position (in m).

heading tuple[float, float]

Heading range for the position commands (in rad).

pos_x instance-attribute
pos_x: tuple[float, float]

Range for the x position (in m).

pos_y instance-attribute
pos_y: tuple[float, float]

Range for the y position (in m).

pos_z instance-attribute
pos_z: tuple[float, float]

Range for the z position (in m).

heading instance-attribute
heading: tuple[float, float]

Heading range for the position commands (in rad).

Used only if :attr:simple_heading is False.

rewards

Functions:

Name Description
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.

lin_vel_l2
lin_vel_l2(env: ManagerBasedRlEnv, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize base linear velocity using L2 squared kernel.

ang_vel_l2
ang_vel_l2(env: ManagerBasedRlEnv, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize base angular velocity using L2 squared kernel.

pos_error_l2
pos_error_l2(env: ManagerBasedRlEnv, command_name: str, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

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

pos_error_tanh
pos_error_tanh(env: ManagerBasedRlEnv, command_name: str, std: float = 0.8, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize asset pos from its target pos using tanh kernel.

yaw_error_l2
yaw_error_l2(env: ManagerBasedRlEnv, command_name: str, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize heading error from target heading using L2 squared kernel.

yaw_error_tanh
yaw_error_tanh(env: ManagerBasedRlEnv, command_name: str, std: float = 0.8, asset_cfg: SceneEntityCfg = _DEFAULT_ASSET_CFG) -> torch.Tensor

Penalize heading error from target heading using tanh kernel.

trajectories

Trajectory implementations package for LAV2.

Modules:

Name Description
base

NumPy trajectory base classes.

helix

NumPy helix trajectory implementation.

hover_step

NumPy piecewise hover-step trajectory implementation.

lemniscate

NumPy lemniscate trajectory implementation.

lissajous

NumPy Lissajous trajectory implementation.

rectangle

NumPy rectangle trajectory implementation.

torch

Torch trajectory implementations for batched RL environments.

Classes:

Name Description
BaseTrajectory

Abstract base class for time-parameterized NumPy reference trajectories.

SpatialTrajectory

Base class for trajectories centered around a world-frame anchor point.

HelixTrajectory

Helix trajectory with optional vertical oscillation.

HoverStepTrajectory

Piecewise-constant position and yaw trajectory.

LemniscateTrajectory

Bernoulli lemniscate trajectory with optional vertical oscillation.

LissajousTrajectory

Three-dimensional Lissajous trajectory.

RectangleTrajectory

Constant-speed rectangle trajectory in the horizontal plane.

BaseTrajectory dataclass

BaseTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0))

Bases: ABC

Abstract base class for time-parameterized NumPy reference trajectories.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample

Sample the full 12D target at time t.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

sample_heading

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

Sample yaw and yaw-rate references for time t and translation state.

build_target

build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample abstractmethod

sample(t: float) -> np.ndarray

Sample the full 12D target at time t.

sample_batch

sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

SpatialTrajectory dataclass

SpatialTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0))

Bases: BaseTrajectory

Base class for trajectories centered around a world-frame anchor point.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample

Sample the full 12D target at time t.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

Cache the trajectory center as a float32 NumPy vector.

sample_heading

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

Sample yaw and yaw-rate references for time t and translation state.

build_target

build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample abstractmethod

sample(t: float) -> np.ndarray

Sample the full 12D target at time t.

sample_batch

sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

__post_init__()

Cache the trajectory center as a float32 NumPy vector.

HelixTrajectory dataclass

HelixTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), radius: float = 1.0, omega: float = 0.5, z_amplitude: float = 0.0, z_frequency: float = 1.0, z_phase: float = 0.0)

Bases: SpatialTrajectory

Helix trajectory with optional vertical oscillation.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

Cache the trajectory center as a float32 NumPy vector.

sample

Sample the helix trajectory at time t.

sample_heading

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

Sample yaw and yaw-rate references for time t and translation state.

build_target

build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

__post_init__()

Cache the trajectory center as a float32 NumPy vector.

sample

sample(t: float) -> np.ndarray

Sample the helix trajectory at time t.

HoverStepTrajectory dataclass

HoverStepTrajectory(yaw_from_velocity: bool = False, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), initial: tuple[float, float, float, float] = (0.0, 0.0, 1.0, 0.0), steps: tuple[tuple[float, tuple[float, float, float, float]], ...] = ((5.0, (1.0, 0.0, 1.0, 0.0)), (10.0, (1.0, 1.0, 1.5, np.pi / 2.0)), (15.0, (0.0, 1.0, 1.5, np.pi))))

Bases: BaseTrajectory

Piecewise-constant position and yaw trajectory.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

sample

Sample the active hover target at time t.

sample_heading

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

Sample yaw and yaw-rate references for time t and translation state.

build_target

build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

sample

sample(t: float) -> np.ndarray

Sample the active hover target at time t.

LemniscateTrajectory dataclass

LemniscateTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), scale: float = 1.0, omega: float = 0.5, z_amplitude: float = 0.0, z_frequency: float = 1.0, z_phase: float = 0.0)

Bases: SpatialTrajectory

Bernoulli lemniscate trajectory with optional vertical oscillation.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

Cache the trajectory center as a float32 NumPy vector.

sample

Sample the lemniscate trajectory at time t.

sample_heading

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

Sample yaw and yaw-rate references for time t and translation state.

build_target

build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

__post_init__()

Cache the trajectory center as a float32 NumPy vector.

sample

sample(t: float) -> np.ndarray

Sample the lemniscate trajectory at time t.

LissajousTrajectory dataclass

LissajousTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), amplitude: tuple[float, float, float] = (1.0, 1.0, 0.2), frequency: tuple[float, float, float] = (1.0, 2.0, 0.5), phase: tuple[float, float, float] = (0.0, np.pi / 2.0, 0.0), omega: float = 0.5)

Bases: SpatialTrajectory

Three-dimensional Lissajous trajectory.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

Cache vector-valued parameters as float32 NumPy arrays.

sample

Sample the Lissajous trajectory at time t.

sample_heading

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

Sample yaw and yaw-rate references for time t and translation state.

build_target

build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

__post_init__()

Cache vector-valued parameters as float32 NumPy arrays.

sample

sample(t: float) -> np.ndarray

Sample the Lissajous trajectory at time t.

RectangleTrajectory dataclass

RectangleTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), size: tuple[float, float] = (2.0, 1.0), speed: float = 0.5)

Bases: SpatialTrajectory

Constant-speed rectangle trajectory in the horizontal plane.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

Precompute rectangle corners and edge lengths.

sample

Sample the rectangle trajectory at time t.

sample_heading

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

Sample yaw and yaw-rate references for time t and translation state.

build_target

build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

__post_init__()

Precompute rectangle corners and edge lengths.

sample

sample(t: float) -> np.ndarray

Sample the rectangle trajectory at time t.

base

NumPy trajectory base classes.

Classes:

Name Description
BaseTrajectory

Abstract base class for time-parameterized NumPy reference trajectories.

SpatialTrajectory

Base class for trajectories centered around a world-frame anchor point.

BaseTrajectory dataclass

BaseTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0))

Bases: ABC

Abstract base class for time-parameterized NumPy reference trajectories.

Methods:

Name Description
sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample

Sample the full 12D target at time t.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

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

Sample yaw and yaw-rate references for time t and translation state.

build_target
build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample abstractmethod
sample(t: float) -> np.ndarray

Sample the full 12D target at time t.

sample_batch
sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

SpatialTrajectory dataclass

SpatialTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0))

Bases: BaseTrajectory

Base class for trajectories centered around a world-frame anchor point.

Methods:

Name Description
__post_init__

Cache the trajectory center as a float32 NumPy vector.

sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample

Sample the full 12D target at time t.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__
__post_init__()

Cache the trajectory center as a float32 NumPy vector.

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

Sample yaw and yaw-rate references for time t and translation state.

build_target
build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample abstractmethod
sample(t: float) -> np.ndarray

Sample the full 12D target at time t.

sample_batch
sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

helix

NumPy helix trajectory implementation.

Classes:

Name Description
HelixTrajectory

Helix trajectory with optional vertical oscillation.

HelixTrajectory dataclass

HelixTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), radius: float = 1.0, omega: float = 0.5, z_amplitude: float = 0.0, z_frequency: float = 1.0, z_phase: float = 0.0)

Bases: SpatialTrajectory

Helix trajectory with optional vertical oscillation.

Methods:

Name Description
sample

Sample the helix trajectory at time t.

sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

Cache the trajectory center as a float32 NumPy vector.

sample
sample(t: float) -> np.ndarray

Sample the helix trajectory at time t.

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

Sample yaw and yaw-rate references for time t and translation state.

build_target
build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch
sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__
__post_init__()

Cache the trajectory center as a float32 NumPy vector.

hover_step

NumPy piecewise hover-step trajectory implementation.

Classes:

Name Description
HoverStepTrajectory

Piecewise-constant position and yaw trajectory.

HoverStepTrajectory dataclass

HoverStepTrajectory(yaw_from_velocity: bool = False, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), initial: tuple[float, float, float, float] = (0.0, 0.0, 1.0, 0.0), steps: tuple[tuple[float, tuple[float, float, float, float]], ...] = ((5.0, (1.0, 0.0, 1.0, 0.0)), (10.0, (1.0, 1.0, 1.5, np.pi / 2.0)), (15.0, (0.0, 1.0, 1.5, np.pi))))

Bases: BaseTrajectory

Piecewise-constant position and yaw trajectory.

Methods:

Name Description
sample

Sample the active hover target at time t.

sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

sample
sample(t: float) -> np.ndarray

Sample the active hover target at time t.

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

Sample yaw and yaw-rate references for time t and translation state.

build_target
build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch
sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

lemniscate

NumPy lemniscate trajectory implementation.

Classes:

Name Description
LemniscateTrajectory

Bernoulli lemniscate trajectory with optional vertical oscillation.

LemniscateTrajectory dataclass

LemniscateTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), scale: float = 1.0, omega: float = 0.5, z_amplitude: float = 0.0, z_frequency: float = 1.0, z_phase: float = 0.0)

Bases: SpatialTrajectory

Bernoulli lemniscate trajectory with optional vertical oscillation.

Methods:

Name Description
sample

Sample the lemniscate trajectory at time t.

sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__

Cache the trajectory center as a float32 NumPy vector.

sample
sample(t: float) -> np.ndarray

Sample the lemniscate trajectory at time t.

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

Sample yaw and yaw-rate references for time t and translation state.

build_target
build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch
sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__
__post_init__()

Cache the trajectory center as a float32 NumPy vector.

lissajous

NumPy Lissajous trajectory implementation.

Classes:

Name Description
LissajousTrajectory

Three-dimensional Lissajous trajectory.

LissajousTrajectory dataclass

LissajousTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), amplitude: tuple[float, float, float] = (1.0, 1.0, 0.2), frequency: tuple[float, float, float] = (1.0, 2.0, 0.5), phase: tuple[float, float, float] = (0.0, np.pi / 2.0, 0.0), omega: float = 0.5)

Bases: SpatialTrajectory

Three-dimensional Lissajous trajectory.

Methods:

Name Description
__post_init__

Cache vector-valued parameters as float32 NumPy arrays.

sample

Sample the Lissajous trajectory at time t.

sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__
__post_init__()

Cache vector-valued parameters as float32 NumPy arrays.

sample
sample(t: float) -> np.ndarray

Sample the Lissajous trajectory at time t.

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

Sample yaw and yaw-rate references for time t and translation state.

build_target
build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch
sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

rectangle

NumPy rectangle trajectory implementation.

Classes:

Name Description
RectangleTrajectory

Constant-speed rectangle trajectory in the horizontal plane.

RectangleTrajectory dataclass

RectangleTrajectory(yaw_from_velocity: bool = True, fixed_yaw: float = 0.0, attitude: tuple[float, float] = (0.0, 0.0), body_rate: tuple[float, float] = (0.0, 0.0), center: tuple[float, float, float] = (0.0, 0.0, 1.0), size: tuple[float, float] = (2.0, 1.0), speed: float = 0.5)

Bases: SpatialTrajectory

Constant-speed rectangle trajectory in the horizontal plane.

Methods:

Name Description
__post_init__

Precompute rectangle corners and edge lengths.

sample

Sample the rectangle trajectory at time t.

sample_heading

Sample yaw and yaw-rate references for time t and translation state.

build_target

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch

Sample a batch of timestamps and stack the resulting 12D targets.

__post_init__
__post_init__()

Precompute rectangle corners and edge lengths.

sample
sample(t: float) -> np.ndarray

Sample the rectangle trajectory at time t.

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

Sample yaw and yaw-rate references for time t and translation state.

build_target
build_target(t: float, pos: ndarray, vel: ndarray, acc: ndarray) -> np.ndarray

Assemble a full 12D target from position, velocity, and acceleration.

sample_batch
sample_batch(ts: ndarray) -> np.ndarray

Sample a batch of timestamps and stack the resulting 12D targets.

torch

Torch trajectory implementations for batched RL environments.

Modules:

Name Description
base

Torch trajectory base classes.

helix

Torch helix trajectory implementation.

hover_step

Torch hover-step trajectory implementation.

lemniscate

Torch lemniscate trajectory implementation.

lissajous

Torch Lissajous trajectory implementation.

rectangle

Torch rectangle trajectory implementation.

Classes:

Name Description
BaseTrajectory

Abstract base class for batched torch trajectory implementations.

SpatialTrajectory

Torch base class for trajectories centered around a batched world-frame anchor.

HelixTrajectory

Batched helix trajectory with optional vertical oscillation.

HoverStepTrajectory

Batched piecewise-constant position and yaw trajectory.

LemniscateTrajectory

Batched Bernoulli lemniscate trajectory with vertical oscillation.

LissajousTrajectory

Batched three-dimensional Lissajous trajectory.

RectangleTrajectory

Batched constant-speed rectangle trajectory in the horizontal plane.

BaseTrajectory dataclass

BaseTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None)

Bases: ABC

Abstract base class for batched torch trajectory implementations.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

sample

Sample a batched 12D target tensor for time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

sample abstractmethod
sample(t: Tensor) -> torch.Tensor

Sample a batched 12D target tensor for time values t.

SpatialTrajectory dataclass

SpatialTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor)

Bases: BaseTrajectory

Torch base class for trajectories centered around a batched world-frame anchor.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

sample

Sample a batched 12D target tensor for time values t.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

sample abstractmethod
sample(t: Tensor) -> torch.Tensor

Sample a batched 12D target tensor for time values t.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

HelixTrajectory dataclass

HelixTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, radius: Tensor, omega: Tensor, z_amplitude: Tensor, z_frequency: Tensor, z_phase: Tensor)

Bases: SpatialTrajectory

Batched helix trajectory with optional vertical oscillation.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched helix trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched helix trajectory at time values t.

HoverStepTrajectory dataclass

HoverStepTrajectory(*, yaw_from_velocity: bool = False, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, initial: Tensor, steps: tuple[tuple[float, Tensor], ...] = ())

Bases: BaseTrajectory

Batched piecewise-constant position and yaw trajectory.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared trajectory tensors from the hover-step batch.

sample

Sample the active hover targets for batched time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared trajectory tensors from the hover-step batch.

sample
sample(t: Tensor) -> torch.Tensor

Sample the active hover targets for batched time values t.

LemniscateTrajectory dataclass

LemniscateTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, scale: Tensor, omega: Tensor, z_amplitude: Tensor, z_frequency: Tensor, z_phase: Tensor)

Bases: SpatialTrajectory

Batched Bernoulli lemniscate trajectory with vertical oscillation.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched lemniscate trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched lemniscate trajectory at time values t.

LissajousTrajectory dataclass

LissajousTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, amplitude: Tensor, frequency: Tensor, phase: Tensor, omega: Tensor)

Bases: SpatialTrajectory

Batched three-dimensional Lissajous trajectory.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched Lissajous trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched Lissajous trajectory at time values t.

RectangleTrajectory dataclass

RectangleTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, size: Tensor, speed: Tensor)

Bases: SpatialTrajectory

Batched constant-speed rectangle trajectory in the horizontal plane.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample

Sample the batched rectangle trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched rectangle trajectory at time values t.

base

Torch trajectory base classes.

Classes:

Name Description
BaseTrajectory

Abstract base class for batched torch trajectory implementations.

SpatialTrajectory

Torch base class for trajectories centered around a batched world-frame anchor.

BaseTrajectory dataclass
BaseTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None)

Bases: ABC

Abstract base class for batched torch trajectory implementations.

Methods:

Name Description
sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

sample

Sample a batched 12D target tensor for time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

sample abstractmethod
sample(t: Tensor) -> torch.Tensor

Sample a batched 12D target tensor for time values t.

SpatialTrajectory dataclass
SpatialTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor)

Bases: BaseTrajectory

Torch base class for trajectories centered around a batched world-frame anchor.

Methods:

Name Description
__post_init__

Initialize shared tensors from the center batch shape when available.

sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

sample

Sample a batched 12D target tensor for time values t.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

sample abstractmethod
sample(t: Tensor) -> torch.Tensor

Sample a batched 12D target tensor for time values t.

helix

Torch helix trajectory implementation.

Classes:

Name Description
HelixTrajectory

Batched helix trajectory with optional vertical oscillation.

HelixTrajectory dataclass
HelixTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, radius: Tensor, omega: Tensor, z_amplitude: Tensor, z_frequency: Tensor, z_phase: Tensor)

Bases: SpatialTrajectory

Batched helix trajectory with optional vertical oscillation.

Methods:

Name Description
sample

Sample the batched helix trajectory at time values t.

sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched helix trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

hover_step

Torch hover-step trajectory implementation.

Classes:

Name Description
HoverStepTrajectory

Batched piecewise-constant position and yaw trajectory.

HoverStepTrajectory dataclass
HoverStepTrajectory(*, yaw_from_velocity: bool = False, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, initial: Tensor, steps: tuple[tuple[float, Tensor], ...] = ())

Bases: BaseTrajectory

Batched piecewise-constant position and yaw trajectory.

Methods:

Name Description
__post_init__

Initialize shared trajectory tensors from the hover-step batch.

sample

Sample the active hover targets for batched time values t.

sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared trajectory tensors from the hover-step batch.

sample
sample(t: Tensor) -> torch.Tensor

Sample the active hover targets for batched time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

lemniscate

Torch lemniscate trajectory implementation.

Classes:

Name Description
LemniscateTrajectory

Batched Bernoulli lemniscate trajectory with vertical oscillation.

LemniscateTrajectory dataclass
LemniscateTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, scale: Tensor, omega: Tensor, z_amplitude: Tensor, z_frequency: Tensor, z_phase: Tensor)

Bases: SpatialTrajectory

Batched Bernoulli lemniscate trajectory with vertical oscillation.

Methods:

Name Description
sample

Sample the batched lemniscate trajectory at time values t.

sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched lemniscate trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

lissajous

Torch Lissajous trajectory implementation.

Classes:

Name Description
LissajousTrajectory

Batched three-dimensional Lissajous trajectory.

LissajousTrajectory dataclass
LissajousTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, amplitude: Tensor, frequency: Tensor, phase: Tensor, omega: Tensor)

Bases: SpatialTrajectory

Batched three-dimensional Lissajous trajectory.

Methods:

Name Description
sample

Sample the batched Lissajous trajectory at time values t.

sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched Lissajous trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.

rectangle

Torch rectangle trajectory implementation.

Classes:

Name Description
RectangleTrajectory

Batched constant-speed rectangle trajectory in the horizontal plane.

RectangleTrajectory dataclass
RectangleTrajectory(*, yaw_from_velocity: bool = True, fixed_yaw: Tensor | None = None, attitude: Tensor | None = None, body_rate: Tensor | None = None, center: Tensor, size: Tensor, speed: Tensor)

Bases: SpatialTrajectory

Batched constant-speed rectangle trajectory in the horizontal plane.

Methods:

Name Description
sample

Sample the batched rectangle trajectory at time values t.

sample_heading

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

build_target

Assemble a batched 12D target tensor from motion primitives.

__post_init__

Initialize shared tensors from the center batch shape when available.

sample
sample(t: Tensor) -> torch.Tensor

Sample the batched rectangle trajectory at time values t.

sample_heading
sample_heading(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> tuple[torch.Tensor, torch.Tensor]

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

build_target
build_target(t: Tensor, pos: Tensor, vel: Tensor, acc: Tensor) -> torch.Tensor

Assemble a batched 12D target tensor from motion primitives.

__post_init__
__post_init__()

Initialize shared tensors from the center batch shape when available.