Derivation of a model of a dynamic system of a discrete Kalman filter for an arbitrary linear system

The Kalman filter (FC) is an optimal linear algorithm for filtering the parameters of a dynamic linear system in the presence of incomplete and noisy observations. This filter is widely used in technical control systems to assess the dynamics of changes in macroeconomic situations or public opinion.



This article aims to acquaint the reader with a standard approach to the transition from a continuous model of a dynamical system described by a system of arbitrary linear differential equations to a discrete model.



Hidden text
as well as save the reader time by eliminating attempts to invent a bicycle and exposing oneself to colleagues in an ugly light. Do not be like an author



This article is also intended to encourage the reader to use FC in those problems where at first glance it seems that linear FC is not applicable, but in fact it may not be so.

To write an article by the author, the fact that despite the simplicity of the following things in the search results for Google both in Russian and in English (at least on the first page), the author could not find them.



Dynamic model for a discrete Kalman filter



Hidden text
Basically, this section is needed in order to introduce the reader to the system of accepted notation, which is very different from book to book and from article to article. An explanation of the meaning of all quantities included in the equations is beyond the scope of this article, while it is understood that the person who comes to the light has some idea about this. If not, welcome here , here and here .



FC can be performed both in discrete and continuous form. Of particular interest from the point of view of practical implementation on modern digital computers is the discrete FC that will be emphasized in this article.



Linear discrete FC is described by the following expressions. Let the system model be represented as follows:

$$ display $$ \ mathbf {x} _ {k} = F \ mathbf {x} _ {k-1} + \ Psi \ mathbf {u} _k + \ Gamma \ mathbf {w} _k $$ display $$





Where $ inline $ f $ inline $ - transition matrix, $ inline $ \ Psi $ inline $ - transition control matrix, $ inline $ \ Gamma $ inline $ - transition perturbation matrix, $ inline $ \ mathbf {x} _k $ inline $ , $ inline $ \ mathbf {u} _k $ inline $ , $ inline $ \ mathbf {w} _k $ inline $ - state vectors, control and noise (disturbance) of the system on $ inline $ k $ inline $ that step. Observation Model:

$$ display $$ \ mathbf {z} _k = H \ mathbf {x} _k + \ mathbf {n} _k $$ display $$





Where $ inline $ \ mathbf {z} _k $ inline $ , $ inline $ \ mathbf {n} _k $ inline $ - observation vectors and observation noise on $ inline $ k $ inline $ that step. 5 equations of work of the FC in this article are not of interest, therefore, in case someone needs them they are given under the spoiler.



Hidden text
The first stage, extrapolation:

$$ display $$ \ mathbf {x} _ {k | k-1} = F \ hat {\ mathbf {x}} _ {k-1} + \ mathbf {w} _k $$ display $$





$$ display $$ P_ {k | k-1} = FP_ {k-1} F ^ T + Q_k $$ display $$





This stage is called extrapolation. The next step, called correction:

$$ display $$ K = PH ^ T (HP_ {k | k-1} H ^ T + R) ^ {- 1} $$ display $$





the assessment itself

$$ display $$ \ hat {\ mathbf {x}} _ {k} = x_ {k | k-1} + K (H \ mathbf {z} _k- \ mathbf {x} _ {k | k-1 }) $$ display $$





$$ display $$ P_k = (E-KH) P_ {k | k-1} $$ display $$









Hereinafter, we are talking about stationary (with constant coefficients) systems for which the matrices $ inline $ f $ inline $ , $ inline $ \ Psi $ inline $ and $ inline $ \ Gamma $ inline $ independent of number $ inline $ k $ inline $ .



Continuous dynamic system model. State space.



In the vast majority of practical applications, FC filters the parameters of continuous dynamic systems described by differential equations for continuous time. Calculation of the FC in this case occurs on a digital computer, which automatically makes the FC discrete and the model should accordingly be discrete. To obtain a discrete model of these continuous systems, it is first necessary to compose the state vector itself (phase vector), the state equation system, then discretize them, thereby obtaining matrices $ inline $ f $ inline $ , $ inline $ \ Psi $ inline $ and $ inline $ \ Gamma $ inline $ .



Let the system behavior be described by a set of $ inline $ n $ inline $ differential equations of the first order:

$$ display $$ \ dot {\ mathbf {x}} (t) = A \ mathbf {x} (t) + B \ mathbf {u} (t) + G \ mathbf {w} (t) $$ display $$





