Search code examples
initializationofflinekalman-filter

Kalman filter: Do I need to compute P in real time? It seems like its evolvement only depends on its initial state


When I look at the standard equations, e.g. http://en.wikipedia.org/wiki/Kalman_filter#Details

it seems as if the 'Predicted (a priori) estimate covariance' P_(k|k-1), as well as the 'Updated (a posteriori) estimate covariance' P_(k|k) do only depend on constant parameters (F, H, Q, R) and the initial value of P_(k-1|k-1). There seems to be no influence by the observed/measured and estimated system state or the error between them (x, y, e etc).

Question:

1) Does this mean the future values of P can be computed in advance once the initial value is picked, hence reducing computational load for real time applications?

2) Shouldn't P tell something about the current believe/trust in the current observations or estimations? How is that possible if it doesn't depend on them?


Solution

  • This is a good observation. Given the constraints (F, H, Q, and R constant) then you can compute the evolution of P independently of the data. To answer your specific questions:

    1) Yes, you could. If you were going to do that, though, you should just precompute a series of K_n, since you'd have no need of P. Sometimes it is appropriate to just use the steady-state K all the time (with the caveat that startup might need a special case). Whenever you make a simple moving average filter you are basically making a fixed-gain KF, you just didn't choose K using the machinery of the KF.

    2) This is a key point about the KF. The most important part of KF design is the noise modelling. You are telling the filter what the performance of the system is by setting the noise terms. People often talk of "tuning" a KF, but the covariance terms have specific meanings (and even units) and directly lead to the performance of the filter as you have described. You can check that you have done a good job by measuring the covariance of your innovation sequence z_n (y_n - H*x_n) to see that your S term ( HPH' + R ) describes it correctly.

    To challenge your assumption about F, H, Q, and R being constant, let me point out some reasons why they may not be (and may authors will scrupulously write them as F_n, H_n, etc to indicate that):

    • F and Q almost always have terms that scale by time. If your timestep is not constant, or you can skip a step, you will need to update F and Q each time.
    • In an EKF, where F is not linear, F will change on every timestep when you compute the Jacobian of f(). Similarly for H if h() is not linear.
    • Your co-varying Q terms may be dependent on the state. For example, if your state includes angular velocity and an orientation expressed as a quaternion, the way that the noise in angular velocity will affect the quaternion is dependent on the current value of the quaternion.
    • Your R term may be influenced by the state or the measurements. E.g. part of the measurement might be rotated, requiring you to rotate the noise. Or the noise might be dependent on temperature.
    • You may put in different measurements (or subsets of measurements) on every update, adding and deleting from H and R as needed.
    • You may have outside knowledge of your process that lets you vary your estimate of Q (e.g. you know your robot has entered a sandy area so it is more prone to slipping).