From 407cfc22cad4f4e0ead44f9d464cf65a6dd539f7 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 18 Jul 2023 18:33:59 +1000 Subject: [PATCH] AP_GPS: remove code if blended instance is not available --- libraries/AP_Arming/AP_Arming.cpp | 2 ++ libraries/AP_GPS/AP_GPS.cpp | 11 ++++++++--- libraries/AP_GPS/AP_GPS.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libraries/AP_Arming/AP_Arming.cpp b/libraries/AP_Arming/AP_Arming.cpp index c735236b6a..44a045ff5d 100644 --- a/libraries/AP_Arming/AP_Arming.cpp +++ b/libraries/AP_Arming/AP_Arming.cpp @@ -618,10 +618,12 @@ bool AP_Arming::gps_checks(bool report) (double)distance_m); return false; } +#if defined(GPS_BLENDED_INSTANCE) if (!gps.blend_health_check()) { check_failed(ARMING_CHECK_GPS, report, "GPS blending unhealthy"); return false; } +#endif // check AHRS and GPS are within 10m of each other if (gps.num_sensors() > 0) { diff --git a/libraries/AP_GPS/AP_GPS.cpp b/libraries/AP_GPS/AP_GPS.cpp index 62ec572a26..c6e24f10a3 100644 --- a/libraries/AP_GPS/AP_GPS.cpp +++ b/libraries/AP_GPS/AP_GPS.cpp @@ -470,8 +470,10 @@ void AP_GPS::init(const AP_SerialManager& serial_manager) } _last_instance_swap_ms = 0; +#if defined(GPS_BLENDED_INSTANCE) // Initialise class variables used to do GPS blending _omega_lpf = 1.0f / constrain_float(_blend_tc, 5.0f, 30.0f); +#endif // prep the state instance fields for (uint8_t i = 0; i < GPS_MAX_INSTANCES; i++) { @@ -491,11 +493,12 @@ void AP_GPS::init(const AP_SerialManager& serial_manager) // GPS solution is treated as an additional sensor. uint8_t AP_GPS::num_sensors(void) const { - if (!_output_is_blended) { - return num_instances; - } else { +#if defined(GPS_BLENDED_INSTANCE) + if (_output_is_blended) { return num_instances+1; } +#endif + return num_instances; } bool AP_GPS::speed_accuracy(uint8_t instance, float &sacc) const @@ -1542,11 +1545,13 @@ bool AP_GPS::all_consistent(float &distance) const return (distance < 50); } +#if defined(GPS_BLENDED_INSTANCE) // pre-arm check of GPS blending. True means healthy or that blending is not being used bool AP_GPS::blend_health_check() const { return (_blend_health_counter < 50); } +#endif /* re-assemble fragmented RTCM data diff --git a/libraries/AP_GPS/AP_GPS.h b/libraries/AP_GPS/AP_GPS.h index ed66955ae5..83d271e6e0 100644 --- a/libraries/AP_GPS/AP_GPS.h +++ b/libraries/AP_GPS/AP_GPS.h @@ -730,6 +730,7 @@ private: void inject_data(const uint8_t *data, uint16_t len); void inject_data(uint8_t instance, const uint8_t *data, uint16_t len); +#if defined(GPS_BLENDED_INSTANCE) // GPS blending and switching Vector3f _blended_antenna_offset; // blended antenna offset float _blended_lag_sec; // blended receiver lag in seconds @@ -743,6 +744,7 @@ private: // calculate the blended state void calc_blended_state(void); +#endif bool should_log() const;