I am trying to understand some of the basics of the Kalman filter. The problem I am working on is quite complex, but I have spent some time trying to simplify the problem with an example.
So, let's say we want to track the position $p$ of a car, and the car can move left or right, at velocity $v$, in a 1-dimensional world. Noisy measurements of the car's position are being made by an external camera:
I am struggling to understand how to formulate a Kalman filter for this problem. What I don't understand, is whether the velocity should be included in the state or the control input, given that it is something we are actually controlling.
To show my thinking, I have created two potential implementations of the Kalman filter below. I would like to know which of these are correct, or most appropriate, and why.
1) In the first method, there is no control input. The state changes by inspecting other elements of the state.
The state at time $t$ contains position $p_t$ and velocity $v_t$:
$x_t = \begin{bmatrix}p_t\\v_t\end{bmatrix}$
The prediction stage only includes the state transition model $A$ and noise $\epsilon$; there is no control input:
$x_{t+1} = Ax_{t} + \epsilon$
The state transition model says that the car's position changes based on the velocity in the state, by calculating the velocity multiplied by the timestep $\Delta t$. And the velocity remains the same:
$A = \begin{bmatrix}1&\Delta t\\0&1\end{bmatrix}$
We then have an observation $z_t$ of the position, which is dependent only on the position and noise $\delta$:
$z_t = Cx_{t} + \delta$
The observation model is just identity, i.e. the observation is a direction observation of the position:
$C = \begin{bmatrix}1 & 0\end{bmatrix}$
2) In the second method, we introduce a control input. The state changes by inspecting elements in both the state and the control input.
This time, the state only contains the position:
$x_t = \begin{bmatrix}p_t\end{bmatrix}$
And the state change is based on the state transition matrix, and the control input matrix.
$x_{t+1} = Ax_t + Bv_t$
This time, the state transition matrix is just identity, since we no longer include velocity and the dynamics is only due to the control input:
$A = \begin{bmatrix}1\end{bmatrix}$
And the control input matrix simply multiplies the velocity by the timestep $\Delta t$:
$B = \begin{bmatrix}\Delta t\end{bmatrix}$
And we know the velocity $v_t$ because this is the command we are controlling the car with.
And we have the same observation model as before, but this becomes a 1-by-1 matrix rather than a 1-by-2 matrix, since we have dropped the velocity component from the state vector:
$z_t = Cx_{t} + \delta$
$C = \begin{bmatrix}1\end{bmatrix}$
I don't really understand which is the most suitable method. Method 2 seems to be better than method 1, because we are directly using the velocity, rather than estimating it. And since we actually control the velocity, it makes sense to actually use it in the estimation.
But would method 1 even work? Would it be able to update its estimate of the velocity, even though the velocity is never measured or used in the dynamics model? Or can the velocity component of the state only change beyond its initial estimate if it is directly measured?
If anybody is able to help me with this, I would really appreciate it. Thank you!