3
$\begingroup$

I have a IMU and GPS sensors on my PCB which contains a microcontroller. An IMU consists of a gyroscope, accelerometer and a magnetometer (the magnetometer is calibrated to compensate for the effects of hard and soft iron). I am using Madgwick's filter to estimate the rotation matrix needed to rotate the read out accelerometer values onto the North-East-Down (NED) coordinate system. After subtracting the gravity vector, I feed the obtained acceleration components to the Kalman Filter. Note that the Madgwick filter estimates the gyroscope bias.

The states of my Kalman filter are:

$$ \vec x = \begin{bmatrix} p_x & p_y & p_z & v_x & v_y & v_z \end{bmatrix}^T \tag 1$$

and the control vector is:

$$ \vec u = \begin{bmatrix} a_x & a_y & a_z & a_x & a_y & a_z \end{bmatrix}^T \tag 2$$

I constructed the discrete time model:

\begin{align} {\vec x}_{k+1} &= \begin{bmatrix} 1 & 0 & 0 & T & 0 & 0 \\ 0 & 1 & 0 & 0 & T & 0 \\ 0 & 0 & 1 & 0 & 0 & T \\ 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} {\vec x}_k + \begin{bmatrix} {T^2\over 2} & 0 & 0 & 0 & 0 & 0 \\ 0 & {T^2\over 2} & 0 & 0 & 0 & 0 \\ 0 & 0 & {T^2\over 2} & 0 & 0 & 0 \\ 0 & 0 & 0 & T & 0 & 0 \\ 0 & 0 & 0 & 0 & T & 0 \\ 0 & 0 & 0 & 0 & 0 & T \end{bmatrix} {\vec u}_k \\&= \textbf{A} {\vec x}_k + \textbf{B} {\vec u}_k \tag 3 \end{align}

I would like to expand my model to incorporate additional states that would estimate the accelerometer bias. However, I don't know how to do that. My intuition tells me that I need to compare my acceleration data to something to obtain the bias components, but I don't know what. As I said, I have a GPS, so I am assuming there is something there that I can use, but I don't know what.

So my question is, how can the accelerometer bias terms be estimated using the Kalman Filter?

$\endgroup$
9
  • 1
    $\begingroup$ Hi there, welcome to this site! This is a very nicely formatted and well-stated question, as far as I can tell, which makes it nice to read. General question: shouldn't there be a factor of $\frac{1}{2}$ in front of the $T^2$ in your $B$, due to $\Delta p_x = \int\int a_x \mathrm dt \mathrm dt=a_x \int t \mathrm dt = a_x \frac{t^2}{2}$? $\endgroup$ Commented Nov 10 at 14:14
  • $\begingroup$ @MarcusMüller I wrote my response in the EDIT of my question for readability reasons. Thank you for the welcome :D $\endgroup$ Commented Nov 10 at 15:11
  • $\begingroup$ not sure what you mean with "first order Talyor expansion" when you use $T^2$; either you linearize and use the linear term in a linear context, i.e., with $T^1$, or you use the quadratic variable, and the coefficient that goes with the quadratic variable. $\endgroup$ Commented Nov 10 at 15:53
  • $\begingroup$ You are correct. It doesn't make sense now that I think about it. I will correct the control matrix and delete the EDIT. $\endgroup$ Commented Nov 10 at 16:08
  • $\begingroup$ You've got a serious error in your (3). Your input and state change matrices are appropriate for sampled-time, but in the left side you're taking the derivative of $\vec x$. You either need $\vec x_k = \mathbf A \vec x_{k-1} + \mathbf B u_k$, or you need to change your $\mathbf A$ and $\mathbf B$ to be appropriate for continuous time (and, strictly, call your filter a Kalman-Bucy filter). Once you edit your question I have an answer for you. $\endgroup$
    – TimWescott
    Commented Nov 11 at 18:15

1 Answer 1

2
$\begingroup$

I'm going to change your notation for (3), so that my answer will be compact enough to fit on one page.

Restating your model, $$\vec x_k = \left [ \begin{array}{c|c} \mathbf 1 & \mathbf T \\ \hline \mathbf 0 & \mathbf 1 \end{array} \right ] x_{k-1} + \begin{bmatrix}\mathbf{\frac {T^2}{2}} \\ \hline \mathbf T \end{bmatrix} u_k \tag a$$

This says the same thing, but leaves you to infer that the elements are all 3x3 identity matrices multiplied by the given factor. Note that I've trimmed your $u_k$ to just three elements to eliminate redundancy.

To add accelerometer bias into the mix, just add it as a state, so that your (1) becomes $$ \vec x = \begin{bmatrix} p_x & p_y & p_z & v_x & v_y & v_z & \Delta a_x & \Delta a_y & \Delta a_z \end{bmatrix}^T \tag b$$ with $\Delta a_x \cdots$ being the x, y, and z components of the accelerometer bias.

Now augment your model for the extra states: $$\vec x_k = \left [ \begin{array}{c|c|c} \mathbf 1 & \mathbf T & \mathbf{\frac{T^2}{2}} \\ \hline \mathbf 0 & \mathbf 1 & \mathbf T \\ \hline \mathbf 0 & \mathbf 0 & \mathbf 1 \end{array} \right ] x_{k-1} + \begin{bmatrix}\mathbf{\frac {T^2}{2}} \\ \hline \mathbf T \\ \hline \mathbf 0 \end{bmatrix} u_k \tag a$$

Then choose reasonable numbers for your accelerometer bias' process noise, and construct your Kalman filter as usual.

Because you are describing the dependency of the observed object motion on the accelerometer bias in your state transition matrix, that dependency will make it into the covariance ($\mathbf P$) matrix. That will, in turn, affect the Kalman gain, which means that deviations in the object's predicted motion from measured will affect the observed accelerometer bias.

$\endgroup$
2
  • $\begingroup$ But I still don't understand how to change (estimate) the accelerometer bias over time. At start up I can calculate the initial bias if I know the gravity vector well (and in my case I actually do). I understand I can add the bias term to my state vector. However, the bias changes over time. How do I estimate that change? I need an expression to modify it in the apriori and/or aposteriori step. How do I actually calculate those reasonable bias' process noise? I tried to research that topic. The term Allan variance came up, but I'm not sure if that can help since I don't know yet what it is. $\endgroup$ Commented Nov 12 at 9:11
  • $\begingroup$ The Kalman filter -- if properly constructed -- will do it for you. I edited your question. A nice thing (for me) about the Kalman filter is that you don't have to have a fully intuitive understanding of how the system works -- you just need to know that the system is observable, you need to model the system correctly, and you need to be able to construct the filter correctly. $\endgroup$
    – TimWescott
    Commented Nov 12 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.