Plane: actualy fail to enter mode, don't just put the mode back and reutrn true

This commit is contained in:
Iampete1 2021-08-06 13:37:34 +01:00 committed by Andrew Tridgell
parent a1eb84ebfd
commit bd2fed31ee
3 changed files with 4 additions and 19 deletions

View File

@ -3,13 +3,7 @@
bool ModeQAcro::_enter() bool ModeQAcro::_enter()
{ {
if (!plane.quadplane.init_mode() && plane.previous_mode != nullptr) { return plane.mode_qstabilize._enter();
plane.control_mode = plane.previous_mode;
} else {
plane.auto_state.vtol_mode = true;
}
return true;
} }
void ModeQAcro::update() void ModeQAcro::update()

View File

@ -3,12 +3,10 @@
bool ModeQStabilize::_enter() bool ModeQStabilize::_enter()
{ {
if (!plane.quadplane.init_mode() && plane.previous_mode != nullptr) { if (!plane.quadplane.init_mode()) {
plane.control_mode = plane.previous_mode; return false;
} else {
plane.auto_state.vtol_mode = true;
} }
plane.auto_state.vtol_mode = true;
return true; return true;
} }

View File

@ -246,15 +246,8 @@ bool Plane::set_mode(Mode &new_mode, const ModeReason reason)
// we failed entering new mode, roll back to old // we failed entering new mode, roll back to old
previous_mode = &old_previous_mode; previous_mode = &old_previous_mode;
control_mode = &old_mode; control_mode = &old_mode;
control_mode_reason = previous_mode_reason; control_mode_reason = previous_mode_reason;
// currently, only Q modes can fail enter(). This will likely change in the future and all modes
// should be changed to check dependencies and fail early before depending on changes in Mode::set_mode()
if (control_mode->is_vtol_mode()) {
// ignore result because if we fail we risk looping at the qautotune check above
control_mode->enter();
}
// make sad noise // make sad noise
if (reason != ModeReason::INITIALISED) { if (reason != ModeReason::INITIALISED) {
AP_Notify::events.user_mode_change_failed = 1; AP_Notify::events.user_mode_change_failed = 1;