From 7996a1a70fe29445799122f3566a7edf47895cb6 Mon Sep 17 00:00:00 2001 From: bresch Date: Wed, 10 Aug 2022 15:04:52 +0200 Subject: [PATCH] ekf2: reset ekf preflight checks on takeoff correctly Using the control status flags isn't robust as this part of the code runs at the EKF update rate while the in_air transition is don at the prediction rate. It was then likely to miss the transition --- src/modules/ekf2/EKF2.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/ekf2/EKF2.cpp b/src/modules/ekf2/EKF2.cpp index a2d72c3ec5..6dd698fee6 100644 --- a/src/modules/ekf2/EKF2.cpp +++ b/src/modules/ekf2/EKF2.cpp @@ -558,6 +558,8 @@ void EKF2::Run() _gyro_cal = {}; _mag_cal = {}; + _preflt_checker.reset(); + } else if (was_in_air && !in_air) { // landed _ekf.set_in_air_status(false); @@ -900,10 +902,6 @@ void EKF2::PublishInnovations(const hrt_abstime ×tamp) _preflt_checker.setUsingEvHgtAiding(_ekf.control_status_flags().ev_hgt); _preflt_checker.update(_ekf.get_imu_sample_delayed().delta_ang_dt, innovations); - - } else if (_ekf.control_status_flags().in_air != _ekf.control_status_prev_flags().in_air) { - // reset preflight checks if transitioning back to landed - _preflt_checker.reset(); } }