Skip to content

Commit

Permalink
Detect system time jump back
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat committed Apr 23, 2024
1 parent 3925394 commit 0c230bf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/control_vehicle.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,15 @@ void control_loop(void)
const double dt = now - last_time;
const double dt_error = dt - expected_dt;
last_time = now;
if (dt < 0)
{
yprintf(
OUTPUT_LV_ERROR,
"Detected system time jump back, monotonic time diff: %0.5fs, system time diff: %0.5fs\n",
expected_dt, dt);
static int status = EXIT_FAILURE;
pthread_exit(&status);
}
if (dt_error < -p(YP_PARAM_MAX_TIME_JUMP_NEG, 0) || p(YP_PARAM_MAX_TIME_JUMP, 0) < dt_error)
{
yprintf(
Expand Down

0 comments on commit 0c230bf

Please sign in to comment.