forked from Archive/PX4-Autopilot
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:
parent
0e3574c44f
commit
262d9c790b
|
@ -549,7 +549,7 @@ public:
|
|||
float roll_scale; /**< scales roll for this rotor */
|
||||
float pitch_scale; /**< scales pitch 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++) {
|
||||
float out = roll * _rotors[i].roll_scale +
|
||||
pitch * _rotors[i].pitch_scale +
|
||||
thrust;
|
||||
|
||||
out *= _rotors[i].out_scale;
|
||||
thrust * _rotors[i].thrust_scale;
|
||||
|
||||
/* calculate min and max output values */
|
||||
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 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) {
|
||||
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 +
|
||||
pitch * _rotors[i].pitch_scale) * roll_pitch_scale +
|
||||
yaw * _rotors[i].yaw_scale +
|
||||
thrust + boost;
|
||||
|
||||
out *= _rotors[i].out_scale;
|
||||
(thrust + boost) * _rotors[i].thrust_scale;
|
||||
|
||||
// scale yaw if it violates limits. inform about yaw limit reached
|
||||
if (out < 0.0f) {
|
||||
|
@ -300,7 +301,7 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
|||
outputs[i] = (roll * _rotors[i].roll_scale +
|
||||
pitch * _rotors[i].pitch_scale) * roll_pitch_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
|
||||
|
|
Loading…
Reference in New Issue