Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/flight/failsafe.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ typedef enum {
} failsafeChannelBehavior_e;

typedef struct {
bool bypassNavigation;
bool forceAngleMode;
failsafeChannelBehavior_e channelBehavior[4];
} failsafeProcedureLogic_t;

static const failsafeProcedureLogic_t failsafeProcedureLogic[] = {
[FAILSAFE_PROCEDURE_AUTO_LANDING] = {
.bypassNavigation = true,
.forceAngleMode = true,
.channelBehavior = {
FAILSAFE_CHANNEL_AUTO, // ROLL
Expand All @@ -99,6 +101,7 @@ static const failsafeProcedureLogic_t failsafeProcedureLogic[] = {
},

[FAILSAFE_PROCEDURE_DROP_IT] = {
.bypassNavigation = true,
.forceAngleMode = true,
.channelBehavior = {
FAILFAFE_CHANNEL_NEUTRAL, // ROLL
Expand All @@ -109,6 +112,7 @@ static const failsafeProcedureLogic_t failsafeProcedureLogic[] = {
},

[FAILSAFE_PROCEDURE_RTH] = {
.bypassNavigation = false,
.forceAngleMode = true,
.channelBehavior = {
FAILFAFE_CHANNEL_NEUTRAL, // ROLL
Expand All @@ -119,6 +123,7 @@ static const failsafeProcedureLogic_t failsafeProcedureLogic[] = {
},

[FAILSAFE_PROCEDURE_NONE] = {
.bypassNavigation = false,
.forceAngleMode = false,
.channelBehavior = {
FAILSAFE_CHANNEL_HOLD, // ROLL
Expand Down Expand Up @@ -160,6 +165,11 @@ void failsafeInit(void)
}

#ifdef NAV
bool failsafeBypassNavigation(void)
{
return failsafeState.active && failsafeState.controlling && failsafeProcedureLogic[failsafeConfig()->failsafe_procedure].bypassNavigation;
}

bool failsafeMayRequireNavigationMode(void)
{
return failsafeConfig()->failsafe_procedure == FAILSAFE_PROCEDURE_RTH;
Expand Down
1 change: 1 addition & 0 deletions src/main/flight/failsafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void failsafeApplyControlInput(void);
bool failsafeRequiresAngleMode(void);
bool failsafeRequiresMotorStop(void);
bool failsafeShouldApplyControlInput(void);
bool failsafeBypassNavigation(void);
void failsafeUpdateRcCommandValues(void);

void failsafeOnValidDataReceived(void);
Expand Down
5 changes: 5 additions & 0 deletions src/main/navigation/navigation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,11 @@ static navigationFSMEvent_t selectNavEventFromBoxModeInput(void)

//We can switch modes only when ARMED
if (ARMING_FLAG(ARMED)) {
// Ask failsafe system if we can use navigation system
if (failsafeBypassNavigation()) {
return NAV_FSM_EVENT_SWITCH_TO_IDLE;
}

// Flags if we can activate certain nav modes (check if we have required sensors and they provide valid data)
bool canActivateAltHold = canActivateAltHoldMode();
bool canActivatePosHold = canActivatePosHoldMode();
Expand Down