From b3c227160037d8f5d5c6c074f93fb7e65990dc1e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 16 Feb 2024 10:37:34 +1100 Subject: [PATCH] AP_ExternalAHRS: added support for GPS disable and fwd flight allow backends to determine if we are in fixed wing flight and/or the GPS is disabled by the user --- libraries/AP_ExternalAHRS/AP_ExternalAHRS.h | 10 +++++++++- .../AP_ExternalAHRS/AP_ExternalAHRS_backend.cpp | 6 ++++++ .../AP_ExternalAHRS/AP_ExternalAHRS_backend.h | 14 +++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h b/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h index dfc81532c2734..e3a3a992cdecd 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS.h @@ -165,7 +165,12 @@ class AP_ExternalAHRS { float differential_pressure; // Pa float temperature; // degC } airspeed_data_message_t; - + + // set GNSS disable for auxillary function GPS_DISABLE + void set_gnss_disable(bool disable) { + gnss_is_disabled = disable; + } + protected: enum class OPTIONS { @@ -195,6 +200,9 @@ class AP_ExternalAHRS { } uint32_t last_log_ms; + + // true when user has disabled the GNSS + bool gnss_is_disabled; }; namespace AP { diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.cpp b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.cpp index eaff493f5af3f..94cf8c41b7d2b 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.cpp +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.cpp @@ -17,6 +17,7 @@ */ #include "AP_ExternalAHRS_backend.h" +#include #if HAL_EXTERNAL_AHRS_ENABLED @@ -37,5 +38,10 @@ bool AP_ExternalAHRS_backend::option_is_set(AP_ExternalAHRS::OPTIONS option) con return frontend.option_is_set(option); } +bool AP_ExternalAHRS_backend::in_fly_forward(void) const +{ + return AP::ahrs().get_fly_forward(); +} + #endif // HAL_EXTERNAL_AHRS_ENABLED diff --git a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h index 02eb1b5319b7d..ed987a01ced3a 100644 --- a/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h +++ b/libraries/AP_ExternalAHRS/AP_ExternalAHRS_backend.h @@ -57,7 +57,19 @@ class AP_ExternalAHRS_backend { void set_default_sensors(uint16_t sensors) { frontend.set_default_sensors(sensors); } - + + /* + return true if the GNSS is disabled + */ + bool gnss_is_disabled(void) const { + return frontend.gnss_is_disabled; + } + + /* + return true when we are in fixed wing flight + */ + bool in_fly_forward(void) const; + private: AP_ExternalAHRS &frontend; };