From 1f2fc723b99c8ca5991a1ef4248368b9f5672fae Mon Sep 17 00:00:00 2001 From: Mykhailo Tomashivskyi Date: Thu, 26 Sep 2024 09:23:25 +0300 Subject: [PATCH] AP_GPS: Ignore Z-axis difference while dual GPS difference check --- libraries/AP_GPS/AP_GPS.cpp | 7 ++++++- libraries/AP_GPS/AP_GPS.h | 1 + libraries/AP_GPS/AP_GPS_MAV.cpp | 1 + libraries/AP_GPS/GPS_Backend.cpp | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/AP_GPS/AP_GPS.cpp b/libraries/AP_GPS/AP_GPS.cpp index 070276dd45c9fc..2c3b522ed2e6fa 100644 --- a/libraries/AP_GPS/AP_GPS.cpp +++ b/libraries/AP_GPS/AP_GPS.cpp @@ -1490,7 +1490,12 @@ bool AP_GPS::all_consistent(float &distance) const } // calculate distance - distance = state[0].location.get_distance_NED(state[1].location).length(); + if (state[0].have_altitude && state[1].have_altitude) { + distance = state[0].location.get_distance_NED(state[1].location).length(); + } else { + distance = state[0].location.get_distance_NE(state[1].location).length(); + } + // success if distance is within 50m return (distance < 50); } diff --git a/libraries/AP_GPS/AP_GPS.h b/libraries/AP_GPS/AP_GPS.h index a3c814ffc241f8..25ebf903041d2c 100644 --- a/libraries/AP_GPS/AP_GPS.h +++ b/libraries/AP_GPS/AP_GPS.h @@ -216,6 +216,7 @@ class AP_GPS bool have_vertical_accuracy; ///< does GPS give vertical position accuracy? Set to true only once available. bool have_gps_yaw; ///< does GPS give yaw? Set to true only once available. bool have_gps_yaw_accuracy; ///< does the GPS give a heading accuracy estimate? Set to true only once available + bool have_altitude; ///< does GPS give altitude? Set to false only if GPS instance does not provide altitude. float undulation; //