m/3dof: Add assert for timestamp paranoia

This commit is contained in:
Jakob Bornecrantz 2021-03-14 18:39:13 +00:00
parent c73146c6fd
commit a71b3d35d1
2 changed files with 5 additions and 0 deletions

View file

@ -0,0 +1 @@
m/3dof: Add assert to catch time traveling drivers.

View file

@ -19,6 +19,7 @@
#include "math/m_mathinclude.h"
#include <stdio.h>
#include <assert.h>
#define DUR_1S_IN_NS (1000 * 1000 * 1000)
#define DUR_300MS_IN_NS (300 * 1000 * 1000)
@ -183,6 +184,9 @@ m_imu_3dof_update(struct m_imu_3dof *f,
return;
}
// This code assumes all timestamps makes some forward progress.
assert(timestamp_ns >= f->last.timestamp_ns);
f->last.gyro = *gyro;
f->last.accel = *accel;