I'm looking at using a magnetometer in a project and I'm struggling to understand the proper procedure for calibration of the sensor.
I understand that magnetometers need to be calibrated to compensate for hard and soft iron effects.
I've seen a number of algorithms for calibration based around ellipsoid fitting, similar to that detailed in https://www.st.com/content/ccc/resource/technical/document/design_tip/group0/a2/98/f5/d4/9c/48/4a/d1/DM00286302/files/DM00286302.pdf/jcr:content/translations/en.DM00286302.pdf. These algorithms all require the magnetometer be spun in three dimensions, to collect enough data for an ellipsoid to be fitted, thereby allowing estimation of scaling and offset parameters to translate and scale the ellipsoid to a unit sphere positioned at the origin.
However, I'm unclear on how the calibration algorithm should be used, for example if say I'm placing my magnetometer in the boot of a car next to several other bits of metal would I be able to calibrate the magnetometer by spinning the magnetometer in three dimensions just above its mounting point? Would this then calibrate out the effect of the hard and soft iron effects in the magnetometers vicinity? Or should I actually be mounting the magnetometer in its mounting point and then spinning the entire platform (in this example the car) in three dimensions? Could someone also explain the physics as to why the calibration should be performed in either manner?