跳转至

mapping

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

类:

名称 描述
FlightMappingConfig

Mapping-range configuration for normalized action scaling.

FlightMappingResult

Mapped result for a normalized flight action or action batch.

FlightActionMapper

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

函数:

名称 描述
target_to_command

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

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

Mapping-range configuration for normalized action scaling.

方法:

名称 描述
from_params

Build mapping ranges from vehicle parameters.

resolve

Resolve config overrides into concrete mapping ranges.

属性:

名称 类型 描述
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.

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.

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.

参数:

名称 类型 描述 默认

params

VehicleParams

Vehicle parameters providing the reference control bounds.

必需

返回:

名称 类型 描述
FlightMappingConfig FlightMappingConfig

Mapping ranges derived from params.

resolve

resolve(params: VehicleParams) -> FlightMappingConfig

Resolve config overrides into concrete mapping ranges.

参数:

名称 类型 描述 默认

params

VehicleParams

Vehicle parameters providing fallback control bounds.

必需

返回:

名称 类型 描述
FlightMappingConfig FlightMappingConfig

Concrete mapping ranges for runtime use.

FlightMappingResult dataclass

FlightMappingResult(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(), mapping: FlightMappingConfig | None = None)

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

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

方法:

名称 描述
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 action into an RPM command and optional intermediates.

属性:

名称 类型 描述
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.

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.

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.

参数:

名称 类型 描述 默认

target

ndarray

Full target state ordered as [x, y, z, vx, vy, vz, roll, pitch, yaw, wx, wy, wz]. The intended convention is: - x, y, z: world-frame position - vx, vy, vz: body-frame linear velocity - roll, pitch, yaw: body attitude relative to the world frame - wx, wy, wz: body-frame angular velocity

必需

command_mode

str

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

必需

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

返回:

名称 类型 描述
ndarray

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

mode ndarray
  • tgt_pos -> [dx_body, dy_body, dz, dyaw]
  • tgt_vel -> [vx_body, vy_body, vz_body, yaw_rate]
  • tgt_ctatt -> [collective, roll, pitch, yaw_rate]
  • tgt_ctbr -> [collective, wx_body, wy_body, wz_body]

引发:

类型 描述
ValueError

If command_mode is unsupported or state is missing for tgt_pos.