mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-30 12:50:35 +08:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user