Dynamic Systems Course Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Data Fusion with Linear Kalman Filter

Dynamic Systems
Steven Dumble, PhD

1 Differential Equations
A differential equation is an equation that relates one or more functions together and
their derivatives. Many of the processes that occur in the world can be expressed as
differential equations, generally in representation of physical quantities, the deviates
represent the rate of change of that quantity and the differential equation describes
the relationship between the two. These processes occur in nature, physics, biology,
economics, engineering and many other areas. Issac Newton invented calculus and used
it to described classical mechanics to express the relationship between position, velocity
and acceleration as a differential equation with respect to time. For example, if x is the
position of a particle, then its velocity v is how quickly the position is changing with
time:
dx
v = ẋ =
dt
The same thing can be said about velocity and acceleration a:
dv
a = v̇ =
dt
These differential equations are commonly called the equation of motion.

1.1 Differential Equation Types


Differential equations can be broken down into two types, Ordinary Differential Equa-
tions (ODE) or Partial Differential Equations (PDE).

Ordinary Differential Equations are an equation which contains only a single variable
and its derivations. Most problems encountered in physics are ODE, for example the
equations of motion are all a function of derivative(s) of a single variable: position.

dx
v=
dt
d2 x
a=
dt2

1
Here the t time is the independent variable and x, v, a are the dependant variables as
they depend on t. These are the types of differential equations we will focus on for data
fusion and state estimation, as we usually want to track how the variable evolve over
time (with time being the independent variable).

Partial Differential Equations are equations which contains multiple variables and their
derivations. An example is the Laplace Equation:
∂u ∂u
+ =0
∂x2 ∂y 2
which is used in many areas of physics, such as heat and fluid dynamics.

1.2 Differential Equation Order


The equation order of an differential equation is determined by the highest derivative. If
an equation contains only first order derivatives, then it is a first order differential equa-
tion, likewise if it contains a second order derivate, then it is a second order differential
equation.
So going back to our equations of motion, the first equation for velocity is a first order
differential equation, while the equation for acceleration is a second order differential
equation.
dx
v=
dt
d2 x
a= 2
dt
It should also be noted that we can turn the second order differential equation for
acceleration into a first order differential equation, if we change the independent variable
to velocity instead of position:
dv
a=
dt
You can then described the complete second order system as two first order differential
equations.

1.3 Linear vs Non-Linear Differential Equations


A linear system is a system which output changes proportionally with in the input, non-
linear systems do not. Linear equations conform with the additivity and homogeneity
properties:
Additivity: f (u + v) = f (u) + f (v)
Homogeneity: f (su) = sf (u)
A linear ODE is when both sides of the equation are a linear combination of the depen-
dent variable and its derivatives. They can be written in the form:
dn y dy
an (x) n + · · · + a1 (x) + a0 (x)y = b(x)
dx dx

2
2 Dynamic Systems
A system is a collection of interrelated entities that can be considered as a whole. If the
different properties or attributes of that system change with time, then it is considered
a dynamic system. The process is how the system evolves over time.

The differential equations that make up the system are the state equations of the dy-
namic system. The state variables of the system are the dependant variables of the state
equations.

Consider the system of time varying, first order differential equations:

ẋ1 = f1 (t, x1 , x2 , · · · , xn , u1 , u2 , · · · , um )
ẋ2 = f2 (t, x1 , x2 , · · · , xn , u1 , u2 , · · · , um )
ẋ3 = f3 (t, x1 , x2 , · · · , xn , u1 , u2 , · · · , um )
..
.
ẋn = fn (t, x1 , x2 , · · · , xn , u1 , u2 , · · · , um )

There are m states, so there are m state equations, each equation is a function of time
t, and the m number of states xi and the n number of inputs uj .
This can compactly be written in vector form as:

ẋ(t) = f (t, x(t), u(t))

where:
x(t) = [x1 (t), x2 (t), · · · , xn (t)]T
u(t) = [u1 (t), u2 (t), · · · , um (t)]T
Many of the processes that occur in the world can be expressed as linear or non-linear
differential equations. We can describe these processes in state-space form which then
allow us to use different mathematical tools to extract useful information and perform
various analysis on the system. If the know the state of the system for the current time
and all the current and future inputs to that system, then we can predict the values of
the future states and outputs of that system and a lot more.

