fix(ekf2): register a lockstep component in replay mode

The replay barrier only waited for the logger, so the next imu sample
could be published before ekf2, running on a work queue, had consumed the
previous one.

Assisted-by: Claude:claude-opus-5[1m]
Signed-off-by: bresch <brescianimathieu@gmail.com>
This commit is contained in:
bresch authored and Mathieu Bresciani committed 2026-09-22 16:01:46 +02:00
1 parent 4aeaafef8e
commit b16eebf1fe
2 files changed
+15

No files matched your search

+14
View File
@@ -226,6 +226,7 @@ EKF2::EKF2(bool multi_mode, const px4::wq_config_t &config, bool replay_mode):
EKF2::~EKF2()
{
px4_lockstep_unregister_component(_lockstep_component);
perf_free(_ekf_update_perf);
perf_free(_msg_missed_imu_perf);
}
@@ -509,6 +510,13 @@ void EKF2::Run()
ScheduleDelayed(10_ms);
return;
}
if (_replay_mode) {
// let the replay module wait for this instance: it publishes the next imu sample only
// once every registered component reported progress, and without this the estimator
// (running on a work queue) can be handed a new sample before it consumed the last one
_lockstep_component = px4_lockstep_register_component();
}
}
if (_vehicle_command_sub.updated()) {
@@ -888,6 +896,12 @@ void EKF2::Run()
// re-schedule as backup timeout
ScheduleDelayed(100_ms);
if (imu_updated && _replay_mode) {
// releases the replay module to publish the next sample, so nothing of this update may be
// left to do below
px4_lockstep_progress(_lockstep_component);
}
}
void EKF2::VerifyParams()
+1
View File
@@ -279,6 +279,7 @@ private:
static constexpr float sq(float x) { return x * x; };
const bool _replay_mode{false}; ///< true when we use replay data from a log
int _lockstep_component{-1}; ///< replay only: barrier the replay module waits on
const bool _multi_mode;
int _instance{0};