-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bandwidth, rates and calibration #8
Comments
Hi Tuomas, I have been a little sloppy in the way I hand data to the sensor fusion But, yes, you must recenter the magnetometer response surface to the origin You must get the axes alignment right when handing to the sensor fusion My general rule of thumb is to pick the sample rate to be four or five times Hope this helps, and please ask other questions as you have them. Kris Hi Kris, Thank you for your information about the sensor fusion topic. Filing an I've been trying to get my own 168MHz STM32F4/ChibiOS based setup running Just in case you are interested, here's my lsm9ds0 driver: And my copy'paste of the original Madwick's algorithm (with some googled To the questions:
https://github.com/kriswiner/LSM9DS0/blob/master/Teensy3.1/LSM9DS0-MS5637/LS Or did I understand that wrong? I'm not doing that at all. How big impact
So are the correct sensor axis directions listed somewhere? From e.g.: // Sensors x- and y-axes are aligned but magnetometer z-axis (+ down) is Thank you! Reply to this email directly or view it on GitHub |
Thanks for the explanations. I think my axis are correct as I'm using the same sensor as you are and I don't see you doing any swapping of them. I started disconnecting the AHRS loop from the sensor loop. Next would be changing the rate and bandwidth settings to match yours. And finally I'll add the magnetometer calibration. That'll take awhile but I'll let you know how it goes. |
Hi kris, Based on your 9250 code, I wrote a piece of firmware for my STMF401 sensor board which is connected with a MPU9250 through SPI. The obtained Quaternion values are as showed below: ax = 4.211426 ay = -39.550781 az = -23.498535 mg FYI, below I attached the printf messages during the init stage: MPU9250 initialized for active data mode.... magCalibration {72.0000, 184.0000, 171.0000} Sorry, I am new in this IMU Quaternion concept; have little idea on how to verify the data I get. |
Well, there seems to be a problem with the accelerometer. If the sensor is Once you get the accel straightened out,you can work on the mag Kris Hi kris, Based on your 9250 code, I wrote a piece of firmware for my STMF401 sensor ax = 4.211426 ay = -39.550781 az = -23.498535 mg FYI, below I attached the printf messages during the init stage: MPU9250 initialized for active data mode.... magCalibration {72.0000, 184.0000, 171.0000} Sorry, I am new in this IMU Quaternion concept; have little idea on how to Reply to this email directly or view it on GitHub |
yeah, you are right. The Accelerometer readings are far way off. |
I've finally got the "disconnected" AHRS loop working and I've been experimenting with magnetometer calibration as well. No real improvements though. I've understood that I should be able to calculate the magnetic heading with atan(y/x) assuming the sensor is flat and still on the table? How accurate should that be? Comparing my calibrated magnetometer heading to a traditional compass, I get -20° difference when pointing to magnetic north, -7° pointing east, +21° pointing south and +8° when pointing west. I assume it shouldn't be that far off? I've ordered one IMU shield now from Sparkfun just to compare it to this my self-made. |
I would recommend that you plot Mx vs Mz and My vs Mz for your magnetometer to see how bad the offset and skew are. I suspect your mag is not properly calibrated and this will lead to large deviations of the heading. I have been doing some testing with the LSM9DS0 whose results you can see here: https://github.com/kriswiner/MPU-6050/wiki/9-DoF-Motion-Sensor-Bakeoff The tangent is an approximation, you should rather derive the Euler angles from the quaternion that results from sensor fusion. I am disappointed that you didn't buy one of my LSM9DS0 breakout at my Tindie store ;/! Did you use my LSM9DS0 sketch? There are mag calibration and open-source sensor fusion algorithms there that might be useful. You should be able to get better heading results that this. |
I've plotted the values and tried to calibrate the magnetometer by applied the offset and scaling based on the minimums and maximums. http://tuomas.kulve.fi/tmp/magn-values-sphere-lsm9ds0-realraw.png I think your LSM9DS0 breakout board might be better as it doesn't have the GND plane below the sensor while the Sparkfun's sensor does. I bought the Photon LSM9DS1 shield as I'm planning to use other Photon shields as well. I'm using your open-source sensor fusion algorithms but the calibration I did manually with spreadsheets and hard coded the values. And I calculated the simple heading just to test the magnetometer behaviour as I still see some "crawling" along the yaw axis. Pitch and roll behave really well but yaw slowly crawls some 10-40° after I stop rotating the sensor. I had to reverse the magnetometer z-axis of my LSM9DS0 to get roughly correct yaw direction when I change the pitch of the sensor. Without reversing, the yaw always changed a lot when I tilted the sensor. I'm still puzzled why I had to do that because I don't see you doing anything similar in your code with LSM9DS0 (I did notice you do that for LSM9DS1 as it's z-axis is reversed compared to LSM9DS0). |
It looks like you still have significant offset in your mag data as well as the expected skew. You might need to collect min/max data for a longer time or do the calibration dynamically to account for changes in either the magnetometer or its environment. You really need 9 DoF sensor fusion to avoid the kind of yaw drift you describe. The magnetometer will dynamically correct the gyro drift which leads directly to yaw crawl. See if the yaw is better behaved with the Madgwick or Mahoney fusion filter. Kris |
Just FYI: I changed my plans and ordered your LSM9DS1 shield with the MS5611 pressure sensor. |
Hi Tuomas, Kris, Please help me. I am using LSM9DS0 in my project; I am facing the exact same issue Tuomas mentioned in his post on July 13 2015 : There is a error in magnetic heading calculated using atan(y/x); the error is as large as 30 degrees between traditional compass and the heading from LSM9DS0. I have tried AHRS. For all the testing I am keeping LSM9DS0 flat on the surface; so there is no tilt. Can you please share, how did you resolve above issue? |
Sorry for the slow reply. I didn't solve my issues even with the LSM9DS1 sensor. I do plan to try again later when I again have more time. |
I don't really remember what the specific issue was but most issues can be -----Original Message----- Sorry for the slow reply. I didn't solve my issues even with the LSM9DS1 You are receiving this because you commented. |
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!
The text was updated successfully, but these errors were encountered: