# How to update velocity in a Kalman filter?

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.

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.
• 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? – Karnivaurus Jan 23 at 21:23
• $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. – Johan Löfberg Jan 24 at 6:43