mixer
Command mixer for mapping thrust/moment demands to rotor speeds.
类:
| 名称 | 描述 |
|---|---|
Mixer |
Map thrust and moment demands to rotor commands. |
Mixer
Mixer(params: VehicleParams = VehicleParams(), verbose=False)
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 mixer with vehicle parameters and mixer matrix.
方法:
| 名称 | 描述 |
|---|---|
apply_thrust_curve |
Apply thrust curve to normalized thrust command. |
calculate_rotor_commands |
Allocate thrust and moments into rotor speeds. |
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
mat |
转速平方到推力扭矩 |
|
inv_mat |
推力扭矩到转速平方 |
|
max_rpm_sq |
最大转速平方 |
|
min_rpm_sq |
最小转速平方 |
|
max_wrench |
单桨最大推力/力矩 |
|
min_wrench |
单桨最小推力/力矩 |
|
max_collective_thrust |
最大总推力 |
mat
instance-attribute
mat = array([[cT * cos(alpha)] * 4, [cT * cos(alpha) * y] * 4, [cT * cos(alpha) * x] * 4, [cT * sin(alpha) * x + cM] * 4]) * array([[1, 1, 1, 1], [-1, 1, 1, -1], [-1, 1, -1, 1], [1, 1, -1, -1]])
转速平方到推力扭矩
inv_mat
instance-attribute
inv_mat = pinv(mat)
推力扭矩到转速平方
max_rpm_sq
instance-attribute
max_rpm_sq = max_rpm ** 2
最大转速平方
min_rpm_sq
instance-attribute
min_rpm_sq = init_rpm ** 2
最小转速平方
max_wrench
instance-attribute
max_wrench = mat[:, 1] * max_rpm_sq
单桨最大推力/力矩
min_wrench
instance-attribute
min_wrench = mat[:, 1] * min_rpm_sq
单桨最小推力/力矩
max_collective_thrust
instance-attribute
max_collective_thrust = max_wrench[0] * 4.0
最大总推力
apply_thrust_curve
apply_thrust_curve(normalized_thrust: float, mode: int = 1) -> float
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
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
float
|
Normalized thrust command [-1, 1]. |
必需 |
|
int
|
Thrust curve mode. |
1
|
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
float |
float
|
Total thrust in Newtons. |
引发:
| 类型 | 描述 |
|---|---|
NotImplementedError
|
If the specified mode is not implemented. |
calculate_rotor_commands
calculate_rotor_commands(control: ndarray) -> np.ndarray
Allocate thrust and moments into rotor speeds.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
ndarray
|
Desired total thrust and roll/pitch/yaw moments. Shape: (4,). |
必需 |
返回:
| 类型 | 描述 |
|---|---|
ndarray
|
np.ndarray: The amplitude of each motor's rotational speed (calculated using |