mixer
Torch mixer for mapping thrust/moment demands to rotor speeds.
Classes:
| Name | Description |
|---|---|
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.
Methods:
| Name | Description |
|---|---|
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
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Tensor
|
Normalized thrust command [-1, 1]. Shape: arbitrary, e.g. (num_envs, n_motors). Applied elementwise. |
required |
|
int
|
Thrust curve mode. |
1
|
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Thrust in Newtons with the same shape as |
Raises:
| Type | Description |
|---|---|
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Tensor
|
Desired total thrust and roll/pitch/yaw moments. Shape: (num_envs, 4) |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: The amplitude of each motor's rotational speed (calculated using |