mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 10:17:45 +08:00
MultirotorMixer: Apply thrust gain independently from other axes
Align the way motor output is computed with the model used in the mixer generation script. previous: `out = (roll_gain*roll + pitch_gain*pitch + yaw_gain*yaw + thrust)*out_gain` new: `out = roll_gain*roll + pitch_gain*pitch + yaw_gain*yaw + thrust_gain*thrust` which is the standard matrix*vector multiplication. This commit has 0 effect on symmetric platforms (i.e. most) as thrust_gain==1 on these platforms. On asymmetric platform --where some thrust_gain are lower than 1-- the previous formulation resulted in coupling between thrust and other axes. fixes #8628
This commit is contained in:
committed by
Daniel Agar
parent
0e3574c44f
commit
262d9c790b
@@ -546,10 +546,10 @@ public:
|
|||||||
* Precalculated rotor mix.
|
* Precalculated rotor mix.
|
||||||
*/
|
*/
|
||||||
struct Rotor {
|
struct Rotor {
|
||||||
float roll_scale; /**< scales roll for this rotor */
|
float roll_scale; /**< scales roll for this rotor */
|
||||||
float pitch_scale; /**< scales pitch for this rotor */
|
float pitch_scale; /**< scales pitch for this rotor */
|
||||||
float yaw_scale; /**< scales yaw for this rotor */
|
float yaw_scale; /**< scales yaw for this rotor */
|
||||||
float out_scale; /**< scales total out for this rotor */
|
float thrust_scale; /**< scales thrust for this rotor */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -187,9 +187,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
|||||||
for (unsigned i = 0; i < _rotor_count; i++) {
|
for (unsigned i = 0; i < _rotor_count; i++) {
|
||||||
float out = roll * _rotors[i].roll_scale +
|
float out = roll * _rotors[i].roll_scale +
|
||||||
pitch * _rotors[i].pitch_scale +
|
pitch * _rotors[i].pitch_scale +
|
||||||
thrust;
|
thrust * _rotors[i].thrust_scale;
|
||||||
|
|
||||||
out *= _rotors[i].out_scale;
|
|
||||||
|
|
||||||
/* calculate min and max output values */
|
/* calculate min and max output values */
|
||||||
if (out < min_out) {
|
if (out < min_out) {
|
||||||
@@ -206,6 +204,11 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
|||||||
float boost = 0.0f; // value added to demanded thrust (can also be negative)
|
float boost = 0.0f; // value added to demanded thrust (can also be negative)
|
||||||
float roll_pitch_scale = 1.0f; // scale for demanded roll and pitch
|
float roll_pitch_scale = 1.0f; // scale for demanded roll and pitch
|
||||||
|
|
||||||
|
// Note: thrust boost is computed assuming thrust_gain==1 for all motors.
|
||||||
|
// On asymmetric platforms, some motors have thrust_gain<1,
|
||||||
|
// which may result in motor saturation after thrust boost is applied
|
||||||
|
// TODO: revise the saturation/boosting strategy
|
||||||
|
|
||||||
if (min_out < 0.0f && max_out < 1.0f && -min_out <= 1.0f - max_out) {
|
if (min_out < 0.0f && max_out < 1.0f && -min_out <= 1.0f - max_out) {
|
||||||
float max_thrust_diff = thrust * thrust_increase_factor - thrust;
|
float max_thrust_diff = thrust * thrust_increase_factor - thrust;
|
||||||
|
|
||||||
@@ -262,9 +265,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
|||||||
float out = (roll * _rotors[i].roll_scale +
|
float out = (roll * _rotors[i].roll_scale +
|
||||||
pitch * _rotors[i].pitch_scale) * roll_pitch_scale +
|
pitch * _rotors[i].pitch_scale) * roll_pitch_scale +
|
||||||
yaw * _rotors[i].yaw_scale +
|
yaw * _rotors[i].yaw_scale +
|
||||||
thrust + boost;
|
(thrust + boost) * _rotors[i].thrust_scale;
|
||||||
|
|
||||||
out *= _rotors[i].out_scale;
|
|
||||||
|
|
||||||
// scale yaw if it violates limits. inform about yaw limit reached
|
// scale yaw if it violates limits. inform about yaw limit reached
|
||||||
if (out < 0.0f) {
|
if (out < 0.0f) {
|
||||||
@@ -300,7 +301,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
|||||||
outputs[i] = (roll * _rotors[i].roll_scale +
|
outputs[i] = (roll * _rotors[i].roll_scale +
|
||||||
pitch * _rotors[i].pitch_scale) * roll_pitch_scale +
|
pitch * _rotors[i].pitch_scale) * roll_pitch_scale +
|
||||||
yaw * _rotors[i].yaw_scale +
|
yaw * _rotors[i].yaw_scale +
|
||||||
thrust + boost;
|
(thrust + boost) * _rotors[i].thrust_scale;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
implement simple model for static relationship between applied motor pwm and motor thrust
|
implement simple model for static relationship between applied motor pwm and motor thrust
|
||||||
|
|||||||
Reference in New Issue
Block a user