Skip to content
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

Question about the yaw axis (magnetometer) values #8

Open
ssokol opened this issue Jun 19, 2013 · 9 comments
Open

Question about the yaw axis (magnetometer) values #8

ssokol opened this issue Jun 19, 2013 · 9 comments

Comments

@ssokol
Copy link

ssokol commented Jun 19, 2013

David,

I've been working with the unit and the code for several days now and have noticed that:

  1. even after calibration the "north" value does not correlate with magnetic north as shown by my trusty Siva compass. It appears to be off by ~-15 degrees.

  2. if I rotate the device a perfect 180 from the perceived 0 to its opposite, the device reads not 180 but 200

  3. If I create a correction factor of 15 degrees to "true up" the north reading, then swing the device around 180 it reads 224 (!?!?)

Is the Euler value output corrected for "true" north vs. magnetic north?

I've tried moving the mounting around to several place (it's currently attached to the outside of the plastic housing that contains the Raspberry Pi) with similar results.

Any suggestions? I've re-run the calibration utility multiple times. Am I simply expecting too much from the sensor? Does it need to be attached to a dongle that is several feet from the Pi? (How long can you extend an i2c connection?)

Many thanks for your advice.

@thesummer
Copy link

I don't know about your particular setup, but the magnetometer is the flakiest part of the sensor and unfortunately the only information you have for the yaw-axis.
I used parts of David's code in a different project, but have an own magnetometer calibration procedure (because I thought the one used here is quite simplistic, but I also didn't get really through the python code). It uses an ellipsoid fit, so you get a matrix which describes the scaling and rotation effects due to soft iron and misalignment errors and an offset vector due to the hard iron effects.
If there is some interest, I can see if I can dig for the files. As far as I remember the results where ok, meaning for a certain timespan and in a certain environment. If you calibrate it e.g. in your room and then take the IMU outside, it can make a big difference because of the hard and soft iron errors caused by metals and cables in your walls.

@DavidEGrayson
Copy link
Owner

Hello, @ssokol. The Euler values are relative to magnetic north and the code doesn't know about true north. Yes, I think you might be expecting too much from the device, but if you want more accuracy then an advanced calibration method like the one @thesummer suggests might be a good idea. minimu9-ahrs does give you access to the raw data so you could plot it and try to figure out the best way to calibrate the magnetometer. When I plotted the data in OpenOffice Calc for my setup it looked like a stretched and translated ellipsoid. I totally agree that the magnetometer is the flakiest part of the sensor.

@ssokol
Copy link
Author

ssokol commented Jun 19, 2013

@DavidEGrayson Thanks for the response. I may look into the more detailed calibration method but it's not mission critical in this instance as my project also includes a GPS which can provide the heading. I'm fairly sure that there is a way to overcome the issue as there are similar MEMS-based AHRS products on the market (see http://www.aviation.levil.com/AHRS_micro_DataSheet.pdf) that claim 0.1 degree resolution.

@thesummer If you happen across the code you used for calibration I would grateful. I've tried reducing interference by taking the unit out into the yard to calibrate and test, but the issue remains. Not sure how to do the calibration motion with the unit mounted in a plane -- it's not aerobatic so the range of motion is relatively limited (if you want to live).

@cgridley
Copy link

I found this article from another AHRS vendor helpful in understanding the calibration process: http://www.vectornav.com/Downloads/Support/AN012.pdf

@ssokol Of course specs for "resolution" are not the same as specs for "accuracy", but it does seem like you should be able to get better results than you describe.

@thesummer
Copy link

Ok. I found the calibration file and edited it, so I can share it without embarrassing myself ;-)
You can find the two python files and some sample data here: https://gist.github.com/thesummer/c4361e3fc14644ceb829
If you call the calibrator with the -p option it will generate a plot (if matplotlib is present) where it plots a unit sphere in yellow, the raw data as red dots and the raw data after applying the calibration as blue dots. Be aware that the unit sphere may look like an ellipsoid because matplotlib somehow does not obey the aspect ratio when resizing the window (suggestions are welcome).
In David's code you basically only have to edit these 2 files IIRC: https://gist.github.com/thesummer/1d46580527424d63aa8c

I didn't have the time to test it again, but I think it should work or at least give you an idea. In general I would be interested to know if this method really yields better results for you.

Best regards,

Jan

@thesummer
Copy link

@ssokol Out of curiosity, have you had a chance to test the other magnetometer calibration?

@ssokol
Copy link
Author

ssokol commented Jun 25, 2013

Unfortunately not yet. Family and job seem to take up too much time... Will reply when I have done.

Sent from my iPhone

On Jun 24, 2013, at 8:09 PM, Jan Sommer notifications@github.com wrote:

@ssokol Out of curiosity, have you had a chance to test the other magnetometer calibration?


Reply to this email directly or view it on GitHub.

@ssokol
Copy link
Author

ssokol commented Jul 3, 2013

@thesummer Finally got a chance to try out your code. I've not yet taken out the old Silva compass for the ultimate comparison, but the rough value is MUCH closer to what I would expect. I'm going flying tomorrow and I'll let you all know how it works out in the "target environment".

@DavidEGrayson
Copy link
Owner

I'll keep this issue open because @thesummer's new calibration script and his modifications to my code look like they might be useful, especially since @ssokol said the result was "MUCH closer". My current calibration script (in minimu9-ahrs version 2.0.0) takes about 18 minutes to run and sometimes produces totally invalid calibrations (along with a warning), so there is room for improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants