Our goal is to track the location (and velocity) of a moving object, e.g. a ball, in a 3-dimensional space. We will allow gravity to act on the ball and the initial position and velocities are assumed to be known. We will be using noisy location estimates using a (simulated) sensor. The objective is to estimate the true location (and velocity) of the ball in 3D space.
We keep track of the following:
-
$x_{1}$ : location in the$x_{1}$ direction. -
$x_{2}$ : location in the$x_{2}$ direction. -
$x_{3}$ : location in the$x_{3}$ direction. -
$v_{1}$ : velocity in the$v_{1}$ direction. -
$v_{2}$ : velocity in the$v_{2}$ direction. -
$v_{3}$ : velocity in the$v_{3}$ direction. -
$a_{1}$ : velocity in the$a_{1}$ direction. -
$a_{2}$ : velocity in the$a_{2}$ direction. -
$a_{3}$ : velocity in the$a_{3}$ direction. Therefore, let the state vector be represented as:
Reproduced from Wikipedia (below) we have the systems of equations (in matrix format) that need to be solved as part of the Kalman Filtering algorithm. Our challenge is to adapt the problem setting to result in the model that satisfies the form of these equations which will allow us to use Kalman Filtering to track the ball's position and velocity.
The Kalman filter model assumes the true state at time
where,
-
$A_{k}$ is the state transition model which is applied to the previous state$X_{k-1}$ -
$B_{k}$ is the control-input model which is applied to the control vector$u_{k}$ (which is not applicable in our setting); -
$w_{k}$ is the process noise which is assumed to be drawn from a zero mean multivariate normal distribution with covariance$Q_{k}$ :
At time
where
The initial state, and the noise vectors at each step
The state of the Kalman filter is represented by two variables:
The Kalman filter can be written as a single equation, however it is most often conceptualized as two distinct phases: "Predict" and "Update". The predict phase uses the state estimate from the previous timestep to produce an estimate of the state at the current timestep. This predicted state estimate is also known as the a priori state estimate because, although it is an estimate of the state at the current timestep, it does not include observation information from the current timestep. In the update phase, the current a priori prediction is combined with current observation information to refine the state estimate. This improved estimate is termed the a posteriori state estimate.
Typically, the two phases alternate, with the prediction advancing the state until the next scheduled observation, and the update incorporating the observation.
- Predicted (a priori) state estimate:
$$\hat{\mathbf{x}}_{k \mid k-1}=\mathbf{A}_{k} \hat{\mathbf{x}}_{k-1 \mid k-1}+\mathbf{B}_{k} \mathbf{u}_{k}$$ - Predicted (a priori) estimate covariance:
$$\mathbf{P}_{k \mid k-1}=\mathbf{A}_{k} \mathbf{P}_{k-1 \mid k-1} \mathbf{A}_{k}^{\mathrm{T}}+\mathbf{Q}_{k}$$
- Innovation or measurement residual:
$$\tilde{\mathbf{y}}_{k}=\mathbf{z}_{k}-\mathbf{H}_{k} \hat{\mathbf{x}}_{k \mid k-1}$$ - Innovation (or residual) covariance:
$$\mathbf{S}_{k}=\mathbf{H}_{k} \mathbf{P}_{k \mid k-1} \mathbf{H}_{k}^{T}+\mathbf{R}_{k} ```math$$ - Optimal Kalman gain:
$$\mathbf{K}_{k}=\mathbf{P}_{k \mid k-1} \mathbf{H}_{k}^{T} \mathbf{S}_{k}^{-1}$$ - Updated (a posteriori) state estimate:
$$\hat{\mathbf{x}}_{k \mid k}=\hat{\mathbf{x}}_{k \mid k-1}+\mathbf{K}_{k} \tilde{\mathbf{y}}_{k}$$ - Updated (a posteriori) estimate covariance:
$$\mathbf{P}_{k \mid k}=\left(I-\mathbf{K}_{k} \mathbf{H}_{k}\right) \mathbf{P}_{k \mid k-1}$$
In our setting, we have the following:
The Dynamic Matrix,
Hence,
In this constant veocity model we have
We always observe the location,
We have the following model for measurement noise covariance matrix:
The constant
Process noise refers to the modeling of forces that could influence our model by creating noise in the form of acceleration disturbance. According to Wikipedia, for this constant velocity model we have:
where,
and we can assume the acceleration process noise
Material for this case study was inspired by the following:
https://balzer82.github.io/Kalman/
For more details on Kalman Filtering equations used, please check: https://en.wikipedia.org/wiki/Kalman_filter