BB.Estimator.Ahrs.Complementary (bb_estimator_ahrs v0.1.0)

Copy Markdown View Source

Complementary filter for 6-DOF IMUs, implemented as a BB.Estimator.

Integrates the gyroscope (high-pass) and blends in an accelerometer- derived tilt estimate (low-pass) using a fixed weight or a time constant.

Usage

sensor :imu, BB.Sensor.SomeImu, ... do
  estimator :orientation, {BB.Estimator.Ahrs.Complementary, alpha: 0.98}
end

Options

  • :alpha — fixed gyro weight, 0.0..1.0. Default 0.98 (98% gyro, 2% accel per update).
  • :time_constant — optional time constant τ in seconds. When set, overrides :alpha with τ / (τ + dt), making the filter frequency-independent.
  • :accel_threshold — accepted deviation of |accel| / g from 1.0 before the correction is suppressed. Default 0.1.

Ported from gworkman/ahrs' Ahrs.Complementary.

Summary

Functions

Runs one Complementary filter step.

Types

t()

@type t() :: %BB.Estimator.Ahrs.Complementary{
  accel_threshold: float(),
  alpha: float(),
  last_monotonic_time: integer() | nil,
  q: BB.Estimator.Ahrs.Quaternion.t(),
  time_constant: nil | float()
}

Functions

step(state, gyro, accel, dt)

@spec step(t(), {float(), float(), float()}, {float(), float(), float()}, float()) ::
  t()

Runs one Complementary filter step.