jmagnuson / ahrs-rs

A Rust port of Madgwick's AHRS algorithm
MIT License
33 stars 19 forks source link

Adding no_std support #12

Closed careyk007 closed 4 years ago

careyk007 commented 4 years ago

In response to #11, I was able to get the filter running on an STM32F4 microcontroller.

jmagnuson commented 4 years ago

That's awesome, thanks! How was the performance on the F4? The current implementation is a pretty direct translation from the paper, and is hopefully able to approach a hand-optimized solution in terms of performance.

careyk007 commented 4 years ago

Happy to help! With some quick and dirty testing, it looks like the full update takes about 600 microseconds, or 60,000 clock cycles on my F4.

I tested this by running my timer interrupt triggered update loop (sample IMU data, update filter) as fast as it could go without missing an interrupt, then running just my IMU sample code as fast as it could go without missing an interrupt. The full update was able to go up to 1kHz while the IMU sample code was able to go up to 2.5kHz.

From the paper, it seemed that an update speed of 100Hz offered the best trade-off between accuracy and processing time, so there should be plenty of leftover processing time for interesting applications with the F4!