here $ inline $ \ mathbf {x} $ inline $ - $ inline $ n $ inline $ -dimensional state vector of the system. A state vector (aka phase vector) is a vector that contains variables that describe the system and their derivatives up to the required order. $ inline $ \ mathbf {u} $ inline $ - $ inline $ r $ inline $ -dimensional control vector of the system that describes the controlled effect exerted on the system.

$ inline $ \ mathbf {w} $ inline $ $ inline $ p $ inline $ -dimensional vector containing a random uncontrolled effect on the system, or noise. $ inline $ a $ inline $ - matrix of system state size $ inline $ n \ times n $ inline $ . $ inline $ B $ inline $ - size control matrix $ inline $ n \ times r $ inline $ . $ inline $ g $ inline $ - perturbation matrix of size $ inline $ n \ times p $ inline $ . In this expression, all products are calculated according to the rules of matrix multiplication. In the general case, the elements of all matrices are functions of time, however, only stationary systems are considered in the article, where the elements are time-independent.



An example of a transition from a system description using a higher order differential equation to a description through a state space is given below.



Example
Let the motion of a point along some axis $ inline $ ox $ inline $ is described by a second order differential equation:

$$ display $$ \ ddot {x} = - \ omega ^ 2 x $$ display $$





If one does not remember, an oscillatory movement is thus represented. We move from a second-order equation to a system of two equations by introducing a new variable $ inline $ x_1 = \ dot {x} $ inline $ . Now we have:

$$ display $$ \ begin {aligned} \ dot {x} & = x_1 \\ \ dot {x} _1 & = - \ omega ^ 2 x \ end {aligned} $$ display $$





This system of equations can be written in matrix form, while the state vector $ inline $ \ mathbf {x} = [x \, x_1] ^ T $ inline $ , the state matrix will be

$$ display $$ A = \ begin {bmatrix} 0 & 1 \\ - \ omega ^ 2 & 0 \ end {bmatrix} $$ display $$





Variable entered $ inline $ x_1 $ inline $ plays the role of speed. Matrices $ inline $ B $ inline $ and $ inline $ g $ inline $ in this example, they are zero, since there are no control and disturbing influences.



Discrete transition



For the correct transition to the discrete region (in other words, the discretization of the model), we need to introduce the concept of a matrix exponent . A matrix exponent is a matrix function obtained by analogy with the expansion of the exponential function in a Taylor series in fact of Maclaurin :

$$ display $$ e ^ {At} = E + At + \, ... \, \ dfrac {A ^ nt ^ n} {n!} + \, ... \, = \ sum_ {k = 0 } ^ {\ infty} \ dfrac {A ^ nt ^ n} {n!} $$ display $$





where under $ inline $ E $ inline $ implies a unit matrix.



The exact transition from a continuous model in the state space to a discrete model requires a search for a solution to a homogeneous system $ inline $ \ dot {\ mathbf {x}} (t) = A (t) \ mathbf {x} (t) $ inline $ , then the transition to the original system, finding a common solution and integration from the initial moment $ inline $ t_0 $ inline $ to some $ inline $ t $ inline $ . A rigorous conclusion can be found in [1]; here, a finished result is presented.



In the case of stationarity of a continuous dynamic model (independent of matrices $ inline $ a $ inline $ , $ inline $ B $ inline $ , $ inline $ g $ inline $ from time) to obtain a discrete model, we can introduce an auxiliary transition matrix of the system $ inline $ \ Phi (t, \ tau) $ inline $ from the moment $ inline $ \ tau $ inline $ in the moment $ inline $ t $ inline $ where $ inline $ t> \ tau $ inline $ :

$$ display $$ \ Phi (t, \ tau) = e ^ {A (t- \ tau)} = \ sum_ {k = 0} ^ {\ infty} \ dfrac {A ^ nt ^ n} {n! } $$ display $$





Further, using this auxiliary matrix, the matrices required for a discrete model can be obtained:

$$ display $$ F = \ Phi (t + T, t) = e ^ {AT} = E + AT + \ dfrac {A ^ 2T ^ 2} {2!} + \ dfrac {A ^ 3T ^ 3} {3!} + ... $$ display $$





$$ display $$ \ Gamma = \ int_ {kT} ^ {(k + 1) T} \ Phi (t_ {k + 1}, \ tau) G (\ tau) d \ tau $$ display $$





$$ display $$ \ Psi = \ int_ {kT} ^ {(k + 1) T} \ Phi (t_ {k + 1}, \ tau) B (\ tau) d \ tau $$ display $$





