Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #6392 from s0up/rescue-disarm-fix
Browse files Browse the repository at this point in the history
Fix rescue early disarm when sanity checks are on
  • Loading branch information
mikeller committed Jul 19, 2018
1 parent be8cf14 commit d33ac80
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main/flight/gps_rescue.c
Expand Up @@ -71,7 +71,7 @@ PG_RESET_TEMPLATE(gpsRescueConfig_t, gpsRescueConfig,
.throttleMin = 1200,
.throttleMax = 1600,
.throttleHover = 1280,
.sanityChecks = 0,
.sanityChecks = RESCUE_SANITY_ON,
.minSats = 8
);

Expand Down Expand Up @@ -123,6 +123,19 @@ void updateGPSRescueState(void)
hoverThrottle = gpsRescueConfig()->throttleHover;
}

// Minimum distance detection (100m). Disarm regardless of sanity check configuration. Rescue too close is never a good idea.
if (rescueState.sensor.distanceToHome < 100) {
// Never allow rescue mode to engage as a failsafe within 100 meters or when disarmed.
if (rescueState.isFailsafe || !ARMING_FLAG(ARMED)) {
rescueState.failure = RESCUE_TOO_CLOSE;
setArmingDisabled(ARMING_DISABLED_ARM_SWITCH);
disarm();
} else {
// Leave it up to the sanity check setting
rescueState.failure = RESCUE_TOO_CLOSE;
}
}

rescueState.phase = RESCUE_ATTAIN_ALT;
FALLTHROUGH;
case RESCUE_ATTAIN_ALT:
Expand Down Expand Up @@ -284,11 +297,6 @@ void performSanityChecks()
if (msI == 5) {
rescueState.failure = RESCUE_FLYAWAY;
}

// Minimum distance detection (100m)
if (rescueState.sensor.distanceToHome < 100) {
rescueState.failure = RESCUE_TOO_CLOSE;
}
}

void rescueStart()
Expand Down

0 comments on commit d33ac80

Please sign in to comment.