From 648a21f11d4ce3c56c47d3000767b7ec31aa08c3 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 4 May 2021 12:17:17 +0200 Subject: [PATCH] commander: ignore calibration in HITL The calibration is not found in HITL mode. Therefore, I suggest to ignore this step and assume the calibration is fine. This mostly fixes the preflight check indicator in QGC, arming was (for some reason?) already possible. --- .../Arming/PreFlightCheck/checks/accelerometerCheck.cpp | 7 ++++++- .../commander/Arming/PreFlightCheck/checks/gyroCheck.cpp | 7 ++++++- .../Arming/PreFlightCheck/checks/magnetometerCheck.cpp | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp b/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp index b762e66ed5..cf1eeef756 100644 --- a/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp +++ b/src/modules/commander/Arming/PreFlightCheck/checks/accelerometerCheck.cpp @@ -65,7 +65,12 @@ bool PreFlightCheck::accelerometerCheck(orb_advert_t *mavlink_log_pub, vehicle_s device_id = accel.get().device_id; - calibration_valid = (calibration::FindCalibrationIndex("ACC", device_id) >= 0); + if (status.hil_state == vehicle_status_s::HIL_STATE_ON) { + calibration_valid = true; + + } else { + calibration_valid = (calibration::FindCalibrationIndex("ACC", device_id) >= 0); + } if (!calibration_valid) { if (report_fail) { diff --git a/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp b/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp index 47477b26cc..ca09bd526e 100644 --- a/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp +++ b/src/modules/commander/Arming/PreFlightCheck/checks/gyroCheck.cpp @@ -64,7 +64,12 @@ bool PreFlightCheck::gyroCheck(orb_advert_t *mavlink_log_pub, vehicle_status_s & device_id = gyro.get().device_id; - calibration_valid = (calibration::FindCalibrationIndex("GYRO", device_id) >= 0); + if (status.hil_state == vehicle_status_s::HIL_STATE_ON) { + calibration_valid = true; + + } else { + calibration_valid = (calibration::FindCalibrationIndex("GYRO", device_id) >= 0); + } if (!calibration_valid) { if (report_fail) { diff --git a/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp b/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp index e35b05308f..713405e867 100644 --- a/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp +++ b/src/modules/commander/Arming/PreFlightCheck/checks/magnetometerCheck.cpp @@ -66,7 +66,12 @@ bool PreFlightCheck::magnetometerCheck(orb_advert_t *mavlink_log_pub, vehicle_st device_id = magnetometer.get().device_id; - calibration_valid = (calibration::FindCalibrationIndex("MAG", device_id) >= 0); + if (status.hil_state == vehicle_status_s::HIL_STATE_ON) { + calibration_valid = true; + + } else { + calibration_valid = (calibration::FindCalibrationIndex("MAG", device_id) >= 0); + } if (!calibration_valid) { if (report_fail) {