fix(ekf2/commander): split no-heading-source from heading-innovation-failure (#27215)

* fix(ekf2,commander): split "no heading source" from heading-innovation-failure

The pre_flt_fail_innov_heading flag conflated two distinct conditions: bad
heading innovations and the absence of any heading source. Optical-flow-only
quad setups (no magnetometer, no GNSS yaw, no external-vision yaw) never set
yaw_align, so the flag latched true and produced a misleading
"Preflight Fail: heading estimate invalid" message in modes that don't
actually depend on heading.

EKF2: pre_flt_fail_innov_heading now reports innovation failures only.
Commander: a new branch consumes estimator_status_flags.cs_yaw_align (when
fresh) to block heading-required modes (POSCTL, AUTO_*, ORBIT, AUTO_LAND,
FW AUTO_TAKEOFF) when no source is present, with a new "no heading
reference" message. The branch only fires for fresh estimator_status_flags
data so external-INS drivers (MicroStrain, VectorNav, ILabs, sbgecom) that
don't publish the flags topic retain prior behaviour. PR #26778's
mode-scoping and PR #26596's silent-pass protection are both preserved.

Resolves #27107.

* style: trim source comments per review

* Apply suggestions from code review

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>

* refactor(commander): move no-heading-source check into checkEstimatorStatusFlags

* Update src/modules/commander/HealthAndArmingChecks/checks/estimatorCheck.cpp

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>

---------

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
G. AmponisandJacob Dahl authored and GitHub committed 2026-05-07 11:17:17 -06:00
1 parent 095f5a48c6
commit 7db998e017
2 files changed
+23 -1

No files matched your search

@@ -625,6 +625,28 @@ void EstimatorChecks::checkEstimatorStatusFlags(const Context &context, Report &
mavlink_log_critical(reporter.mavlink_log_pub(), "GNSS heading not reliable - Land now!\t");
}
}
if (!context.isArmed()
&& (hrt_absolute_time() - estimator_status_flags.timestamp < 5_s)
&& !estimator_status_flags.cs_yaw_align) {
const NavModes heading_required_groups = (NavModes)(
reporter.failsafeFlags().mode_req_local_position |
reporter.failsafeFlags().mode_req_local_position_relaxed |
(1u << vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF));
/* EVENT
* @description
* No heading source has aligned the EKF yaw
*/
reporter.armingCheckFailure(heading_required_groups, health_component_t::local_position_estimate,
events::ID("check_estimator_heading_no_source"),
events::Log::Error, "No heading reference");
if (reporter.mavlink_log_pub()) {
mavlink_log_critical(reporter.mavlink_log_pub(), "Preflight Fail: no heading reference");
}
}
}
}
+1 -1
View File
@@ -1987,7 +1987,7 @@ void EKF2::PublishStatus(const hrt_abstime &timestamp)
status.time_slip = _last_time_slip_us * 1e-6f;
static constexpr float kMinTestRatioPreflight = 0.5f;
status.pre_flt_fail_innov_heading = (kMinTestRatioPreflight < status.hdg_test_ratio) || !_ekf.control_status_flags().yaw_align;
status.pre_flt_fail_innov_heading = (kMinTestRatioPreflight < status.hdg_test_ratio);
status.pre_flt_fail_innov_height = (kMinTestRatioPreflight < status.hgt_test_ratio);
status.pre_flt_fail_innov_pos_horiz = (kMinTestRatioPreflight < status.pos_test_ratio);
status.pre_flt_fail_innov_vel_horiz = (kMinTestRatioPreflight < vel_xy_test_ratio);