From bc7f811ff04f2d7b47cc2662d575b77b33a5dd7c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 28 Nov 2019 13:41:29 +1100 Subject: [PATCH] AP_GPS: cope with UAVCAN GPS that don't provide Aux message thanks to @VadimZ for the suggestion --- libraries/AP_GPS/AP_GPS_UAVCAN.cpp | 14 ++++++++++++++ libraries/AP_GPS/AP_GPS_UAVCAN.h | 1 + 2 files changed, 15 insertions(+) diff --git a/libraries/AP_GPS/AP_GPS_UAVCAN.cpp b/libraries/AP_GPS/AP_GPS_UAVCAN.cpp index f4f9a68f5d..80d58faf0e 100644 --- a/libraries/AP_GPS/AP_GPS_UAVCAN.cpp +++ b/libraries/AP_GPS/AP_GPS_UAVCAN.cpp @@ -240,6 +240,12 @@ void AP_GPS_UAVCAN::handle_fix_msg(const FixCb &cb) interim_state.num_sats = 0; } + if (!seen_aux) { + // if we haven't seen an Aux message then populate vdop and + // hdop from pdop. Some GPS modules don't provide the Aux message + interim_state.hdop = interim_state.vdop = cb.msg->pdop * 100.0; + } + interim_state.last_gps_time_ms = AP_HAL::millis(); _new_data = true; @@ -336,6 +342,12 @@ void AP_GPS_UAVCAN::handle_fix2_msg(const Fix2Cb &cb) interim_state.num_sats = 0; } + if (!seen_aux) { + // if we haven't seen an Aux message then populate vdop and + // hdop from pdop. Some GPS modules don't provide the Aux message + interim_state.hdop = interim_state.vdop = cb.msg->pdop * 100.0; + } + interim_state.last_gps_time_ms = AP_HAL::millis(); _new_data = true; @@ -355,10 +367,12 @@ void AP_GPS_UAVCAN::handle_aux_msg(const AuxCb &cb) WITH_SEMAPHORE(sem); if (!uavcan::isNaN(cb.msg->hdop)) { + seen_aux = true; interim_state.hdop = cb.msg->hdop * 100.0; } if (!uavcan::isNaN(cb.msg->vdop)) { + seen_aux = true; interim_state.vdop = cb.msg->vdop * 100.0; } } diff --git a/libraries/AP_GPS/AP_GPS_UAVCAN.h b/libraries/AP_GPS/AP_GPS_UAVCAN.h index 32c636dfa2..6e1607ef6d 100644 --- a/libraries/AP_GPS/AP_GPS_UAVCAN.h +++ b/libraries/AP_GPS/AP_GPS_UAVCAN.h @@ -65,6 +65,7 @@ private: bool seen_message; bool seen_fix2; + bool seen_aux; // Module Detection Registry static struct DetectedModules {