Here under $ inline $ B (\ tau) $ inline $ and $ inline $ G (\ tau) $ inline $ we mean matrices from continuous equations, by $ inline $ \ Psi $ inline $ and $ inline $ \ Gamma $ inline $ required matrices of a discrete model.



Practical examples



Hidden text
Unfortunately, the examples will only have perversions with the matrix $ inline $ f $ inline $ , since the author is too lazy to invent examples with control actions, and in general, as part of his dissertation, he deals with navigation issues where there are no control actions. Moreover, with the rudimentary knowledge of mathematical analysis, after analyzing the examples, these actions should not cause problems. For non-zero examples $ inline $ \ Gamma $ inline $ and $ inline $ \ Psi $ inline $ can go to [2].



To illustrate the above mathematics, consider two examples. One of which is warm-up, and the second is illustrative, to demonstrate the capabilities of the described method.



Trivial



Let the object move along the axis $ inline $ ox $ inline $ with initial speed $ inline $ v_0 $ inline $ and constant acceleration $ inline $ a $ inline $ . Then his model can be represented as:

$$ display $$ \ ddot {x} = a $$ display $$





We represent this model in the form of a system of homogeneous differential equations. To do this, we divide the equation into a system of three remote controls:

$$ display $$ \ begin {aligned} \ dot {x} & = v_x \\ \ dot {v} _x & = a_x \\ \ dot {a} _x & = 0 \ end {aligned} $$ display $$





When writing systems of equations, the following derivatives are added there so far the following is required to calculate the current one. Then in the current system you can’t stop at $ inline $ v_x $ inline $ , since the calculation requires $ inline $ a_x $ inline $ . At the same time to calculate $ inline $ a_x $ inline $ derivative $ inline $ \ dot {a} _x $ inline $ not required, therefore, to introduce derivatives of the order above $ inline $ a_x $ inline $ in the state vector does not make much sense.



Combine three variables into a state vector $ inline $ \ mathbf {x} = [x \, v_x \, ​​a_x] ^ T $ inline $ and write the system of equations in matrix form for the transition to the state space form:

$$ display $$ \ dot {\ mathbf {x}} = A \ mathbf {x} $$ display $$





where is the matrix

