Skip to content

Commit

Permalink
commander: improve logic for ekf2 preflight check
Browse files Browse the repository at this point in the history
With this change we prevent the case where arming silently fails within
the first 10 seconds after boot.

Also, we now set the sensors as healthy as soon as the ekf is healthy,
and don't wait 10 seconds without actually checking.
  • Loading branch information
julianoes authored and dagar committed Mar 19, 2021
1 parent 2f024a9 commit a134598
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/modules/commander/Arming/PreFlightCheck/PreFlightCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,19 @@ bool PreFlightCheck::preflightCheck(orb_advert_t *mavlink_log_pub, vehicle_statu
}

if (estimator_type == 2) {
bool ekf_healthy = false;

// don't report ekf failures for the first 10 seconds to allow time for the filter to start
if (time_since_boot > 10_s) {
const bool ekf_healthy = ekf2Check(mavlink_log_pub, status, false, report_failures) &&
ekf2CheckSensorBias(mavlink_log_pub, report_failures);

ekf_healthy = ekf2Check(mavlink_log_pub, status, false, report_failures) &&
ekf2CheckSensorBias(mavlink_log_pub, report_failures);
// For the first 10 seconds the ekf2 can be unhealthy, and we just mark it
// as not present.
// After that or if report_failures is true, we'll set the flags as is.

set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_AHRS, true, true, ekf_healthy, status);
if (!ekf_healthy && time_since_boot < 10_s && !report_failures) {
set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_AHRS, true, false, false, status);

} else {
set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_AHRS, true, false, false, status);
set_health_flags(subsystem_info_s::SUBSYSTEM_TYPE_AHRS, true, true, ekf_healthy, status);
}

failed |= !ekf_healthy;
Expand Down

0 comments on commit a134598

Please sign in to comment.