3 Continuous and Discrete Time


There are two ways to represent time in dynamic models, both of which are equivalent in
terms of results, just different mechanization. Models can be represented in continuous-
time or discrete-time.
Continuous time is the natural way of expressing time as a scalar real value t, models
of dynamic systems calculate the instantaneous rates or derivatives ẋ(t), so the models

3
are differential equations. To obtain the state of the system for some time in the future,
the differential equations have to be integrated to find the state.
Z t
x(t) = f (t, x(t), u(t)) dt
0

Discrete time systems break the continuous time t into a number of small steps of time
∆t where the current time is expressed as a integer k multiplication of the timestep
such that t = k∆t. So the time, state, and input are all represented at distict steps in
time such that tk , xk and uk are the time, state and input respectively for time step k.
Discrete time dynamic systems do not calculate the derivate ẋ(t) rather they calculate
the new state for the next time step k + 1 in the future such that:

xk+1 = f (tk , xk , uk )

The integration step is not needed as in continuous-time systems, however the discrete
model can only be calculated for discrete chucks of time while the continuous-time system
can be calculated for any time.

4 Mathematical Models
The state space representation of dynamic systems can be expressed in continuous time
or discrete time. Each time representation many consist of linear or non-linear models
that may or may not be time varying.

4.1 Continuous Non-Linear Model


This is the most general form of a continuos time dynamic system, any time of continuous
system may be represented in this form.

ẋ(t) = f (t, x(t), u(t))

• Continuous Time (calculates state rates ẋ)

• Time Varying (function of t)

• General function (represented as a general f (·))

4.2 Continuous Linear Model


This is the version of the continuous time model that can be represented as a linear
operation of the state vector and input vector.

ẋ(t) = A(t)x(t) + B(t)u(t)

4
    
ẋ1 (t) a11 (t) a12 (t) ... a1n (t) x1 (t)
 ẋ2 (t)   a21 (t) a22 (t) ... a2n (t)  x2 (t) 
=
    
 .. .. .. .. ..  .. 
 .   . . . .  . 
ẋn (t) an1 (t) an2 (t) ... ann (t) xn (t)
  
b11 (t) b12 (t) ... b1r (t) u1 (t)
 b21 (t) b22 (t) ... b2r (t)  u2 (t) 
+
  
.. .. .. ..  .. 
 . . . .  . 
bn1 (t) bn2 (t) . . . bnr (t) ur (t)

• Continuous Time (calculates state rates ẋ)


• Time Varying (A and B are a function of t)
• Linear function (represented as a linear matrix operation)

4.3 Discrete Non-Linear Model


This is the most general form of a discrete time dynamic system, any time of discrete
system may be represented in this form.
xk+1 = f (tk , xk , uk )

• Discrete Time (calculates next time step state xk+1 )


• Time Varying (function of timestep k)
• General function (represented as a general f (·))

4.4 Discrete Linear Model


This is the version of the discrete time model that can be represented as a linear operation
of the state vector and input vector.
xk+1 = Fk xk + Gk uk

     
x1 f11 f12 ... f1n x1
 x2   f21 f22 ... f2n   x2 
=
     
 ..  .. .. .. ..   .. 
 .   . . . .   . 
xn k+1
fn1 fn2 . . . fnn k
xn k
   
g11 g12 . . . g1r u1
 g21 g22 . . . g2r   u2 
+ .
   
.. .. .. ..
 ..
  
. . .   . 
gn1 gn2 . . . gnr k
ur k

5
• Discrete Time (calculates next time step state xk+1 )

• Time Varying (A and B are a function of timestep k)

• Linear function (represented as a linear matrix operation)

4.5 Model Summary


A summary of how the different mathematical models of dynamics systems can be rep-
resented is shown in the following table.

Continuous Discrete
Time invariant
General ẋ(t) = f (x(t), u(t)) xk = f (xk−1 , uk−1 )
Linear ẋ(t) = Ax(t) + Bu(t) xk = Fxk−1 + Guk−1
Time varying
General ẋ(t) = f (t, x(t), u(t)) xk = f (k, xk−1 , uk−1 )
Linear ẋ(t) = A(t)x(t) + B(t)u(t) xk = Fk−1 xk−1 + Gk−1 uk−1

