Skip to content

mapping

Array API action mappers for batched vehicle simulation.

Classes:

Name Description
FlightMapping

Fields emitted while lowering normalized actions to actuator commands.

DifferentialDriveMapping

Fields emitted while lowering ground actions to drive-shaft targets.

FlightMappingConfig

Mapping-range configuration for normalized action scaling.

DifferentialDriveMappingConfig

Policy-facing scaling for differential-drive controller modes.

FlightActionMapper

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

DifferentialDriveActionMapper

Map normalized ground actions into differential controller targets.

Functions:

Name Description
target_to_command

Convert dict target batches into compact command vectors.

Attributes:

Name Type Description
ACTION_KEY_ORDER

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

ACTION_KEY_ORDER module-attribute

ACTION_KEY_ORDER = tuple(ControllerState.__annotations__)

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

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

FlightMapping

Bases: TypedDict

Fields emitted while lowering normalized actions to actuator commands.

Attributes:

Name Type Description
target ControllerTarget

Mapped target consumed by sim2real PX4 setpoints or simulation controllers.

collective_acc ArrayLike

Total thrust acceleration consumed by the sim2real thrust model.

torque ArrayLike

Normalized body torque consumed by PX4-native or legacy MAVROS wrench paths.

motor_thrusts ArrayLike

Normalized per-motor thrust consumed by PX4-native direct actuators.

wrench ArrayLike

Physical [thrust, roll, pitch, yaw] wrench used by simulation diagnostics.

rpm_command ArrayLike

Rotor RPM command consumed by train and sim2sim rotor dynamics.

target instance-attribute

target: ControllerTarget

Mapped target consumed by sim2real PX4 setpoints or simulation controllers.

collective_acc instance-attribute

collective_acc: ArrayLike

Total thrust acceleration consumed by the sim2real thrust model.

torque instance-attribute

torque: ArrayLike

Normalized body torque consumed by PX4-native or legacy MAVROS wrench paths.

motor_thrusts instance-attribute

motor_thrusts: ArrayLike

Normalized per-motor thrust consumed by PX4-native direct actuators.

wrench instance-attribute

wrench: ArrayLike

Physical [thrust, roll, pitch, yaw] wrench used by simulation diagnostics.

rpm_command instance-attribute

rpm_command: ArrayLike

Rotor RPM command consumed by train and sim2sim rotor dynamics.

DifferentialDriveMapping

Bases: TypedDict

Fields emitted while lowering ground actions to drive-shaft targets.

FlightMappingConfig dataclass

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

Mapping-range configuration for normalized action scaling.

Methods:

Name Description
from_params

Build mapping ranges from vehicle parameters.

resolve

Resolve config overrides into concrete mapping ranges.

from_params classmethod

from_params(params: VehicleParams) -> FlightMappingConfig

Build mapping ranges from vehicle parameters.

resolve

resolve(params: VehicleParams) -> FlightMappingConfig

Resolve config overrides into concrete mapping ranges.

DifferentialDriveMappingConfig dataclass

DifferentialDriveMappingConfig(forward_speed_range: float | None = None, yaw_rate_range: float | None = None, heading_range: float = pi, side_speed_range: float | None = None)

Policy-facing scaling for differential-drive controller modes.

Methods:

Name Description
from_params

Build mapping ranges from track or wheel platform parameters.

resolve

Resolve explicit overrides against platform-derived defaults.

from_params classmethod

from_params(params: VehicleParams) -> DifferentialDriveMappingConfig

Build mapping ranges from track or wheel platform parameters.

resolve

resolve(params: VehicleParams) -> DifferentialDriveMappingConfig

Resolve explicit overrides against platform-derived defaults.

FlightActionMapper

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

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

Initialize the batched action mapper and backend namespace.

Methods:

Name Description
randomize

Randomize.

action_to_collective_acc

Action to collective acc.

collective_acc_to_thrust

Collective acc to thrust.

action_to_collective_thrust

Action to collective thrust.

decode_action

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

map_action

Resolve normalized batched action into simulation rotor RPM commands.

Attributes:

Name Type Description
requires_controller bool

Requires controller.

requires_controller property

requires_controller: bool

Requires controller.

randomize

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

Randomize.

action_to_collective_acc

action_to_collective_acc(action: ArrayLike, mixer) -> ArrayLike

Action to collective acc.

collective_acc_to_thrust

collective_acc_to_thrust(collective_acc: ArrayLike) -> ArrayLike

Collective acc to thrust.

action_to_collective_thrust

action_to_collective_thrust(action: ArrayLike, mixer) -> ArrayLike

Action to collective thrust.

decode_action

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

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

map_action

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

Resolve normalized batched action into simulation rotor RPM commands.

DifferentialDriveActionMapper

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

Map normalized ground actions into differential controller targets.

Initialize the ground mapper and stable action-field indices.

Methods:

Name Description
decode_action

Decode a policy action into side speed or a controller target.

map_action

Resolve an action into left/right output-shaft speed targets.

Attributes:

Name Type Description
requires_controller bool

Whether this mode passes through the differential controller.

requires_controller property

requires_controller: bool

Whether this mode passes through the differential controller.

decode_action

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

Decode a policy action into side speed or a controller target.

map_action

map_action(action: ArrayLike, *, state: ControllerState | None = None, controller: ControllerBase | None = None) -> DifferentialDriveMapping

Resolve an action into left/right output-shaft speed targets.

target_to_command

target_to_command(target: ControllerTarget, command_mode: str, state: ControllerState | None = None, output_frame: str = 'world_relative') -> ArrayLike

Convert dict target batches into compact command vectors.