From 2317b5fe8d5afcfd7f2e3ec32c1523ca88798988 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Mon, 27 Jul 2020 18:49:34 -0400 Subject: [PATCH] Disable GPS RESCUE if mixer is fixed-wing type GPS Rescue flight control logic only knows how to fly multirotors and engaging GPS Rescue on a fixed-wing craft would result in an immediate loss of control and crash. For example, when GPS Rescue is engaged it attempts to yaw to the home direction heading and this won't work on fixed wing (particularly the flying wing mixer with no rudder). Next it tries to attain the target altitude exclusively with throttle control - not how altitude is controlled with a fix-wing aircraft. Also the GPS Rescue no-fix arming prevention logic shouldn't be applied. --- src/main/config/config.c | 2 +- src/main/flight/mixer.c | 10 +++++++--- src/main/flight/mixer.h | 1 + src/main/msp/msp_box.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index 75afdac76..a82df3ab8 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -372,7 +372,7 @@ static void validateAndFixConfig(void) #endif if ( - featureIsConfigured(FEATURE_3D) || !featureIsConfigured(FEATURE_GPS) + featureIsConfigured(FEATURE_3D) || !featureIsConfigured(FEATURE_GPS) || mixerModeIsFixedWing(mixerConfig()->mixerMode) #if !defined(USE_GPS) || !defined(USE_GPS_RESCUE) || true #endif diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index ab993e561..576d643c1 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -992,10 +992,9 @@ mixerMode_e getMixerMode(void) return currentMixerMode; } - -bool isFixedWing(void) +bool mixerModeIsFixedWing(mixerMode_e mixerMode) { - switch (currentMixerMode) { + switch (mixerMode) { case MIXER_FLYING_WING: case MIXER_AIRPLANE: case MIXER_CUSTOM_AIRPLANE: @@ -1008,3 +1007,8 @@ bool isFixedWing(void) break; } } + +bool isFixedWing(void) +{ + return mixerModeIsFixedWing(currentMixerMode); +} diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index e5cf091e2..4b923a896 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -115,4 +115,5 @@ bool mixerIsTricopter(void); void mixerSetThrottleAngleCorrection(int correctionValue); float mixerGetThrottle(void); mixerMode_e getMixerMode(void); +bool mixerModeIsFixedWing(mixerMode_e mixerMode); bool isFixedWing(void); diff --git a/src/main/msp/msp_box.c b/src/main/msp/msp_box.c index 4c1bbaed2..e5c98b896 100644 --- a/src/main/msp/msp_box.c +++ b/src/main/msp/msp_box.c @@ -214,7 +214,7 @@ void initActiveBoxIds(void) #ifdef USE_GPS if (featureIsEnabled(FEATURE_GPS)) { #ifdef USE_GPS_RESCUE - if (!featureIsEnabled(FEATURE_3D)) { + if (!featureIsEnabled(FEATURE_3D) && !isFixedWing()) { BME(BOXGPSRESCUE); } #endif