Skip to content

Commit

Permalink
mixer_multirotor: use reduce_only instead of -1000 for yaw thrust red…
Browse files Browse the repository at this point in the history
…uction

This is more accurate, because if we use -1000 as lower bound, a very large
yaw command can reduce thrust more than needed.

The difference can be seen in the following example
(with roll/pitch airmode):
p_dot_sp = -1.0 # roll acceleration
q_dot_sp = 0.9 # pitch acceleration
r_dot_sp = -0.9 # yaw acceleration
  • Loading branch information
bkueng committed Dec 13, 2018
1 parent 418df25 commit cfad556
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib/mixer/mixer_multirotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ void MultirotorMixer::mix_yaw(float yaw, float *outputs)
_tmp_array[i] = _rotors[i].thrust_scale;
}

minimize_saturation(_tmp_array, outputs, _saturation_status, -1000.f);
// reduce thrust only
minimize_saturation(_tmp_array, outputs, _saturation_status, 0.f, 1.f, true);
}

unsigned
Expand Down
5 changes: 4 additions & 1 deletion src/lib/mixer/mixer_multirotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ def mix_yaw(m_sp, u, P, u_min, u_max):
u_r_dot = P[:,2]
u_pp = minimize_sat(u_p, u_min, u_max+0.15, u_r_dot)
u_T = P[:, 3]
u_ppp = minimize_sat(u_pp, -1000, u_max, u_T)
u_ppp = minimize_sat(u_pp, 0, u_max, u_T)
# reduce thrust only
if (u_ppp > (u_pp)).any():
u_ppp = u_pp
return u_ppp

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

0 comments on commit cfad556

Please # to comment.