Hi Kris,
Thank you for your information about the sensor fusion topic. Filing an issue against your code is quite misleading as I'm not even using it (directly anyway) but I'm hoping you have some suggestions for me.
I've been trying to get my own 168MHz STM32F4/ChibiOS based setup running for quite some time without success. It reacts well to change (I guess my gyroscope math are working properly) but when I stop rotating the sensor, yaw typically crawls for the next 10 seconds to some value (something wrong with my magnetometer math?).
Just in case you are interested, here's my lsm9ds0 driver:
https://github.com/snowcap-electronics/control-board/blob/master/drivers/sc_lsm9ds0.c
And my copy'paste of the original Madwick's algorithm (with some googled updates, I'll probably update that to match yours):
https://github.com/snowcap-electronics/control-board/blob/master/src/sc_ahrs.c
To the questions:
-
I have set all sensors to roughly 100Hz (gyro is 95Hz). I'm waiting to get a reading from all of them and then I run the AHRS math. I noticed that you are using quite different rates for each of them and run the AHRS math when ever you get a reading from any of them. Why 10Hz (or 25Hz) magnetometer rate instead of 100Hz? Do you happen to have any pointers to docs about rate and bandwidth and how to pick them?
-
I just realised that it seems that in magnetometer calibration you want to find the maximums for each axis in each direction and then calculate the "origin" as the bias:
https://github.com/kriswiner/LSM9DS0/blob/master/Teensy3.1/LSM9DS0-MS5637/LSM9DS0_MS5637_Mini_Add_On.ino#L808
Or did I understand that wrong? I'm not doing that at all. How big impact could that give? Could that alone be the reason why my yaw crawls so much when I stop rotating it?
- I noticed that LSM9DS0 and LSM9DS1 have their magnetometer Z-axis pointing in opposite directions. Does the AHRS algorithm assume some direction? Currently I'm assuming all sensors point to right directions for the Madwick's algorithm and I haven't been able to confirm if that's ok.
So are the correct sensor axis directions listed somewhere?
From e.g.:
https://github.com/sparkfun/LSM9DS0_Breakout/blob/master/Libraries/Arduino/SFE_LSM9DS0/examples/LSM9DS0_AHRS/LSM9DS0_AHRS.ino#L267
// Sensors x- and y-axes are aligned but magnetometer z-axis (+ down) is opposite to z-axis (+ up) of accelerometer and gyro!
// This is ok by aircraft orientation standards!
Thank you!
Hi Kris,
Thank you for your information about the sensor fusion topic. Filing an issue against your code is quite misleading as I'm not even using it (directly anyway) but I'm hoping you have some suggestions for me.
I've been trying to get my own 168MHz STM32F4/ChibiOS based setup running for quite some time without success. It reacts well to change (I guess my gyroscope math are working properly) but when I stop rotating the sensor, yaw typically crawls for the next 10 seconds to some value (something wrong with my magnetometer math?).
Just in case you are interested, here's my lsm9ds0 driver:
https://github.com/snowcap-electronics/control-board/blob/master/drivers/sc_lsm9ds0.c
And my copy'paste of the original Madwick's algorithm (with some googled updates, I'll probably update that to match yours):
https://github.com/snowcap-electronics/control-board/blob/master/src/sc_ahrs.c
To the questions:
I have set all sensors to roughly 100Hz (gyro is 95Hz). I'm waiting to get a reading from all of them and then I run the AHRS math. I noticed that you are using quite different rates for each of them and run the AHRS math when ever you get a reading from any of them. Why 10Hz (or 25Hz) magnetometer rate instead of 100Hz? Do you happen to have any pointers to docs about rate and bandwidth and how to pick them?
I just realised that it seems that in magnetometer calibration you want to find the maximums for each axis in each direction and then calculate the "origin" as the bias:
https://github.com/kriswiner/LSM9DS0/blob/master/Teensy3.1/LSM9DS0-MS5637/LSM9DS0_MS5637_Mini_Add_On.ino#L808
Or did I understand that wrong? I'm not doing that at all. How big impact could that give? Could that alone be the reason why my yaw crawls so much when I stop rotating it?
So are the correct sensor axis directions listed somewhere?
From e.g.:
https://github.com/sparkfun/LSM9DS0_Breakout/blob/master/Libraries/Arduino/SFE_LSM9DS0/examples/LSM9DS0_AHRS/LSM9DS0_AHRS.ino#L267
// Sensors x- and y-axes are aligned but magnetometer z-axis (+ down) is opposite to z-axis (+ up) of accelerometer and gyro!
// This is ok by aircraft orientation standards!
Thank you!