#fusion #nxp #sensor #adafruit #port #python-bindings #filter

nightly bin+lib ahrs-fusion

Port of NXP Sensor Fusion (as written by Adafruit)

4 releases (breaking)

0.4.0 May 16, 2022
0.3.0 May 14, 2022
0.2.0 Feb 8, 2022
0.1.0 Dec 18, 2021

#1382 in Hardware support

Custom license

88KB
1.5K SLoC

C++ 1K SLoC // 0.4% comments Rust 262 SLoC C 4 SLoC

AHRS Fusion

Port of Adafruit NXP sensor fusion algorithms based on Kalman filters for rust.

Linking

This library is no_std, and e.g. on ARM you need to provide implementations for sinf(..) and the likes. The easiest way to do that is to just extern link to e.g.: cmsis_dsp (see this link for more explanation) and selecting one of the implementations to provide the math functions.

To use micromath:

$ cargo add cmsis_dsp --features micromath

if you are not using the cmsis_dsp library, also add the following to your crate:

extern crate cmsis_dsp;

Python bindings

You can also use this small library through Python bindings. Enter the python directory and install using pip or e.g. maturin develop --release in your virtual environment.

Using from the command-line

There is also a small command line utility that takes as its argument the frequency, and reads accelerometer and gyroscope from stdin as CSV. It outputs the rotated acceleration for every line. It can be built or installed by enabling the build-bin feature flag:

$ cargo install --feature build-bin --path .
$ echo 1,2,3,4,5,6 | ahrs-csv 10

Resources

Dependencies

~0–8.5MB
~56K SLoC