From 347f5238d6ffee5a8d1804d4c5c3f9d2ee505805 Mon Sep 17 00:00:00 2001 From: Matej Petrlik Date: Tue, 23 Apr 2024 09:36:43 +0200 Subject: [PATCH] added check for large dt when using event.last_real --- src/estimators/altitude/alt_generic.cpp | 2 +- src/estimators/heading/hdg_generic.cpp | 2 +- src/estimators/lateral/lat_generic.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/estimators/altitude/alt_generic.cpp b/src/estimators/altitude/alt_generic.cpp index 80fae06..ab3b6b9 100644 --- a/src/estimators/altitude/alt_generic.cpp +++ b/src/estimators/altitude/alt_generic.cpp @@ -329,7 +329,7 @@ void AltGeneric::timerUpdate(const ros::TimerEvent &event) { } double dt = (event.current_real - event.last_real).toSec(); - if (dt <= 0.0) { + if (dt <= 0.0 || dt > 1.0) { return; } diff --git a/src/estimators/heading/hdg_generic.cpp b/src/estimators/heading/hdg_generic.cpp index cedb4ce..79d0ecd 100644 --- a/src/estimators/heading/hdg_generic.cpp +++ b/src/estimators/heading/hdg_generic.cpp @@ -302,7 +302,7 @@ void HdgGeneric::timerUpdate(const ros::TimerEvent &event) { } double dt = (event.current_real - event.last_real).toSec(); - if (dt <= 0.0) { + if (dt <= 0.0 || dt > 1.0) { return; } diff --git a/src/estimators/lateral/lat_generic.cpp b/src/estimators/lateral/lat_generic.cpp index 7ece255..a6ae1c4 100644 --- a/src/estimators/lateral/lat_generic.cpp +++ b/src/estimators/lateral/lat_generic.cpp @@ -340,7 +340,7 @@ void LatGeneric::timerUpdate(const ros::TimerEvent &event) { // obtain dt for state prediction double dt = (event.current_real - event.last_real).toSec(); - if (dt <= 0.0) { // sometimes the timer ticks twice simultaneously in simulation - we ignore the second tick + if (dt <= 0.0 || dt > 1.0) { // sometimes the timer ticks twice simultaneously in simulation - we ignore the second tick, in case of stopping and starting the timer, the last_real is 0 return; }