From 2512b73106c705203fc47fe43b3eff802c516675 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Sep 2018 12:37:18 +1000 Subject: [PATCH] AP_GPS: added ability to disable GPS this is used for GPS loss testing in real vehicles, by linking it to a RCn_OPTION value. GPS position is still logged, but is not used --- libraries/AP_GPS/AP_GPS.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libraries/AP_GPS/AP_GPS.h b/libraries/AP_GPS/AP_GPS.h index 61be8a60b5..78b581e3c8 100644 --- a/libraries/AP_GPS/AP_GPS.h +++ b/libraries/AP_GPS/AP_GPS.h @@ -188,6 +188,9 @@ public: /// Query GPS status GPS_Status status(uint8_t instance) const { + if (_force_disable_gps && state[instance].status > NO_FIX) { + return NO_FIX; + } return state[instance].status; } GPS_Status status(void) const { @@ -417,6 +420,11 @@ public: // returns true if all GPS instances have passed all final arming checks/state changes bool prepare_for_arming(void); + // used to disable GPS for GPS failure testing in flight + void force_disable(bool disable) { + _force_disable_gps = disable; + } + protected: // configuration parameters @@ -555,6 +563,9 @@ private: GPS_AUTO_CONFIG_DISABLE = 0, GPS_AUTO_CONFIG_ENABLE = 1 }; + + // used for flight testing with GPS loss + bool _force_disable_gps; }; namespace AP {