[TriEmbed] magnetometer libraries for the rest of us for soft iron and pitch/yaw correction
Pete Soper
pete at soper.us
Wed Jun 23 08:31:14 CDT 2021
I struggle (translation: I am a doofus) with linear algebra, let alone
the matrix theory involved with "soft iron calibration" of magnetometer
chips when they are in arbitrary orientations close to ferrous metals.
I'm looking for OSS solutions and suspect they're plentiful in some
problem spaces such as drone software. But when searching the repos I
run into code that is either trivial (only smart enough to pull X/Y/Z
samples out via polled I/O) or requiring a return to 'State's math
department for a few months before I have any hope of recognizing the
specific code I need. My application involves a six axis
accelerometer/magnetometer and a Particle board with bags of compute and
memory resources.
I understand the principles of hard iron correction (i.e. a competing
magnetic field "pulls" the origin of the magenetometer and it's a simply
a matter of using X, Y, and Z corrections to "recenter" the response to
be linear and describing a sphere). Some chips even fully or partially
automate this process. But soft iron correction (nearby metal distorting
the sensor response to Earth's field lines and changing it from a sphere
to an elipsoid that has to be corrected back to a sphere) is currently
mystical.
The scheme for restoring linearity of response with soft iron distortion
is to get bunches of samples (the ubiquitous "figure eight" manoevers we
do with our smart phones). It's the "plugging in of these samples and
getting and applying the resulting correction" that I don't understand
properly to get the sensor back to an effectively spherical pattern of
response in the presence of soft iron.
Anybody come across a library that one can simply poke a lot of samples
into and end up with the necessary corrections to handle this case? Any
sources of OSS solutions for this you've come across? Nirvana would be
something like the old Usenet groups like
comp.sensor.magnetometer.calibration-for-the-math-impaired that is
likely to have a solution for an appliance operator like me in this
particular space.
Also, I'm looking for simple pitch/yaw correction of magnetometer
measures to have a "tilt insensitive" response such that an
accelerometer can provide the axis measures needed to correct the
magnetometer's measures for a given pitch and yaw (and roll). The best
discourse I've found so far is this one
<https://stackoverflow.com/questions/24639529/tilted-magnetometer-output-pitch-and-roll-tilt-compensation-i-am-lost>
in which the petitioner shows some example code but goes on to explain
that he had to invert the roll radian angle parameter and swap X and Y
to compensate and get the proper results after the revelation that his
Bosch datasheet had bad mistakes. My hope is I can mutate his example
code until my test fixture matches the behavior of a smart phone running
a compass application after it has been calibrated, but this is tangled
up with the calibration process. I assume I can keep that simple and get
joy (i.e. see the above function work properly with my sensor and the
specified mods to it) by keeping any ferrous metal or magnetized
material well away from the mag test fixture during my tests. Does that
seem sensible?
Best Regards,
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20210623/ecd30e07/attachment.htm>
More information about the TriEmbed
mailing list