fix(commander): skip preflight checks until topics are advertised (#27341)

On boards with a slow startup sequence (e.g. FMU-V6XRT), the health
checks run before load_mon and ekf2 have published their first message,
producing spurious "Preflight Fail" entries in dmesg.

Gate the cpuload and estimator_status checks on
uORB::Subscription::advertised(). While the topic has never been
advertised the publisher has not started yet, so skip the check
silently. Once advertised, missing or stale data is reported as before
so real failures are still caught.

Signed-off-by: SofianElmotiem <sofianelmotiem@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
This commit is contained in:
Sofian Elmotiem
2026-05-17 20:38:48 +02:00
committed by GitHub
parent b990430cdc
commit 5e86770e05
2 changed files with 13 additions and 7 deletions
@@ -50,6 +50,10 @@ void CpuResourceChecks::checkAndReport(const Context &context, Report &reporter)
return;
}
if (!_cpuload_sub.advertised()) {
return;
}
cpuload_s cpuload;
if (!_cpuload_sub.copy(&cpuload) || hrt_elapsed_time(&cpuload.timestamp) > 2_s) {
@@ -109,14 +109,16 @@ void EstimatorChecks::checkAndReport(const Context &context, Report &reporter)
}
if (missing_data && (param_ekf2_en == 1)) {
/* EVENT
*/
reporter.armingCheckFailure(required_groups, health_component_t::local_position_estimate,
events::ID("check_estimator_missing_data"),
events::Log::Info, "Waiting for estimator to initialize");
if (_estimator_status_sub.advertised()) {
/* EVENT
*/
reporter.armingCheckFailure(required_groups, health_component_t::local_position_estimate,
events::ID("check_estimator_missing_data"),
events::Log::Info, "Waiting for estimator to initialize");
if (reporter.mavlink_log_pub()) {
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: ekf2 missing data");
if (reporter.mavlink_log_pub()) {
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: ekf2 missing data");
}
}
} else {