AP_Arming: only compare AHRS vs GPS if GPS is enabled

This commit is contained in:
Randy Mackay 2022-12-13 17:47:04 +09:00
parent ba234330d9
commit cb39bd72d3
1 changed files with 9 additions and 7 deletions

View File

@ -598,13 +598,15 @@ bool AP_Arming::gps_checks(bool report)
}
// check AHRS and GPS are within 10m of each other
const Location gps_loc = gps.location();
Location ahrs_loc;
if (AP::ahrs().get_location(ahrs_loc)) {
const float distance = gps_loc.get_distance(ahrs_loc);
if (distance > AP_ARMING_AHRS_GPS_ERROR_MAX) {
check_failed(ARMING_CHECK_GPS, report, "GPS and AHRS differ by %4.1fm", (double)distance);
return false;
if (gps.num_sensors() > 0) {
const Location gps_loc = gps.location();
Location ahrs_loc;
if (AP::ahrs().get_location(ahrs_loc)) {
const float distance = gps_loc.get_distance(ahrs_loc);
if (distance > AP_ARMING_AHRS_GPS_ERROR_MAX) {
check_failed(ARMING_CHECK_GPS, report, "GPS and AHRS differ by %4.1fm", (double)distance);
return false;
}
}
}
}