diff --git a/libraries/AP_Arming/AP_Arming.cpp b/libraries/AP_Arming/AP_Arming.cpp index 85be140159..cd13390e9c 100644 --- a/libraries/AP_Arming/AP_Arming.cpp +++ b/libraries/AP_Arming/AP_Arming.cpp @@ -332,11 +332,23 @@ bool AP_Arming::ins_checks(bool report) bool AP_Arming::compass_checks(bool report) { + Compass &_compass = AP::compass(); + + // check if compass is calibrating + if (_compass.is_calibrating()) { + check_failed(ARMING_CHECK_COMPASS, report, "Compass calibration running"); + return false; + } + + // check if compass has calibrated and requires reboot + if (_compass.compass_cal_requires_reboot()) { + check_failed(ARMING_CHECK_COMPASS, report, "Compass calibrated requires reboot"); + return false; + } + if ((checks_to_perform) & ARMING_CHECK_ALL || (checks_to_perform) & ARMING_CHECK_COMPASS) { - Compass &_compass = AP::compass(); - // avoid Compass::use_for_yaw(void) as it implicitly calls healthy() which can // incorrectly skip the remaining checks, pass the primary instance directly if (!_compass.use_for_yaw(_compass.get_primary())) { @@ -354,18 +366,6 @@ bool AP_Arming::compass_checks(bool report) return false; } - //check if compass is calibrating - if (_compass.is_calibrating()) { - check_failed(ARMING_CHECK_COMPASS, report, "Compass calibration running"); - return false; - } - - //check if compass has calibrated and requires reboot - if (_compass.compass_cal_requires_reboot()) { - check_failed(ARMING_CHECK_COMPASS, report, "Compass calibrated requires reboot"); - return false; - } - // check for unreasonable compass offsets const Vector3f offsets = _compass.get_offsets(); if (offsets.length() > _compass.get_offsets_max()) {