Madgwick better than Kalman filter for IMU/AHRS using 6 or 9 degree of freedom MEMS sensor?
Rayman
Posts: 14,646
in Propeller 2
Working on getting the LSM9DS1 (9DOF Mems) sensor working on P2.
Was thinking that I'd use C to implement a Kalman filter.
But, just today I noticed Adafruit writing about something that looks better:
https://learn.adafruit.com/how-to-fuse-motion-sensor-data-into-ahrs-orientation-euler-quaternions
That took here:
https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/
Madgwick claims his approach is better for microcontrollers with similar performance as Kalman filter.
There are versions for both 6 and 9 DOF sensors.
Code does look fairly compact although there is a lot of stuff that makes me still want to do it in C.
Guess I'll see what Fastspin makes of it...
License is not clear. The original code does not appear to have any license.
The version that Adafruit points to appears to have a LGPL license.
Was thinking that I'd use C to implement a Kalman filter.
But, just today I noticed Adafruit writing about something that looks better:
https://learn.adafruit.com/how-to-fuse-motion-sensor-data-into-ahrs-orientation-euler-quaternions
That took here:
https://x-io.co.uk/open-source-imu-and-ahrs-algorithms/
Madgwick claims his approach is better for microcontrollers with similar performance as Kalman filter.
There are versions for both 6 and 9 DOF sensors.
Code does look fairly compact although there is a lot of stuff that makes me still want to do it in C.
Guess I'll see what Fastspin makes of it...
License is not clear. The original code does not appear to have any license.
The version that Adafruit points to appears to have a LGPL license.
Comments
The problem of fusing sensor data to produce orientation parameters was addressed in the Prop1 Elev8 flight controller.
The libraries detailed in this Elev8 summary sheet may be useful for your quest.
I'll have to see where that algorithm came from...
Looks like it uses quaternion math like Madgwick does...
https://forums.parallax.com/discussion/167164/imu-roll-angle-correct-when-stopped-wrong-when-moving
Roll and pitch seem to work, but I can't get yaw to come out making any sense...
Think I'll start over and try to port some working code over to P2.
There's a few out there like these with acceptable licenses:
https://github.com/kriswiner/LSM9DS1
https://github.com/lythaniel/YapiBot/tree/master/src
That first one looks better at the moment as it seems to include some magnetic sensor calibration code.
Adafruit says you need calibration and use the program from here to do it: https://www.pjrc.com/store/prop_shield.html
I tried it out, but need to get the data in proper format. Think I'll skip that part and try the kriswiner way first...
Think I've decided that I really have to do a better job with calibration of magnetic sensors.
Also, I probably shouldn't have put a uSD connector right next to this chip
https://learn.adafruit.com/adafruit-sensorlab-magnetometer-calibration/magnetic-calibration-with-motioncal
Fortunately, I came across another tool, Magneto 1.2: https://sites.google.com/site/sailboatinstruments1/home
This one takes input from a text file, so that should be a lot more straightforward.
One interesting thing is that you have to supply a "norm" value.
But, reading this blog: https://thecavepearlproject.org/2015/05/22/calibrating-any-compass-or-accelerometer-for-arduino/
It seems any value will do because Madgwick doesn't care about the units...
Still, I think I'll try to use the NOAA or BGS values to give units of Gauss.