Skip to content

mixer

Command 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(), 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.

Methods:

Name Description
calculate_rotor_commands

Allocate thrust and moments into rotor speeds.

Attributes:

Name Type Description
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

最大总推力

calculate_rotor_commands

calculate_rotor_commands(control: ndarray) -> np.ndarray

Allocate thrust and moments into rotor speeds.

Parameters:

Name Type Description Default

control

ndarray

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

required

Returns:

Type Description
ndarray

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