Class WelfordCovarianceProvider

Inheritance Relationships

Base Type

Class Documentation

class WelfordCovarianceProvider : public adi_imu::ImuCovarianceInterface

Computes covariance online using Welford’s algorithm.

This provider collects samples during the calibration phrase (IMU should be stationary) and computes variance using Welford’s numerically stable online algorithm. After calibration_samples are collected, the covariance is frozen and returned for all subsequent queries.

Reference: Welford, B. P. (1962). “Note on method for calculating

corrected sum of squares and products”

Public Functions

explicit WelfordCovarianceProvider(size_t calibration_samples = DEFAULT_CALIBRATION_SAMPLES, double min_variance = DEFAULT_MIN_VARIANCE)
virtual void addSample(const Vec3 &accel, const Vec3 &gyro) override

Process a new IMU sample for covariance estimation.

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

  • gyro – Angular velocity sample (rad/s)

virtual bool isReady() const override

Check if covariance estimation is ready (calibration complete).

Returns:

true if covariance values are valid and ready to use.

virtual CovarianceMatrix getAccelCovariance() const override

Get the linear acceleration covariance matrix.

Returns:

3x3 covariance matrix row-major order.

virtual CovarianceMatrix getGyroCovariance() const override

Get the angular velocity covariance matrix.

Returns:

3x3 covariance matrix row-major order.

virtual void reset() override

Reset the covariance extimator to initial state.

virtual double getCalibrationProgress() const override

Get the current calibration progress (0.0 to 1.0).

Returns:

Progress ratio, 1.0 when calibration is complete.

Public Static Attributes

static constexpr size_t DEFAULT_CALIBRATION_SAMPLES = 1000
static constexpr double DEFAULT_MIN_VARIANCE = 1e-9