mc_att_control: fix for Rattitude mode

When switching back from rate to attitude control, the code depended on a
vehicle_control_mode topics update, but the publication frequency of that
is low. So the switch was noticeably delayed.
This commit is contained in:
Beat Küng
2018-11-05 10:43:32 +01:00
parent 36ee0297ee
commit adf1fea554
@@ -876,13 +876,12 @@ MulticopterAttitudeControl::run()
attitude_dt += dt;
/* Check if we are in rattitude mode and the pilot is above the threshold on pitch
* or roll (yaw can rotate 360 in normal att control). If both are true don't
* or roll (yaw can rotate 360 in normal att control). If both are true don't
* even bother running the attitude controllers */
if (_v_control_mode.flag_control_rattitude_enabled) {
if (fabsf(_manual_control_sp.y) > _rattitude_thres.get() ||
fabsf(_manual_control_sp.x) > _rattitude_thres.get()) {
_v_control_mode.flag_control_attitude_enabled = false;
}
_v_control_mode.flag_control_attitude_enabled =
fabsf(_manual_control_sp.y) <= _rattitude_thres.get() &&
fabsf(_manual_control_sp.x) <= _rattitude_thres.get();
}
bool attitude_setpoint_generated = false;