$$ display $$ A = \ begin {bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \ end {bmatrix} $$ display $$





Now we can calculate the transition matrix of the discrete dynamical system corresponding to the considered continuous:

$ inline $ \ begin {aligned} F = E + A \ cdot T + A \ times A \ cdot \ dfrac {T ^ 2} {2} = \ begin {bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \ end {bmatrix} + \ begin {bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 0 & 0 & 0 \ end {bmatrix} \ cdot T + \\ \ begin {bmatrix} 0 & 0 & 1 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \ end {bmatrix} \ cdot \ dfrac {T ^ 2} {2} = \ begin {bmatrix} 1 & T & T ^ 2/2 \\ 0 & 1 & T \\ 0 & 0 & 1 \ end {bmatrix} \ end {aligned} $ inline $

The reader can verify that $ inline $ A ^ 3 $ inline $ and above is a zero matrix.

In this way, a transition matrix known to everyone was obtained, which was deduced without applying any assumptions.



Nontrivial example



We assume that our object moves in three-dimensional space with a certain constant (modulo) linear velocity and with an angular velocity represented by a pseudovector:

$$ display $$ \ omega = [\ omega_x \, ​​\ omega_y \, \ omega_z] ^ T $$ display $$





First you need to make up the equations of the state space. We write the acceleration when moving around the circle. From the physics course for 1 semester, it is known that centripetal acceleration is a vector product of angular and linear velocities:

$$ display $$ \ dot {v} = \ omega \ times v $$ display $$





Here the velocity vector is $ inline $ v = [v_x \, ​​v_y \, v_z] ^ T $ inline $ .

We will write the vector product in more detail:

$$ display $$ \ omega \ times v = \ begin {bmatrix} \ omega_x \\ \ omega_y \\ \ omega_z \ end {bmatrix} \ times \ begin {bmatrix} v_x \\ v_y \\ v_z \ end {bmatrix} = \ begin {bmatrix} \ omega_yz- \ omega_zy \\ \ omega_zx- \ omega_xz \\ \ omega_xy- \ omega_yx \ end {bmatrix} $$ display $$





Now we write the system of equations

$$ display $$ \ begin {aligned} \ dot {x} & = v_x \\ \ dot {y} & = v_y \\ \ dot {z} & = v_z \\ \ dot {v} _x & = \ omega_yz - \ omega_zy \\ \ dot {v} _y & = \ omega_zx- \ omega_xz \\ \ dot {v} _z & = \ omega_xy- \ omega_yx \ end {aligned} $$ display $$





Upon transition to the matrix form, the matrix $ inline $ a $ inline $ will be:

$$ display $$ A = \ begin {bmatrix} 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & \ 0 & 0 & 0 & 0 & - \ omega_z & \ omega_y \\ 0 & 0 & 0 & \ omega_z & 0 & - \ omega_x \\ 0 & 0 & 0 & - \ omega_y & \ omega_x & 0 \ end { bmatrix} $$ display $$









Next, we proceed to the matrix $ inline $ f $ inline $ by the corresponding expression. Since orally multiply matrices by size $ inline $ 6 \ times 6 $ inline $ three times is quite difficult, the probability of error is high, and this is not a royal matter, then we will write a script using the Python sympy library:

from sympy import symbols, Matrix, eye x, y, z, T = symbols('xyz T') vx, vy, vz = symbols('v_x v_y v_z') wx, wy, wz = symbols('w_x w_y w_z') A = Matrix([ [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, -wz, wy], [0, 0, 0, wz, 0, -wx], [0, 0, 0, -wy, wx, 0] ]) F = eye(6) + A*T + A*A*T**2/2 from sympy import latex print(latex(F))
      
      





And running it, we get something like this:



Hidden text
 \left[\begin{matrix}1 & 0 & 0 & T & - \frac{T^{2} w_{z}}{2} & \frac{T^{2} w_{y}}{2}\\0 & 1 & 0 & \frac{T^{2} w_{z}}{2} & T & - \frac{T^{2} w_{x}}{2}\\0 & 0 & 1 & - \frac{T^{2} w_{y}}{2} & \frac{T^{2} w_{x}}{2} & T\\0 & 0 & 0 & \frac{T^{2} \left(- w_{y}^{2} - w_{z}^{2}\right)}{2} + 1 & \frac{T^{2} w_{x} w_{y}}{2} - T w_{z} & \frac{T^{2} w_{x} w_{z}}{2} + T w_{y}\\0 & 0 & 0 & \frac{T^{2} w_{x} w_{y}}{2} + T w_{z} & \frac{T^{2} \left(- w_{x}^{2} - w_{z}^{2}\right)}{2} + 1 & \frac{T^{2} w_{y} w_{z}}{2} - T w_{x}\\0 & 0 & 0 & \frac{T^{2} w_{x} w_{z}}{2} - T w_{y} & \frac{T^{2} w_{y} w_{z}}{2} + T w_{x} & \frac{T^{2} \left(- w_{x}^{2} - w_{y}^{2}\right)}{2} + 1\end{matrix}\right]
      
      







That after framing with appropriate tags and pasting into the source code of the article turns into:

$$ display $$ F = \ left [\ begin {matrix} 1 & 0 & 0 & T & - \ frac {T ^ {2} w_ {z}} {2} & \ frac {T ^ {2} w_ {y}} {2} \\ 0 & 1 & 0 & \ frac {T ^ {2} w_ {z}} {2} & T & - \ frac {T ^ {2} w_ {x}} {2 } \\ 0 & 0 & 1 & - \ frac {T ^ {2} w_ {y}} {2} & \ frac {T ^ {2} w_ {x}} {2} & T \\ 0 & 0 & 0 & \ frac {T ^ {2} \ left (- w_ {y} ^ {2} - w_ {z} ^ {2} \ right)} {2} + 1 & \ frac {T ^ {2} w_ {x} w_ {y}} {2} - T w_ {z} & \ frac {T ^ {2} w_ {x} w_ {z}} {2} + T w_ {y} \\ 0 & 0 & 0 & \ frac {T ^ {2} w_ {x} w_ {y}} {2} + T w_ {z} & \ frac {T ^ {2} \ left (- w_ {x} ^ {2} - w_ {z} ^ {2} \ right)} {2} + 1 & \ frac {T ^ {2} w_ {y} w_ {z}} {2} - T w_ {x} \\ 0 & 0 & 0 & \ frac {T ^ {2} w_ {x} w_ {z}} {2} - T w_ {y} & \ frac {T ^ {2} w_ {y} w_ {z}} {2} + T w_ {x} & \ frac {T ^ {2} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2} \ right)} {2} + 1 \ end {matrix} \ right] $$ display $$







In this way, the Kalman filter transition matrix for circular motion can be derived.

Unlike the previous case, the result of the construction $ inline $ a $ inline $ to a power higher than 3 is not a zero matrix.



e.g. <math> $ inline $ A ^ 3 $ inline $ </math>

$$ display $$ \ left [\ begin {matrix} 0 & 0 & 0 & - w_ {y} ^ {2} - w_ {z} ^ {2} & w_ {x} w_ {y} & w_ {x } w_ {z} \\ 0 & 0 & 0 & w_ {x} w_ {y} & - w_ {x} ^ {2} - w_ {z} ^ {2} & w_ {y} w_ {z} \ \ 0 & 0 & 0 & w_ {x} w_ {z} & w_ {y} w_ {z} & - w_ {x} ^ {2} - w_ {y} ^ {2} \\ 0 & 0 & 0 & 0 & w_ {x} ^ {2} w_ {z} - w_ {z} \ left (- w_ {y} ^ {2} - w_ {z} ^ {2} \ right) & - w_ {x} ^ {2} w_ {y} + w_ {y} \ left (- w_ {y} ^ {2} - w_ {z} ^ {2} \ right) \\ 0 & 0 & 0 & - w_ {y} ^ {2} w_ {z} + w_ {z} \ left (- w_ {x} ^ {2} - w_ {z} ^ {2} \ right) & 0 & w_ {x} w_ {y} ^ { 2} - w_ {x} \ left (- w_ {x} ^ {2} - w_ {z} ^ {2} \ right) \\ 0 & 0 & 0 & w_ {y} w_ {z} ^ {2 } - w_ {y} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2} \ right) & - w_ {x} w_ {z} ^ {2} + w_ {x} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2} \ right) & 0 \ end {matrix} \ right] $$ display $$









