1
+ @doc raw """
2
+ VehicleTracking(y::Matrix{Fl}, ρ::Fl, H::Matrix{Fl}, Q::Matrix{Fl}) where Fl
3
+
4
+ The vehicle tracking example illustrates a model where there are no hyperparameters,
5
+ the user defines the parameters ``\r ho``, ``H`` and ``Q`` and the model gives the predicted and filtered speed and
6
+ position. In this case, $y_t$ is a $2 \t imes 1$ observation vector representing the corrupted measurements
7
+ of the vehicle's position on the two-dimensional plane in instant $t$.
8
+
9
+ The position and speed in each dimension compose the state of the vehicle. Let us refer to ``x_t^{(d)}`` as
10
+ the position on the axis $d$ and to ``\d ot{x}^{(d)}_t`` as the speed on the axis $d$ in instant ``t``. Additionally,
11
+ let ``\e ta^{(d)}_t`` be the input drive force on the axis ``d``, which acts as state noise. For a single dimension,
12
+ we can describe the vehicle dynamics as
13
+
14
+ ```math
15
+ \b egin{equation}
16
+ \b egin{aligned}
17
+ & x_{t+1}^{(d)} = x_t^{(d)} + \B ig( 1 - \f rac{\r ho \D elta_t}{2} \B ig) \D elta_t \d ot{x}^{(d)}_t + \f rac{\D elta^2_t}{2} \e ta_t^{(d)}, \\
18
+ & \d ot{x}^{(d)}_{t+1} = (1 - \r ho) \d ot{x}^{(d)}_{t} + \D elta_t \e ta^{(d)}_t,
19
+ \e nd{aligned}\l abel{eq_control}
20
+ \e nd{equation}
21
+ ```
22
+
23
+ We can cast the dynamical system as a state-space model in the following manner:
24
+ ```math
25
+ \b egin{align*}
26
+ y_t &= \b egin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \e nd{bmatrix} \a lpha_{t+1} + \v arepsilon_t, \\
27
+ \a lpha_{t+1} &= \b egin{bmatrix} 1 & (1 - \t frac{\r ho \D elta_t}{2}) \D elta_t & 0 & 0 \\ 0 & (1 - \r ho) & 0 & 0 \\ 0 & 0 & 1 & (1 - \t frac{\r ho \D elta_t}{2}) \\ 0 & 0 & 0 & (1 - \r ho) \e nd{bmatrix} \a lpha_{t} + \b egin{bmatrix} \t frac{\D elta^2_t}{2} & 0 \\ \D elta_t & 0 \\ 0 & \t frac{\D elta^2_t}{2} \\ 0 & \D elta_t \e nd{bmatrix} \e ta_{t},
28
+ \e nd{align*}
29
+ ```
30
+
31
+ See more on [Vehicle tracking](@ref)
32
+ """
33
+ mutable struct VehicleTracking <: StateSpaceModel
34
+ system:: LinearMultivariateTimeInvariant
35
+
36
+ function VehicleTracking (y:: Matrix{Fl} , ρ:: Fl , H:: Matrix{Fl} , Q:: Matrix{Fl} ) where Fl
37
+ p = 2
38
+ Z = kron (Matrix {Fl} (I, p, p), [1.0 0.0 ])
39
+ T = kron (Matrix {Fl} (I, p, p), [1 (1 - ρ / 2 ); 0 (1 - ρ)])
40
+ R = kron (Matrix {Fl} (I, p, p), [0.5 ; 1 ])
41
+ d = zeros (Fl, p)
42
+ c = zeros (Fl, 4 )
43
+ H = H
44
+ Q = Q
45
+
46
+ system = LinearMultivariateTimeInvariant {Fl} (y, Z, T, R, d, c, H, Q)
47
+
48
+ return new (system)
49
+ end
50
+ end
51
+
52
+ function default_filter (model:: VehicleTracking )
53
+ Fl = typeof_model_elements (model)
54
+ steadystate_tol = Fl (1e-5 )
55
+ a1 = zeros (Fl, num_states (model))
56
+ skip_llk_instants = length (a1)
57
+ P1 = Fl (1e6 ) .* Matrix {Fl} (I, num_states (model), num_states (model))
58
+ return MultivariateKalmanFilter (2 , a1, P1, skip_llk_instants, steadystate_tol)
59
+ end
0 commit comments