5 Continuous to Discrete Conversions


In general, an time invariant, continuous-time, deterministic linear system can be rep-
resented as:
ẋ(t) = Ax(t) + Bu(t) (1)
where x is the state vector, u is the control vector and the matrices A and B are com-
monly referred to as the system matrix and control matrix respectively. The continuous-
time solution is given by:
Z t
x(t) = eA(t−t0 ) x(t0 ) + eA(t−τ ) Bu(τ )dτ (2)
t0

where t0 is the initial time of the system, which is usually just set to be zero. The
first term matrix exponential in the above equation is commonly referred to as the
state-transition matrix, as it is the matrix that describes how the state changes from an
initial condition to a new condition at the end of the time period without any control
involvement.
To convert the above system into a discrete form, we want to substitute the discrete
time relationship tk = tk−1 + ∆t into the continuous-time solution, so t0 = tk−1 is the
previous time step and t = tk is the current time step with ∆t = tk − tk−1 so that:
Z tk
x(tk ) = eA(tk −tk−1 ) x(tk−1 ) + eA(tk −τ ) Bu(τ )dτ (3)
tk−1

6
If we assume that the control input u(t) is held constant over the time period ∆T and
let α = τ − tk−1 then:
Z ∆t
A∆t
x(tk ) = e x(tk−1 ) +eA(∆t−α) dα Bu(tk−1 ) (4)
0
Z ∆t
=e A∆t
x(tk−1 ) + eA∆t
e−Aα dα Bu(tk−1 ) (5)
0
= Fx(tk−1 ) + Gu(tk−1 ) (6)

where the discrete-time matrices are:

F = eA∆t (7)
Z ∆t
G=F e−Aα dα B (8)
0
= F I − e−A∆t A−1 B if A−1 exists
 
(9)

The matrix exponential term eAt can be computed or approximated a number of different
ways. One useful definition is:

At
X (At)j
e = (10)
j!
j=0

If the above summation is expanded then it can be written as:

(At)2 (At)3
eAt = (At)0 + (At)1 + + + ... (11)
2! 3!
A simple approximation that may be applied is to ignore the higher order terms, such
that:
eAt ≈ I + At (12)
This approximation may or may not be appropriate depending on the system matrix A,
if the higher order terms are significant then a different method would be needed to be
taken.

6 Numerical Simulation of Models


In order to solve differential equations with respect to time, the integral of the equations
needs to be computed. This process is called integration and in simulation it is usually
carried out numerically because an exact analytical solution can not usually be found.

6.1 Continuous System Simulation


To simulate continuous systems a numerical integration method needs to be used. The
simplest method is called Euler First Order Integration. This method approximates the

7
continuous response of the system by assuming the derivatives can be held constant over
a small interval in time, such that:

x(t + ∆t) = x(t) + ẋ(t)∆t

The state x is stepped forward in small chucks of time ∆t, this process is carried out
until time t reaches the end time of the simulation. The steps of the integration process
can be summarized as:

1. Assume an Initial Condition x(0)

2. Calculate the State Rates ẋ(t) = f (t, x(t), u(t))

3. Integrate the State x(t + ∆t) = x(t) + ẋ(t)∆t

4. Update the Time t → t + ∆T

5. Repeat steps 2-4 as needed

The characteristics of Euler First Order Integration that should be noted are:

• Simplest Integration Method

• Least Accurate

• Time step must be small to capture fast dynamics

• Can be numerically unstable (Solution accuracy get exponentially worse with time)

6.2 Discrete System Simulation


Discrete equations don’t need an integration process as the discrete equations themselves
already solve for the next step in time, rather these equations only need to be stepped
forward in time to get the system response. The simulation of discrete models is very
straight forward, no integration is needed, the recursive solution just needs to be stepped
forward from the start of the simulation until the desired time.

1. Assume an Initial Condition x0

2. Step the Solution xk+1 = f (tk , xk , uk )

3. Update the Timestep k → k + 1

4. Repeat steps 2-3 as needed

You might also like