or <math> $ inline $ A ^ 4 $ inline $ </math>

$$ display $$ \ left [\ begin {matrix} 0 & 0 & 0 & 0 & w_ {x} ^ {2} w_ {z} - w_ {z} \ left (- w_ {y} ^ {2} - w_ {z} ^ {2} \ right) & - w_ {x} ^ {2} w_ {y} + w_ {y} \ left (- w_ {y} ^ {2} - w_ {z} ^ { 2} \ right) \\ 0 & 0 & 0 & - w_ {y} ^ {2} w_ {z} + w_ {z} \ left (- w_ {x} ^ {2} - w_ {z} ^ { 2} \ right) & 0 & w_ {x} w_ {y} ^ {2} - w_ {x} \ left (- w_ {x} ^ {2} - w_ {z} ^ {2} \ right) \ \ 0 & 0 & 0 & w_ {y} w_ {z} ^ {2} - w_ {y} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2} \ right) & - w_ {x} w_ {z} ^ {2} + w_ {x} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2} \ right) & 0 \\ 0 & 0 & 0 & - w_ {y} \ left (- w_ {x} ^ {2} w_ {y} + w_ {y} \ left (- w_ {y} ^ {2} - w_ {z} ^ {2} \ right ) \ right) + w_ {z} \ left (w_ {x} ^ {2} w_ {z} - w_ {z} \ left (- w_ {y} ^ {2} - w_ {z} ^ {2} \ right) \ right) & w_ {x} \ left (- w_ {x} ^ {2} w_ {y} + w_ {y} \ left (- w_ {y} ^ {2} - w_ {z} ^ {2} \ right) \ right) & - w_ {x} \ left (w_ {x} ^ {2} w_ {z} - w_ {z} \ left (- w_ {y} ^ {2} - w_ { z} ^ {2} \ right) \ right) \\ 0 & 0 & 0 & - w_ {y} \ left (w_ {x} w_ {y} ^ {2} - w_ {x} \ left (- w_ {x} ^ {2} - w_ {z} ^ {2} \ right) \ right) & w_ {x} \ left (w_ {x} w_ {y} ^ {2} - w_ {x} \ left ( - w_ {x} ^ {2} - w_ {z} ^ {2} \ right) \ right) - w_ {z} \ left (- w _ {y} ^ {2} w_ {z} + w_ {z} \ left (- w_ {x} ^ {2} - w_ {z} ^ {2} \ right) \ right) & w_ {y} \ left (- w_ {y} ^ {2} w_ {z} + w_ {z} \ left (- w_ {x} ^ {2} - w_ {z} ^ {2} \ right) \ right) \\ 0 & 0 & 0 & w_ {z} \ left (- w_ {x} w_ {z} ^ {2} + w_ {x} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2 } \ right) \ right) & - w_ {z} \ left (w_ {y} w_ {z} ^ {2} - w_ {y} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2} \ right) \ right) & - w_ {x} \ left (- w_ {x} w_ {z} ^ {2} + w_ {x} \ left (- w_ {x} ^ {2} - w_ {y} ^ {2} \ right) \ right) + w_ {y} \ left (w_ {y} w_ {z} ^ {2} - w_ {y} \ left (- w_ {x} ^ {2 } - w_ {y} ^ {2} \ right) \ right) \ end {matrix} \ right] $$ display $$









