Skip to content

Commit

Permalink
failsafe: set cause to generic when fallback mode is activated
Browse files Browse the repository at this point in the history
Previously when triggering low battery RTL and then losing GPS, the fallback
to Descend would still have low battery as cause.
  • Loading branch information
bkueng authored and sfuhrer committed Mar 15, 2024
1 parent da39d07 commit 70346a5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/modules/commander/failsafe/framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,48 +517,62 @@ void FailsafeBase::getSelectedAction(const State &state, const failsafe_flags_s
break;
}

returned_state.cause = Cause::Generic;

// fallthrough
case Action::FallbackAltCtrl:
if (modeCanRun(status_flags, vehicle_status_s::NAVIGATION_STATE_ALTCTL)) {
selected_action = Action::FallbackAltCtrl;
break;
}

returned_state.cause = Cause::Generic;

// fallthrough
case Action::FallbackStab:
if (modeCanRun(status_flags, vehicle_status_s::NAVIGATION_STATE_STAB)) {
selected_action = Action::FallbackStab;
break;
} // else: fall through here as well. If stabilized isn't available, we most certainly end up in Terminate

returned_state.cause = Cause::Generic;

// fallthrough
case Action::Hold:
if (modeCanRun(status_flags, vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER)) {
selected_action = Action::Hold;
break;
}

returned_state.cause = Cause::Generic;

// fallthrough
case Action::RTL:
if (modeCanRun(status_flags, vehicle_status_s::NAVIGATION_STATE_AUTO_RTL)) {
selected_action = Action::RTL;
break;
}

returned_state.cause = Cause::Generic;

// fallthrough
case Action::Land:
if (modeCanRun(status_flags, vehicle_status_s::NAVIGATION_STATE_AUTO_LAND)) {
selected_action = Action::Land;
break;
}

returned_state.cause = Cause::Generic;

// fallthrough
case Action::Descend:
if (modeCanRun(status_flags, vehicle_status_s::NAVIGATION_STATE_DESCEND)) {
selected_action = Action::Descend;
break;
}

returned_state.cause = Cause::Generic;

// fallthrough
case Action::Terminate:
selected_action = Action::Terminate;
Expand Down

0 comments on commit 70346a5

Please sign in to comment.