Skip to content

mapping

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

Classes:

Name Description
FlightMappingConfig

Mapping-range configuration for normalized action scaling.

FlightActionMapper

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

Functions:

Name Description
target_to_command

Convert a dict target into a compact command vector.

Attributes:

Name Type Description
CONTROLLER_REGISTRY dict[str, type]

Registry mapping controller name strings to their classes.

CONTROLLER_REGISTRY module-attribute

CONTROLLER_REGISTRY: dict[str, type] = {'FlightController': FlightController, 'GeoControl': GeoControl}

Registry mapping controller name strings to their classes.

Shared with FlightControlActionCfg.controller so that sim2sim / sim2real runtimes use the same resolution logic as IsaacLab training tasks.

FlightMappingConfig dataclass

FlightMappingConfig(velocity_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.

Relative rotation fields mirror step_len / control_mode from so3_primer.rotations.envs.rot.RotEnv.__init__ and the benchmark wrappers: so3_primer.benchmarks.crazyflow.utils.utils.RotationCrazyflowWrapper, so3_primer.benchmarks.droneracing.utils.utils.RotationDroneRacingWrapper, and so3_primer.benchmarks.robosuite.utils.utils.RotationGymWrapper.

Methods:

Name Description
from_params

Build mapping ranges from vehicle parameters.

resolve

Resolve config overrides into concrete mapping ranges.

Attributes:

Name Type Description
velocity_range tuple[float, float, float] | None

Velocity scaling in m/s for x, y, z axes.

attitude_range tuple[float, float, float] | None

Attitude scaling in radians.

body_rate_range tuple[float, float, float] | None

Body-rate scaling in rad/s.

rel_rotation bool

Whether attitude actions are relative deltas rather than absolute targets.

rotation_step_len float | None

Relative rotation scale. Primer defines max step as step_len * pi radians.

velocity_range class-attribute instance-attribute

velocity_range: tuple[float, float, float] | None = None

Velocity scaling in m/s for x, y, z axes.

attitude_range class-attribute instance-attribute

attitude_range: tuple[float, float, float] | None = None

Attitude scaling in radians.

body_rate_range class-attribute instance-attribute

body_rate_range: tuple[float, float, float] | None = (2.0, 2.0, 2.0)

Body-rate scaling in rad/s.

rel_rotation class-attribute instance-attribute

rel_rotation: bool = False

Whether attitude actions are relative deltas rather than absolute targets.

rotation_step_len class-attribute instance-attribute

rotation_step_len: float | None = None

Relative rotation scale. Primer defines max step as step_len * pi radians.

from_params classmethod

from_params(params: VehicleParams) -> FlightMappingConfig

Build mapping ranges from vehicle parameters.

The returned ranges are chosen to broadly cover the controller range exposed by VehicleParams without requiring exact one-to-one alignment with the internal PX4-style controller limits.

Parameters:

Name Type Description Default

params

VehicleParams

Vehicle parameters providing the reference control bounds.

required

Returns:

Name Type Description
FlightMappingConfig FlightMappingConfig

Mapping ranges derived from params.

resolve

resolve(params: VehicleParams) -> FlightMappingConfig

Resolve config overrides into concrete mapping ranges.

Parameters:

Name Type Description Default

params

VehicleParams

Vehicle parameters providing fallback control bounds.

required

Returns:

Name Type Description
FlightMappingConfig FlightMappingConfig

Concrete mapping ranges for runtime use.

FlightActionMapper

FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), mapping: FlightMappingConfig | None = None, control_mask: dict | None = None)

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

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

Parameters:

Name Type Description Default

control_mode

str

Control mode string (e.g. "cmd_ctatt_quat").

required

params

VehicleParams

Vehicle parameters for action scaling.

VehicleParams()

mapping

FlightMappingConfig | None

Optional mapping-range overrides. Relative-rotation behaviour is controlled via :attr:FlightMappingConfig.rel_rotation and :attr:FlightMappingConfig.rotation_step_len.

None

control_mask

dict | None

Per-key boolean mask dict.

None

Methods:

Name Description
action_to_collective_acc

Map a normalized policy collective action to total collective acceleration.

collective_acc_to_thrust

Convert total collective acceleration into total thrust in Newtons.

action_to_collective_thrust

Convert a normalized policy collective action into total thrust.

decode_action

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

map_action

Resolve a normalized action into simulation rotor RPM commands.

Attributes:

Name Type Description
requires_controller bool

Whether this mode needs a controller — true when mask has any keys.

requires_controller property

requires_controller: bool

Whether this mode needs a controller — true when mask has any keys.

action_to_collective_acc

action_to_collective_acc(action: float | ndarray, mixer: Mixer) -> np.ndarray

Map a normalized policy collective action to total collective acceleration.

collective_acc_to_thrust

collective_acc_to_thrust(collective_acc: float | ndarray) -> np.ndarray

Convert total collective acceleration into total thrust in Newtons.

action_to_collective_thrust

action_to_collective_thrust(action: float | ndarray, mixer: Mixer) -> np.ndarray

Convert a normalized policy collective action into total thrust.

decode_action

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

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

map_action

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

Resolve a normalized action into simulation rotor RPM commands.

target_to_command

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

Convert a dict target into a compact command vector.

target keys are pos(3), vel(3), att_euler(3), ang_vel(3), thrust(scalar). The tgt_ctatt/tgt_ctbr modes read the dedicated thrust key instead of overloading index 5.

Parameters:

Name Type Description Default

target

ControllerTarget

Target state dict.

required

command_mode

str

One of tgt_pos, tgt_vel, tgt_ctatt, tgt_ctbr.

required

state

ControllerState | None

Current state dict; required for tgt_pos mode.

None

output_frame

str

"world_relative" (default) or "yaw_body". "yaw_body" rotates planar commands into the body heading frame.

'world_relative'