Magnetometer Calibration Using Levenberg-Marquardt Algorithm

Recently I worked on a magnetometer calibration method. This method is based on Levenberg-Marquardt Algorithm (LMA), a non-linear least-squares optimization algorithm. The method is implemented on ArduPilot and PX4, an open-source flight controller firmware.

I have to admit, formulizing mathematical notion from code is not straightforward. I spent several days to learn from LMA basic and finally understanding the sphere fit and ellipsoid fit algorithm.

In case you are wondering about the mathematical part, I write the formulation of the algorithm on PDF since it can’t be viewed on WordPress (unless I pay more for the plugin).

Click here for the document.