Closed stenbergd closed 8 years ago
Full scale is set to 1.3 Gauss as earth's magnetic field vector is .5 Gauss according to Wikipedia.
Very good, should give us more than enough wiggle-room for any magnetic interference.
There are some datasheet and application notes from ST on calibrating the magnetometer.
I previously implemented an algorithm that would compensate for hard-iron and soft-iron distortion of magnetometer readings. You basically need to turn the quadcopter/fcb board 360 degrees around all of its 3 axes to calibrate it, but will likely only need to do this once.
Anyway, the link in the OP suggests an improvement on what I did and also provides a fun mathematical optimization method!
Hard-iron offset it pure scaling of x, y, z measurement axes.
Soft-iron offset has distorted/skewed the magnetometer measurement sphere.
We will start with the hard-iron offset. If we do not have any strong magnetic sources on-board, this will most likely be sufficient to gather good measurements.
Also, we may not need to use float values (Gauss values). Raw values enough if we want to calc attitude with magnetometer?
Perhaps we will use values normed into the unit sphere?
General advice for doing numerical solutions (from link in 1st post)
Choosing parameters that are about the same order of magnitude leads to stable, reliable performance. because we avoid over/underflow of floating-point values.
Our floats are 32 bit, under&overflow is unlikely.
consider offline calibration by reading the values to a file, then doing the Gauss-Newton Least Sphere Fit in Scilab, GNU Octave or similar.
Pro: Could be useful if we are running out of program space
Con: FCB must be attached to a PC during calibration, this may not be practical.
The magnetometer is now compensated by the Gauss-Newton (offline, implemented in SciLab) method with respect to offset & scaling. (i.e. hard-iron offset)
@DanielStenis
are any scripts using the human-readable variant of the start-sensor-sampling
on the Termite console? If not, I would like to remove the line breaks for easier text processing for the offline variants of the Gauss-Newton calibrations.
Not at the moment, no. But you could implement a new output encoding type named commaseparated_encoding or something. If we want to keep the human-readable as it is for now
Some more info about hard/soft-iron compensation can be found here:
So I implemented an extra "c" parameter for sensor - sampling. All it does is to print the values for XYZ on one single line.
Should we care about magnetometer declination (correction for difference between magnetic and geographic north pole)?
Improve magnetometer calibration using Gauss-Newton method
Read more: https://chionophilous.wordpress.com/2012/09/01/implementing-the-gauss-newton-algorithm-for-sphere-fitting-1-of-3/