I am learning about the Kalman filter, and having difficulty understand how to construct a Kalman filter when velocities are introduced. Let's say we are tracking the (x-position, y-position) of an object, and we have a sensor which estimates this position. One way to construct the Kalman filter is to exclude any velocity, such that the prior prediction of the next position is just the old position.

But a better way would be to include the object's velocity. The state vector would then include the x-velocity and y-velocity, i.e. state = (x-position, y-position, x-velocity, y-velocity). The value of x at the next timestep would then be x + dt * x-velocity, and similarly for y.

My question is: how do we update x-velocity and y-velocity? Whilst we have a sensor which estimates positions, we don't have a sensor which estimates velocities. Therefore, we cannot update the velocities using the observation model. We could then assume that the velocity doesn't change, but this is very limiting in my application, as I know that the velocity does change significantly.

One idea I had was to emulate an observation model, by saying that the measured velocity is the difference between the current position and the previous position. Then, I could use an observation model in the same way as with the position measurement. However, this feels like a bit of a hack, since this is not a sensor in the true sense; I am just emulating a sensor using old data. And it seems like this could be incorporated in a more direct way, than by "pretending" I have some sensor which gave me this data.

Can somebody please help me understand this?? Thanks!


The idea in a Kalman filter is that you typically don't measure all the states, so it is a bit unclear what reference you are using where this setup wouldn't be answered already in the definition of the filter and the basic equations.

Write your dynamics as $x_{k+1} = Fx_{k} + Gw_k$ (where $x_k$ denotes your 4 states and $w_k$ is assumed process noise). The measurement model is $y_k = Cx_k + \eta_k$ where $C$ thus only would have two rows in your case. At this point, you just apply standard theory to derive the Kalman gain (i.e. solve the Riccati equation)

Edit: Perhaps I missed the core part of the question: How you define the dynamic model of the state is up to you. Typical approach is to say that the acceleration is random, i.e. $x_{k+1} = x_{k} + w_k$ for the velocity states.

  • $\begingroup$ Hi Johan, thanks very much for your reply. The last paragraph is the part which I am trying to understand at the moment. Elsewhere, I have read that, intuitively, the next state is a weighted average of the prediction and observation -- with the weight coming from the uncertainties in each. This makes sense to me for the position component of the state, where there is an observation. But for the velocity component, how can this be a weighted average of the previous velocity and the velocity observation -- when there is no velocity observation? In this case, the velocity would remain the same.. $\endgroup$ – Karnivaurus Jan 23 at 17:55
  • $\begingroup$ The weighting of model prediction and correction from measurement to define new estimate is what the Kalman filter gives you, not something you define. What you have to define is the assumed dynamics and measurement model. It feels like you are missing the point of what the Kalman filter actually does and computes. $\endgroup$ – Johan Löfberg Jan 23 at 21:09
  • $\begingroup$ I understand that the Kalman gain is calculated by the algorithm, and this is what determines the weighting between prediction and measurement. What I don't understand is how a component of the state can ever change, if you don't have a measurement for it. For example, using your notation, the updated estimation is equal to: $x_{k} = {x}_{k}^{predicted} + K (y_{k} - C x_{k}^{predicted})$. Since the observation does not measure velocity, the velocity estimation at time $k$ remains the same as at time $k-1$. So, the system assumes constant velocity and can never update it. Is this true? $\endgroup$ – Karnivaurus Jan 23 at 21:23
  • 1
    $\begingroup$ $K$ has height 4 and thus the residual will cause all state estimates to be adjusted. Assume you have a scalar system with position and velocity $\hat{x}_k$ and you make an initial guess $\hat{x}_0 = (0,0)$. Now you wait one second and obtain a measurement of the position which says $4$. This is not consistent with model prediction (which would say we stay at 0 since velocity estimate is 0), hence it's either the position estimate which is wrong, or the velocity estimate is wrong or measurement error or process noise. Kalman gives you the optimal way to update the two state estimates. $\endgroup$ – Johan Löfberg Jan 24 at 6:43
  • $\begingroup$ Hi Johan, ok I understand now. I didn't realise that the Kalman gain was able to update something which didn't have a measurement. I've gone through the maths and have now verified that this is possible, so I'm feeling a bit clearer now. Thanks so much for all your answers! $\endgroup$ – Karnivaurus Jan 24 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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