Question about the code of compass calibration

Recently, I’m research the part of compass calibration for Copter 3.6, I have some questions about the process of compass calibration:

 why compass calibration including sphere fitting and ellipsoid fitting? As far as I'm concern, the sphere fitting compute the offsets and a radius. In ellipsoid fitting, "soft iron" error and offsets can be computed, and use radius from sphere fitting to compute residual.

The explaination of the code as following:
Once the sample buffer is full, a sphere fitting algorithm is run, which

  • computes a new sphere radius. The sample buffer is thinned of samples which
  • no longer meet the acceptance criteria, and the state transitions to
  • RUNNING_STEP_TWO. Samples continue to be collected until the buffer is full
  • again, the full ellipsoid fit is run, and the state transitions to either
  • SUCCESS or FAILED.

why radius from sphere fitting can still be used for ellipsoid fitting? In sphere fitting, soft iron is ignored, thus radius from sphere fitting is also in-accurate. What will happen if we run ellipsoid fitting directly, and assumes radius = 1? after ellipsoid fitting done, we normalize “soft iron” to get the right radius.

What’s the advantage of this two-step compass calibration algorithm?

1 Like