Skip to content

Commit

Permalink
mc mixer: prioritize roll/pitch over yaw for full airmode
Browse files Browse the repository at this point in the history
Improves roll/pitch tracking in situations of large yaw demands.
  • Loading branch information
bkueng authored and bresch committed Jun 17, 2019
1 parent 8811c83 commit beaba44
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/mixer/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,8 @@ class MultirotorMixer : public Mixer
* Mix roll, pitch, yaw, thrust and set the outputs vector.
*
* Desaturation behavior: full airmode for roll/pitch/yaw:
* thrust is increased/decreased as much as required to meet demanded the roll/pitch/yaw.
* thrust is increased/decreased as much as required to meet demanded the roll/pitch/yaw,
* while giving priority to roll and pitch over yaw.
*/
inline void mix_airmode_rpy(float roll, float pitch, float yaw, float thrust, float *outputs);

Expand Down
8 changes: 8 additions & 0 deletions src/lib/mixer/mixer_multirotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ void MultirotorMixer::mix_airmode_rpy(float roll, float pitch, float yaw, float
}

minimize_saturation(_tmp_array, outputs, _saturation_status);

// Unsaturate yaw (in case upper and lower bounds are exceeded)
// to prioritize roll/pitch over yaw.
for (unsigned i = 0; i < _rotor_count; i++) {
_tmp_array[i] = _rotors[i].yaw_scale;
}

minimize_saturation(_tmp_array, outputs, _saturation_status);
}

void MultirotorMixer::mix_airmode_disabled(float roll, float pitch, float yaw, float thrust, float *outputs)
Expand Down
8 changes: 7 additions & 1 deletion src/lib/mixer/mixer_multirotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ def airmode_rpy(m_sp, P, u_min, u_max):
# Use thrust to unsaturate the outputs if needed
u_T = P[:, 3]
u_prime = minimize_sat(u, u_min, u_max, u_T)
return (u, u_prime)

# Unsaturate yaw (in case upper and lower bounds are exceeded)
# to prioritize roll/pitch over yaw.
u_T = P[:, 2]
u_prime_yaw = minimize_sat(u_prime, u_min, u_max, u_T)

return (u, u_prime_yaw)


def normal_mode(m_sp, P, u_min, u_max):
Expand Down

0 comments on commit beaba44

Please sign in to comment.