Skip to content

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 dict target batches into compact command vectors.

Attributes:

Name Type Description
CONTROLLER_REGISTRY dict[str, type]

Torch-controller registry mirroring

CONTROLLER_REGISTRY module-attribute

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

Torch-controller registry mirroring :data:lav2.controllers.mapping.CONTROLLER_REGISTRY.

FlightActionMapper

FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), mapping: FlightMappingConfig | None = None, control_mask: dict | None = None, 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.

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

num_envs

int

Number of parallel environments.

1

device

str | device

Torch device.

'cpu'

Methods:

Name Description
randomize

Randomize mapper runtime parameters used by action scaling.

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.

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 — true when mask has any keys.

requires_controller property

requires_controller: bool

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

randomize

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

Randomize mapper runtime parameters used by action scaling.

action_to_collective_acc

action_to_collective_acc(action: Tensor, mixer: Mixer) -> torch.Tensor

Map a normalized policy collective action to total collective acceleration.

collective_acc_to_thrust

collective_acc_to_thrust(collective_acc: Tensor) -> torch.Tensor

Convert total collective acceleration into total thrust in Newtons.

action_to_collective_thrust

action_to_collective_thrust(action: Tensor, mixer: Mixer) -> torch.Tensor

Convert a normalized policy collective action into total thrust.

map_action

map_action(action: Tensor, mixer: Mixer, *, state: dict | 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: dict, command_mode: str, state: dict | None = None, output_frame: str = 'world_relative') -> torch.Tensor

Convert dict target batches into compact command vectors.

Parameters:

Name Type Description Default

target

dict

Batched target state dict.

required

command_mode

str

One of tgt_pos, tgt_vel, tgt_ctatt, tgt_ctbr.

required

state

dict | None

Batched current state dict; required for tgt_pos mode.

None

output_frame

str

"world_relative" (default) or "yaw_body". Only affects tgt_vel mode. "yaw_body" rotates the planar velocity into the body frame using the target yaw.

'world_relative'