m5stack / M5StickC

M5StickC Arduino Library
MIT License
477 stars 222 forks source link

Mahony AHRS implement in IMU example is wrong. #125

Open Menginventor opened 3 years ago

Menginventor commented 3 years ago

In MahonyAHRS.cpp specify update frequency to 25Hz but the example use delay of 1000 ms. So the algorith is wrong and this code is useless.

geiseri commented 3 years ago

Ignore their copy, it uses hardcoded and global variables that are for the most part wrong. Just use the https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/ version and save yourself tons of heartache. You can replace their MPU6886::getAhrsData. Also, note that samples will be a bit off unless you can ensure that the average sample rate is in fact what you put in the Mahony::begin(...). In my case, I ended up getting the average time for the "loop" call for a few seconds and then using that for the sampling frequency. Sadly you will find the numbers are pretty much garbage though due to #124.

Menginventor commented 3 years ago

Hmm what the product.... I really hope some bugfix from the source.

geiseri commented 3 years ago

Oh, these guys have sweet hardware, but their code is a trainwreck :) I am actually working on consolidating them all right now. The StickC is awesome for ESPHome.