跳转至

mixer

Torch mixer for mapping thrust/moment demands to rotor speeds.

类:

名称 描述
Mixer

Map thrust and moment demands to rotor commands.

Mixer

Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device: str | device = 'cpu')

Map thrust and moment demands to rotor commands.

Note

电机推力分配: 电机1 = 推力 - 横滚(roll) + 俯仰(pitch) + 偏航(yaw) 电机2 = 推力 + 横滚(roll) - 俯仰(pitch) + 偏航(yaw) 电机3 = 推力 + 横滚(roll) + 俯仰(pitch) - 偏航(yaw) 电机4 = 推力 - 横滚(roll) - 俯仰(pitch) - 偏航(yaw)

Initialize the torch mixer with vehicle parameters and device.

方法:

名称 描述
randomize

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

Apply thrust curve to normalized thrust command.

calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

randomize

randomize(env_ids=None, randomization=None)

Randomize mixer runtime parameters from nominal values.

apply_thrust_curve

apply_thrust_curve(normalized_thrust: Tensor, mode: int = 1) -> torch.Tensor

Apply thrust curve to normalized thrust command.

References

cmd_ctatt: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_att_control/mc_att_control_main.cpp#L111-L137 cmd_ctbr: https://github.com/PX4/PX4-Autopilot/blob/e5a483e4b71ab4b994cb0121fe28992d8ce0c8cd/src/modules/mc_rate_control/MulticopterRateControl.cpp#L156-L179

参数:

名称 类型 描述 默认

normalized_thrust

Tensor

Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise.

必需

mode

int

Thrust curve mode.

1

返回:

类型 描述
Tensor

torch.Tensor: Thrust in Newtons with the same shape as normalized_thrust.

引发:

类型 描述
NotImplementedError

If the specified mode is not implemented.

calculate_rotor_commands

calculate_rotor_commands(control: Tensor) -> torch.Tensor

Allocate thrust and moments into rotor speeds.

参数:

名称 类型 描述 默认

control

Tensor

Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4)

必需

返回:

类型 描述
Tensor

torch.Tensor: The amplitude of each motor's rotational speed (calculated using sqrt(clip(rpm_sq))). Shape: (num_envs, 4)