fix commander: make sure to count all valid mags in preflight check

Previously, if a mag was not required (not index 0 and not used by ekf),
it was not counted in num_enabled_and_valid_calibration.
If a user set SYS_HAS_MAG to e.g. 3, it would then trigger a preflight
failure, even if there were 3 calibrated and enabled mags.
This commit is contained in:
Beat Küng
2024-05-31 15:59:38 +02:00
committed by Daniel Agar
parent 53210dd8f3
commit ca112fea8a
@@ -50,10 +50,6 @@ void MagnetometerChecks::checkAndReport(const Context &context, Report &reporter
bool is_mag_fault = false;
const bool is_required = instance == 0 || isMagRequired(instance, is_mag_fault);
if (!is_required) {
continue;
}
const bool exists = _sensor_mag_sub[instance].advertised();
bool is_valid = false;
bool is_calibration_valid = false;
@@ -83,6 +79,11 @@ void MagnetometerChecks::checkAndReport(const Context &context, Report &reporter
reporter.setIsPresent(health_component_t::magnetometer);
}
// Do not raise errors if a mag is not required
if (!is_required) {
continue;
}
const bool is_sensor_ok = is_valid && is_calibration_valid && !is_mag_fault;
if (!is_sensor_ok) {