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