From 22425bab4694ca5d25515a987a3d24246de1fcb5 Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Mon, 1 Jul 2024 21:38:13 -0300 Subject: [PATCH 1/2] AP_Compass: use ahrs for location instead of GPS directly for calibration --- libraries/AP_Compass/CompassCalibrator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Compass/CompassCalibrator.cpp b/libraries/AP_Compass/CompassCalibrator.cpp index 57a374987c571..3b917c4bd7a62 100644 --- a/libraries/AP_Compass/CompassCalibrator.cpp +++ b/libraries/AP_Compass/CompassCalibrator.cpp @@ -1065,14 +1065,14 @@ bool CompassCalibrator::calculate_orientation(void) */ bool CompassCalibrator::fix_radius(void) { - if (AP::gps().status() < AP_GPS::GPS_OK_FIX_2D) { + Location loc; + if (!AP::ahrs().get_location(loc) && !AP::ahrs().get_origin(loc)) { // we don't have a position, leave scale factor as 0. This // will disable use of WMM in the EKF. Users can manually set // scale factor after calibration if it is known _params.scale_factor = 0; return true; } - const Location &loc = AP::gps().location(); float intensity; float declination; float inclination; From 8ece859f32ea8c82ec644a492dd3e748073a445e Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Mon, 1 Jul 2024 21:38:50 -0300 Subject: [PATCH 2/2] AP_Compass: warn user if fix_radius() is skipped --- libraries/AP_Compass/CompassCalibrator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/AP_Compass/CompassCalibrator.cpp b/libraries/AP_Compass/CompassCalibrator.cpp index 3b917c4bd7a62..8845ba260e57c 100644 --- a/libraries/AP_Compass/CompassCalibrator.cpp +++ b/libraries/AP_Compass/CompassCalibrator.cpp @@ -1067,6 +1067,7 @@ bool CompassCalibrator::fix_radius(void) { Location loc; if (!AP::ahrs().get_location(loc) && !AP::ahrs().get_origin(loc)) { + GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "MagCal: No location, fix_radius skipped"); // we don't have a position, leave scale factor as 0. This // will disable use of WMM in the EKF. Users can manually set // scale factor after calibration if it is known