From a68fe4dbd7512fa7c9e5b55d33b902c89b570b65 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sat, 31 Oct 2020 15:36:41 -0400 Subject: [PATCH] ekf2: move parameter update to beginning of cycle --- src/modules/ekf2/EKF2.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/modules/ekf2/EKF2.cpp b/src/modules/ekf2/EKF2.cpp index 7f986bd26d..635a44dfb3 100644 --- a/src/modules/ekf2/EKF2.cpp +++ b/src/modules/ekf2/EKF2.cpp @@ -251,6 +251,16 @@ void EKF2::Run() } } + // check for parameter updates + if (_parameter_update_sub.updated()) { + // clear update + parameter_update_s pupdate; + _parameter_update_sub.copy(&pupdate); + + // update parameters from storage + updateParams(); + } + bool updated = false; imuSample imu_sample_new {}; @@ -297,17 +307,6 @@ void EKF2::Run() } if (updated) { - - // check for parameter updates - if (_parameter_update_sub.updated()) { - // clear update - parameter_update_s pupdate; - _parameter_update_sub.copy(&pupdate); - - // update parameters from storage - updateParams(); - } - const hrt_abstime now = imu_sample_new.time_us; // ekf2_timestamps (using 0.1 ms relative timestamps)