Skip to content

Commit

Permalink
fix commander: make sure to count all valid mags in preflight check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bkueng authored and dagar committed May 31, 2024
1 parent 53210dd commit ca112fe
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit ca112fe

Please sign in to comment.