Class MotionDetector

Class Documentation

class MotionDetector

Detects whether the IMU is stationary based on sensor readings.

Uses simple thresholding on gyroscope magnitude and accelerometer deviation from gravity to determine stationarity. This allows covariance estimators to only update during stationary periods, avoiding motion-induced variance inflation.

Public Functions

explicit MotionDetector(double gyro_threshold = DEFAULT_GYRO_THRESHOLD, double accel_threshold = DEFAULT_ACCEL_THRESHOLD)

Construct motion detector with configurable thresholds.

Parameters:
  • gyro_threshold – Max gyro magnitude to consider stationary (rad/s)

  • accel_threshold – Max accel deviation from gravity (m/s^2)

bool isStationary(const Vec3 &accel, const Vec3 &gyro) const

Check if the sensor is stationary based on current readings.

Parameters:
  • accel – Linear acceleration sample (m/s^2)

  • gyro – Angular velocity sample (rad/s)

Returns:

true if sensor appears stationary

void setGyroThreshold(double threshold)

Set the gyroscope threshold for stationarity.

Parameters:

threshold – Max angular velocity magnitude (rad/s)

void setAccelThreshold(double threshold)

Set the accelerometer threshold for stationarity.

Parameters:

threshold – Max deviation from gravity (m/s^2)

inline double getGyroThreshold() const

Get current gyroscope threshold.

inline double getAccelThreshold() const

Get current accelerometer threshold.

inline void setEnabled(bool enabled)

Enable or disable motion detection. When disabled, isStationary() always returns true.

inline bool isEnabled() const

Check if motion detection is enabled.

Public Static Attributes

static constexpr double DEFAULT_GYRO_THRESHOLD = 0.05
static constexpr double DEFAULT_ACCEL_THRESHOLD = 0.5
static constexpr double GRAVITY_MAGNITUDE = 9.81