What is the correct function to minimize to calibrate 3D Inertial Measurement Unit (sensitivity matrix + offset of accelerometer and compass)

27 Views Asked by At

I have been experimenting with accelerometer and compass calibration and I can't decide how the function I am trying to minimize should look like.

Basically, I have number of measurements $x \in M$, and I need to find sensitivity matrix $A$ and offset vector $\epsilon$, such that for all $x$ it holds that $|A (x - \epsilon)| \approx u$ (AKA the norm of the calibrated measurement should be as close as possible to some constant).

Is there some kind of guide on how to come up with the function to minimize?

I experimented with numerical solution with cost function $1/n\sum_{x_1}^{x_n} g(|A(x-\epsilon)| - u)$ (where g(x) is either $|x|$, or $x^2$, or something else) starting from $A_0=E$ and $\epsilon_0 = 0$ with (- unfortunately - numerical gradient and) gradient descent algorithm that automatically finds the $\lambda_{gradient}$. However:

  1. I am not sure that the function I am minimizing is correct. Should I use it in this form, or is there some other, better, geometry-based cost function?
  2. Is there any analytical way to solve this (new) cost function?

The draft code can be found here.