Introduction

Documentation Status Discord Build Status Code Style: Black

AHRS library for CircuitPython

This library contains right now one alogrithm for AHRS - Attitude and Heading Reference System. It is used to combine multiple sensor values to give a heading, pitch and roll value such as used by aircraft.

See the Wiki for a more complete description.

Dependencies

This library depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Usage Example

Create the filter, set the parameters and start feeding it sensor data

filter = mahony.Mahony(Kp, Ki, sample_frequency)

while True:
        filter.update(gx, gy, gz, ax, ay, az, mx, my, mz)

Caution

The calculations are very processor intensive. I have tested this on an Adafruit Feather M4 Express. Mahony was able to do about 300 samples/sec Madgwick was only able to about 15 samples/sec

Also be careful which values you feed the filter and the orientation of your sensor. I turned the gryoscope/accelerometer off to make sure magnetic fields were correct and then turned on only the gyroscope/accelerometer to ensure they were correct.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Documentation

Indices and tables