Therefore, the representation of such a matrix is ​​possible with finite accuracy. However, when $ inline $ \ omega T \ ll 1 $ inline $ series obtained in matrix elements $ inline $ f $ inline $ converge pretty quickly. For practical use, enough members to the second degree, rarely to the third and even more so to the fourth.



In addition, we illustrate the operation of the matrix $ inline $ f $ inline $ asking vector $ inline $ \ omega $ inline $ , $ inline $ \ bf {x} _0 $ inline $ , $ inline $ \ bf {v} _0 $ inline $ , and a recurrence sequence of the form:

$$ display $$ \ mathbf {x} _k = F \ mathbf {x} _ {k-1} $$ display $$





We calculate this recurrence sequence for $ inline $ \ omega T \ approx \ frac {1} {100} $ inline $



Python code
 import numpy as np from numpy import pi T = 1 wx, wy, wz = 0, 2*pi/100/2**.5, 2*pi/100/2**.5 vx0 = 10 A = np.array([ [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, -wz, wy], [0, 0, 0, wz, 0, -wx], [0, 0, 0, -wy, wx, 0] ]) F = np.eye(6) + A * T + A @ A * T**2/2 + A @ A @ A * T**3/6 X = np.zeros((6, 101)) X[:, 0] = np.array([0, 0, 0, vx0, 0, 0]) for k in range(X.shape[1] - 1): X[:, k + 1] = F @ X[:, k] import matplotlib as mpl import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.gca(projection='3d') ax.plot(X[0, :], X[1, :], X[2, :]) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') plt.show()
      
      





Let me remind you that for the type np.array the symbol "@" denotes matrix multiplication. Distances and speeds are measured in parrots, angular velocity in rad / s. It is also necessary to remember that in order to obtain a circle, it is necessary that the velocity and angular velocity vectors are perpendicular, otherwise a spiral will be obtained instead of a circle.



As a result, setting a certain initial position, velocity, and angular velocity, one can obtain such a trajectory



The accuracy of the coincidence of the first and last points can be obtained as

 >>> print(X[:3, 0] - X[:3,-1]) [-0.00051924 -0.0072984 0.0072984 ]
      
      





With a turning radius of the order of 150 units, the relative error does not exceed the values ​​of the order $ inline $ 5 \ cdot 10 ^ {- 5} $ inline $ . This accuracy is quite enough for the FC model, which monitors the turning target.



Conclusion



If earlier FC was used mainly for solving navigation problems, where the use of linear motion models yielded good results, then with the development of modern applications such as robotics, computer vision, etc., the need for more complex models of movement of objects has increased. Moreover, the application of the above approach makes it possible to synthesize a discrete FC model at no particular cost, which will facilitate the task for developers. The only limitation of this approach is that a continuous model of a dynamic system must be described by a set of linear, or at least linearizable, equations in the state space.



Summarizing the above, we can give an algorithm for the synthesis of the transition matrix FC:



  1. Writing the differential equation of the system
  2. Transition to the state vector and to the state space
  3. Linearization if necessary
  4. Representation of the transition matrix in the form of a matrix exponent and truncation of the series if necessary
  5. Calculation of the remaining matrices taking into account the transition matrix


The author welcomes constructive criticism regarding mistakes made, inaccuracies, incorrect formulations, methods not mentioned, and more. Thanks for attention!



References



[1] Medic J. Statistically optimal linear estimates and control. Per. from English Ed. A.S. Shatalova Moscow. Publishing house "Energy", 1973, 440 p.

[2] Matveev V.V. Basics of the construction of strapdown inertial systems of St. Petersburg: State Research Center of the Russian Federation OJSC Concern TsNII Elektribribor, 2009. - 280s. ISBN 978-5-900180-73-3



All Articles