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

Copy Markdown View Source

Mahony AHRS filter, 6-DOF IMU variant, implemented as a BB.Estimator.

Uses a Proportional-Integral controller to fuse gyroscope and accelerometer measurements. Computationally cheaper than Madgwick and particularly robust under sustained drift.

Usage

sensor :imu, BB.Sensor.SomeImu, ... do
  estimator :orientation, {BB.Estimator.Ahrs.Mahony, kp: 2.0, ki: 0.005}
end

Options

  • :kp — proportional gain on the accel/mag error vector. Default 2.0.
  • :ki — integral gain (gyro bias estimation). Default 0.0 (P-only).
  • :accel_threshold — accepted deviation of |accel| / g from 1.0 before the correction is suppressed. Default 0.1.
  • :e_int_limit — anti-windup clamp on the integral term. Default 100.0.

Ported from gworkman/ahrs' Ahrs.Mahony.

Summary

Functions

Runs one Mahony step. gyro is rad/s, accel is m/s², dt is seconds. Returns the updated state.

Types

t()

@type t() :: %BB.Estimator.Ahrs.Mahony{
  accel_threshold: float(),
  e_int: {float(), float(), float()},
  e_int_limit: float(),
  ki: float(),
  kp: float(),
  last_monotonic_time: integer() | nil,
  q: BB.Estimator.Ahrs.Quaternion.t()
}

Functions

step(state, gyro, accel, dt)

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

Runs one Mahony step. gyro is rad/s, accel is m/s², dt is seconds. Returns the updated state.