Linear Systems

You might also like

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

Robotics and Control systems .

LINEAR SYSTEMS

lrrohafao & nadgudd -

u
( Br Pg Be ily )
-

for →

controlling
a 2b point mass
point mass
,
a

I:)
-

÷H: :
:
• e. renren.am ,
p
/ reformulation
-

general form X
-
- -

A B U
je
'

2e
.

H = P R2 =
p
, ,

:p )
Ie, ice
' '

⇒ Rz u

:]
p

I:) fo
= = =

on sina.ae mm
-
-
::
a-
Ea]
a- -
-

CE ] LF ] -
-

- ~
n

.
-

:÷÷÷÷:÷÷"÷÷÷÷÷÷÷÷:i y
Y c

l
-

se

.fi
where in is the number control
of inputs,
General state space
and Y £ It where he is the number
form of

:::÷:7E¥: :*: :# iii:


"

÷.
for point Px m
a mass pxn
CE IR D t IR

=L : :X:'ll:b
-
-

Tz Lineaoisah on
-

-
in -
U
je a -

let's linear model


say a non

µ)
]
u
if = [ I ° + D
w i =
f Ce , u
) Y -
-
h Casa )
- O

" "
C ~
local linear model
se
we want to find a
,
-

operating point
around an .

-
Let's
A Point operating point
Controlling ZD thats . define an

# (Ro ,
Wo ) I = slot
thus
Gr Su
Case ) Uo


2e No t U = t
U
Uy
=
=
,

TT T T
T
deviation
sonfallu
'


use Pie small deviation operating
operating
=
.
of u
P= ( Pa
Py ) pry
point point of
'
u
,
hey = of x

the state K then


Define
T Eze ie -
do
[ Ry )
=

se = Poe P'se Py "


, , , o
T
't that
En ko is must constant
ie
[ rise rise
a

by joy]
un -

Ise
= -

, , I
Fy
, =

Uy =
'

similarly is
Py]t
gu
[ Pa
=

y =
.

thus
je =
f ( no + Sir ,
not Gu )

Ise =
f ( Hot Sse ,
Uo t Su )
÷t÷÷÷÷ :
:÷÷f
Taylor series Expansion

on

:*:÷: : ::÷÷÷.÷ .. .

..
t -
-
-

↳g 2¥
in
order
Highest Teem

2nz
H .
O .T "

"

Assuming that f- Cao ,


# 7=0 for example
, - -

1=17-1
state
-

control
input
"
-
ro
-
- o and there .
is no

, ,

thus

Item
)
II

III.
ai ' .su
item
.
-
o i
-
s.

age
-
- - -
-
-

.
.
.

Isn 't similar to


2h
2zufIm
2. for -
-
-

nxm
I = Ase t B U
yup , zu,

2¥40)
So
8"
)
in Sa
! !
-

I
-
= o

I:#
.

Zu

7 is
¥ .
- -
- a'

similarly

Y =
hlseofsse ) = h ( no ) t 2k¥ .
Eat Hot

(!! )
2K

assuming hcseol h
gunge
-
-
o
=

Y = 2h17 .
En
22

- do :

÷=f:÷÷÷I: ¥÷f
C

www.onrene-uea.me ."
# i
-

:
be = A fat B Su
i
-

:÷:÷j
LIFT

c=sy:€
je f (se )

÷÷÷÷:÷÷÷
a

Azz )
a
,

HIM
"
- -

hee Y Csa
Y )
:
=
-

:
Zu

rdacotian
Computing
-
.

f- =
fkn , per
- - -
ten
,
Ui
,
ur ,
- --
Um )

t:
"
-
-

Example of linear nation


-

.
Unicycle
-

t.f.IE
-

#fed%n nonlinear

¥o÷zIE . .

f- Cse y)

tootling
• ,

# →

je
"
topic = U cos I

the state
lets define I resin a
IT
=

x [ a ETT sie =
[ oi ,

E-
=
, ,

= W
Y = a

• let 's construct the


function to become define the state
t
(yw )

)
X ( a)


se
y a-
• = the '
" ) -

-
= , ,

.no
.
+ acne
E -
-
Csi .si soit
T
. Y = be , y a)
,
Y -
- h Cr ) = E
evaluate non-linear system at

so we can see
C Ko
,
Uo ) = (o, O
)

)
1%17
ft : s.no . + ucoso .
Ex -

-
fcsex.us =
:
the Jacobian n

.
)
÷:
't:÷÷÷÷÷t I:÷÷:÷÷÷÷÷÷,
"

son

I)
out

( Eino Toa Ey
-

so
-

-
* s.no .

=L: )
O

:
at a → o

win :÷o
=L; :b .
:

Hill
"
¥
: .

rag :/
=p÷÷÷÷÷i
:#

÷÷e÷÷ ,
.

=
[ i o
] 3C
with scalar
T let 's start
h ( XD =
( K , Y ,
a) Targa Cto ) -
-
no

a is number
scalar
,
is gruff a

I
2h (X ) She 2h , 2h professor said that the solution is

=L: : :L
= ,
I 0
- - - act -
to )

:÷÷: :* :e
no

..
.
.

Start with initial condition


20
( to -
to
)
K Lto ) = C
No =
e° No

FYI
2h, 2h,
.

Tze Ty Klto V
correct

now check general solution


, by diffferiatiuy
find stale model the
equation
dealt ?
to

c÷H : : :X:H÷k:L
-

date) Ko
=

* -
alt - to )
= E No
q .

- -
- -
-
in

xi A X B U ie = a se ✓
ne't '

-
Correct

(g ! ! ) (Ff )
what said is

:*'÷
solution
'
from pwraa,

(Tf )
.
=

T-a-higher-otde-y.es
C X je = A se sector ) = No
y
,

A- is a matrix

see the j g alwas.gs o


whatever the solution is
going
to be

to )
the control ( ee WIT is given EA
Lt -

u =
,
.
zee ) =
zeo
.

linear ration we have lost -


do
after *
taatrix
direction this called elexsponeufial
costrtrol cu y .

have to be aware that MatrixExponential is Just hire scalar


Therefore
we
,

lineariseh
-

on does not
give exponential
sometime

=€!a÷t! !
E. :t÷
" A
all the system eat
capture
or .
e
,

- in

SYSTEMS proven
it be
LTI can

- by programming
-

I;÷E:→
y
Exponential is
e. the derivative of matrix

¥e*=dEi¥ ←

E.ie#ILaEE
How such system behave ?
K
! deft A eat
¥
=

let 's staff


Ingoing input signal past similar w scalar

a
=

I = Ase se (to) = Ko k
!

What's solution taking out the first element


the
of the
system ?
by knowing the solution
behave
we can know
defeat =

kA÷t fu
t §= ,
A
Ce -
s
) !
how the
system .
,

u
I
E Ak th
-

= o +
ka ¥ !
'

-
o + *
E
'

=
AE.oA÷!
.
-

solving the controlled Equation solving A


-

dzfotoIH.to
we turnt control "
Mal
scale space DT
,
) Buk)
sie = Ase
-
the solution
f- Cest )
t
't 't -

)
Real
f.tda.tk
x e
-4
=
d
fct.es
.
'
= + . -

T
)
etttt
--

ie =
A sect )
.

de
define =
Ect ,
t) Butt ) t AOI Ct ,
t ) Butt)

Lt to )
EA
-

=
OI ( t
,
-2
)
so
thees

k =
Ect ,
-4 .
se CE )
dde7-ttl.AOILE.tojkltd-EG.tl in
Butt) t

# AOI Cti ) Butch

I
DOICE to) A ICE to )

)
,

(Itt # Ect
= ,

der Butt)
-

' A ,
to) alto) t , e) BUNDT +

) I I ideating take
ICE t
-

= .

-
state space
,
with control signal this is oust sect )

je B ✓
d÷7=
= Ase t u
A Nlt) t Bu Cf )
is correct
Professor solution C. claim that professor

f!
.

Ect
Ct -4 But ) da
HH a ,
to ) Reto) t ,

correct
Now IN
fcehrhraoy
the Bobek on is
verify that
poof
start with initial condition .

C- = to Ic = Ase + BU

Heo ) -
- IO ( to ,
to
) alto ) t Cto , a) BUCH de y = Cse
E
-
-
I o
YLE) -
-
C Elt ,
to ) Rko ) t
C)Ect -4 ,
BUCH DI

RHO ) = R CEO ) ✓ correct to

Act -4 ,

Now check the general creation .


Ect ,
e) =
e.

{ II compute
UK) DT Don't don't
KLH -
-
IOCE.to ) se Cto ) + CE ,
t ) B worry
we need to

all above but rather we oust


stuffs ,
Taking the first derivative
need to regrow it to move
forward

d÷H= ÷ #Ect
to )
behavior which
+ ,
e)BUCH de
studying the system
T the system stability
htt
.

= A ICE ,
to ) neo, t - - -
this difficult -
-
-

:n±÷*f
-

y
-
:÷¥¥a:i:÷ :*
-

STABILITY ctdet Systems


- flight
-
't 't
HIE) to
design sie Ase e
control objectives se co ) o
-
= -

: =
, ,

1. stability r
Because A is a matrix we cannot
2 .

Tracking A 70 but rather we check


say ,
-3 Robustness the eigenvalues matrix A
condition
of
.

9 other obscures

and
Eigenvalues eigenvector
scalar systems -

self ) =
eats co) to :O
A u = Xu
,

behaviour
-
I I t
lets check the
system cnxn pen
"
scalar
setts

teigen
④ a > ° matrix vector

↳ eigenvector ECqypu.gg
value

the how the matrix


NCE )
, eigenvalues tell us

A "
acts
"
in different directions (eigenvectors )

§#
④ a "

it is non zero vector .

"
MT

4:11 : ) ali)
• -

KCH
④ ^

µoµ,
a -0

- if I I I
or

l : .in ::: :L .si: :c::L


+

Three
-
cases
of stability .

1.
etsympfioticaly stable

tf seco )
Feuding Eigenvalues and Eigenvectors
KCH -20 ,
-

Ace
" "
tf all Are
for
" =

sect ) will to zero


go
do
"
condition seco) AW O
of =
-

in this Kalat at °
of XI )
CA
case
- I = o G)

2 Unstable
.

since U is non vector then to


Zero
UK
,
Fae co) :
Ct
) " → u
)
satisfy Ci
" "
condition of
(A XI)
"
there F some 0
exists
def -
=

which the sett)


Uco )
for system goes
example

( do I ) )
to "
infinity crows

deff
up )
I)
.

o
-

la the case
of scalar a > o

,
-

3
Critically stable :

( (3g !) )
R
.

def
-

"
The does to so
system not
go infinity
bat does not either
go
"
to Zero
,
.
.

a. O

C d) ( )
a

-2 -
d -
G -

-
o

'
-
6 -
d t d - 6 = O
d, 4
=

At d 22 0

) de
-

=
-

=-3
(X -
4) ( X t z )
Example
Aag de
(: :)
:
s
-

A.
( A - AI ) it = o

''
'

µ ) l ! ! )) ( Y )

Eigenvalues
! -
-

-
o

outta - AI ) - o

f; :X: ) att ? )
"
o
-
a

K)
( c d) ( = o
- -
I -

202
}
U
hw#on
0
t
X, 12=-1
=

Infinite
,
-

go, - go, =o
-
I + 42 = o = I

If 4=2 Eigenvectors
2K
/
O

)
2 t
-

II I
-

A 0
-
=

U2 = I

=L? )
( to (
so it is the eigenvector correspond to 'd = O

eigenvalue di -
-
4
.
And also .
,

If we = I

l :)
* = -
i

Ur = - O .
5

So also the eigenvector correspond


)
is
0=4 ,
Ni - do, = o

to And there
eigenvalue X, so on
= 4
dik
.

Y
.
-

= o

correspond
-

to
are
infinite eigenvector et

a
particular eigenvalue .

de =L de -0 Iz = 1
,

The meaning of eigenvalues and eigenvectors 4=1


,
or =
-
I

geometrically 9=2 ,
K -
- I
# ,

A- t.tw
-

called
de -
-

l U = i if = 0
A * the
eigenvalue also
stretching factor
-

the ,
,
er = -
I if =L
,
it eigenvector , also called the
stretching
.

is the Direction
-

;
A the line at transformation
-

In
LD
n

.
-7 Av
describe the
.

i How can
eigenvalues
system behaviour ?

I
from state space system dynamic from A p e
p p we have

je AK

/A=pppT#
=

for to so the solution is


,

sect) =
eat seco
) -

theorem

µ#
+ T and H
'

for innertable matrix


e oriental Matrix
any
then -
'
HT
et CH
-
I
f-
Ame
Eigenvalues h Eigenvectors = T T

AT Rtt where A matrix


exponential
-

= is nxn
the theorem of matrix
Using
'
find eigenvalues
-

suppose that we n
At PDP t
.

di Xr da and L
,
,
. .
. the
corresponding = E
" t '

eigenvectors
-

are
= p e .
P

I !÷ )
.mn#qneu::areaenumoa::ue::(su..÷: "÷÷÷÷
a: n: .:nm.?. . . r
"
" "
remain:
-

. .
.

"

( )
o
-

o
-

P vi v .vn
.
. .
-

.
the
Back to the solution
of

it:÷÷÷÷÷÷:)
state
space dynamic

me. # no ,

)P
"

! ÷

not
P
"
and desire a matrix n whose e

diagonal elements are the


eigenvalues .
µ ,

§! !g÷÷ a)
D= so
for tf Seco) the behaviour
of
characterised
by
-

the system is

the
.

the eigenvalues of system


we that
can
verify matrix A .

isn't
IAP=PDT
it is clear now ,
?

if 7120 : sect)
- → u

is rotted
-
.

there is one or more eigenvalues


Sf
sect )
are negatif
then
goes
to
infinity
Example

(to %)
add the system
A- = if
we
up
caused each
by
ruesponse
then the system
eigenvalue
the
eigenvalues are ×, se de = -
, dynamic will

look like
,

+
the
eigenvectors Y
( lo ) (9)
are -
-
Vr =


rise

A describes the system dynamics unstable


'

the
skin : :
self ) =
ett zeo
Tammany :

p.to : ) D= ( I :) a -
-
ar

'" " the solution is sect) = EAT No


sect ) = p e p Ro -
=
Asymptotically stable

al: :) oil: :)
--
.
-
If and only if

Re (d) so Ad E eight )
(et ele )
,

NCH =
ko
"
red
part of X is
negatif for all

suppose that unital state Ko = (


c
,
d Y d which the element
of eigenvalues
T "

) of system
A
(se
taahix
and sect ) =
Lt ) see Ct )
, ,

then --

burnable

4:47 ) E (f ) ITA E eight ) recd)


: > o
-

,
"
there exists d which part of

C.: E. t.ws Eisen::n;a¥:÷÷:*.ie::


.
.
.

Converge
→ to Zero
-

stable
that
Critically
It is
proved
also by an
example -

Positif eigenvalues make the


system
unstable
.
Only if
Re CX ) so ,
the eight )
"
less equal
to
too more complex systems ,
the real part of d is or

of eigenvalues
it can be deduced that the all X which part
zero
for
will add the
eigenvalues up of system matrix A
"

state behaviour
system .
"
and have negative
one
eigenvalue is o the test
Cn
graphical it can be
explained real "
part
,

as follows
K two
purely imaginary eigenvalues and

I✓
the test "
370 have
negatif real part .

deco
and transfer which
computed
as
state space
function
feigCAI-detfA.AE#
5h = AN t U
go at can be concluded that

RW
Y CR t CA) is
actually the
system poles
-

eig
-

so the simple dynamic system diagram .


is Examples
-
.
: A morning particle .

=p
'

→ u

a-
Et

dynamic p
acceleration
-
the control signal
is the
particle
thus the it defined at
transfer function
-

if p is the position and P is the velocity .

fffT (
'
=
lets define the star se = P ,
F )
VCs )
thus we have
A- F re

form of
lets the state
the space

ftp./- ( Oo to )f:p ) ( Y )
get eaycace u
+
Bucs )
sxcs ) Axes ) je ←
-
=
t
l
n
position
(SI - A
) Xo ) = BUCS ) assume that we can
only observe Ahe
' the"
xes ) CSI Bucs )
-

A
)
)
=

Cio) ( Pp
-

y =

- YG ) = C X Cs ) t D VCs ) e

( (Oo ! ) ( I 1) 1=0
'
CSI At Bucs ) t Dues )
eight )
= C

-

"
=
(CGI -
A) B t
D) Vcs )

/
'

µ!
AT
Yui, =
c CSI -
B t D ⇒ o
=

=
C ad2( SI -
A
) B t D
'

d
Esta
-
-
o

ads CSI ) def CSI A ) Lef find the


transfer function
Y
C -
A B t
-

part
-

focus the denumetatrr


def CSI A ) only
.

CSI A)
=/ (so ;) ( Oo ! ) )
=
→ numerator dot -
-

DCS) → Denumeratm

! !/
stability of system

=/
Poles described the the .

'

obtained characteristic s
ftp.gaaa.be
by system =

D Cs) = O

+he
tchehaoalcteristic E-
gutian
|detCsI-A)= is
5=0
From the we know
state space and
poles
the are

the system behaviour can


that
be deduced
by
the
eigenvalues so the poles are the
eigenvalues
matrix CA )
of the
system the
system
of
.
.

eight )
CEIL : ill:# to ]

SYSTEM DYNAMICS SIMULATION USING PYTHON


WITH INPUT VARIATION

INDRAZNO SIRADJUDDIN, ZAKIYAH AMALIA

1. First Order Systems Simulation


1.1. Example 1.

1.1.1. Di↵erential Equation.


dy
(1) ⌧p = y + Kp u
dt
dy y Kp
(2) = + u
dt ⌧p ⌧p

1.1.2. Transfer Function.


Y (s) Kp
(3) sY (s) y(0) = + U (s)
⌧p ⌧p

PsgI!I
Y (s) Kp poles : "

(4) =
U (s) ⌧p s + 1
where y(0) = 0.

1.1.3. State Space. The general form of the state space is


(5) ẋ = Ax + Bu
(6) y = Cx + Du
If x = y, ẋ = ẏ and u = u then

(7) ẋ =
1
x+
Kp
u
eight)⇒
deff et
-
-
d
) - o

⌧p ⌧p a.
(8) y = x
amour
¥
- - '

1 Kp .
In this case A = ,B= , C = 1 and D = 0
⌧p ⌧p

1.1.4. STEP Input.


(
0 for t < 0
(9) u(t) =
1 for t 0
1
2 INDRAZNO SIRADJUDDIN, ZAKIYAH AMALIA

1.1.5. Python. The python code is listed below

1 # !/ usr / bin / env python3


2 # -* - coding : utf -8 -* -
3 """
4 Created on Mon Feb 24 10:17:26 2020
5
6 @author : idr
7 """
8
9 import numpy as np
10 from scipy import signal
11 import matplotlib . pyplot as plt
12 from scipy . integrate import odeint
13
14 # Simulate taup * dy / dt = -y + K * u
15 Kp = 3.0
16 taup = 2.0
17
18 # (1) Transfer Function
19 num = [ Kp ]
20 den = [ taup ,1]
21 sys1 = signal . TransferFunction ( num , den )
22 t1 , y1 = signal . step ( sys1 )
23
24 # (2) State Space
25 A = -1.0/ taup
26 B = Kp / taup
27 C = 1.0
28 D = 0.0
29 sys2 = signal . StateSpace (A ,B ,C , D )
30 t2 , y2 = signal . step ( sys2 )
31
32 # (3) ODE Integrator
33 def model3 (y , t ):
34 u = 1
35 return ( - y + Kp * u )/ taup
36 t3 = np . linspace (0 ,14 ,100)
37 y3 = odeint ( model3 ,0 , t3 )
38
39 plt . figure (1)
40 plt . plot ( t1 , y1 , ’b - - ’ , linewidth =3 , label = r ’ Transfer Function ’)
41 plt . plot ( t2 , y2 , ’g : ’ , linewidth =2 , label = r ’ State Space ’)
42 plt . plot ( t3 , y3 , ’r - ’ , linewidth =1 , label = r ’ ODE Integrator ’)
43 plt . xlabel ( r ’ Time ( $t$ ) ’)
44 plt . ylabel ( r ’ Response ( $y$ ) ’)
45 plt . legend ( loc = ’ best ’)
46 plt . savefig ( ’1 st_order . pdf ’)
SYSTEM DYNAMICS SIMULATION USING PYTHON WITH INPUT VARIATION 3

3.0

2.5

2.0
Response (y)

1.5

1.0

0.5 Transfer Function


State Space
0.0 ODE Integrator

0 2 4 6 8 10 12 14
Time (t)

Figure 1. System’s responses Listing 1

47 plt . show ()

Listing 1. Python example

2. Second Order System Simulation


2.1. Example 1.

2.1.1. Di↵erential Equation.

d2 y dy
(10) ⌧s2 2
+ 2⇣⌧s + y = Kp u(t ✓p )
dt dt
d2 y ⇣ dy 1
(11) 2
= 2 y + Kp u(t ✓p )
dt ⌧s dt ⌧s2

2.1.2. Transfer Function.

⇣ 1
(12) s2 Y (s) sẏ(0) y(0) = 2 (sY (s) y(0)) Y (s) + Kp e s✓p
U (s)
⌧s ⌧s2
(13) Y (s)(⌧s2 s2 + 2⇣⌧s s + 1) = Kp e s✓p U (s)
Y (s) Kp s✓p
(14) = 2 2
e
U (s) ⌧s s + 2⇣⌧s s + 1

+5-2455-1=02,11
where y(0) = 0 and ẏ(0) = 0
poles i
4 INDRAZNO SIRADJUDDIN, ZAKIYAH AMALIA

2.1.3. State Space. If x = [y, ẏ]T and ẋ = [ẏ, ÿ]T then


2 3 2 3
 0 1  0
ẏ ⇣ 5 y + 4 Kp 5 u(t
(15) = 4 1 ✓p )
ÿ 2 ẏ
⌧s2 ⌧s ⌧s2

⇥ ⇤ y
(16) y = 1 0 + [0]u

In this case
2 3
0 1
(17) A = 4 1
2
⇣5 →
eight )

'll:c '÷! ti :D
⌧2 ⌧s
2 s3 de
0 -

(18) B = 4 Kp 5 .
⌧2
⇥ s ⇤ ,
(19) C = 1 0

'÷÷ .to
f
(20) D = [0] "
2.1.4. Python. The python code is listed below .

1 # !/ usr / bin / env python3


2 # -* - coding : utf -8 -* -
3 """
4 Created on Mon Feb 24 10:18:04 2020
d) ¥
4k¥
o
+
-

5 + .

6 @author : idr
,
7 """
N
29¥
d
¥,
8 o
t + =

9 import numpy as np
10 from scipy import signal

|Tidt29Esdtl=I
11 import matplotlib . pyplot as plt
12 from scipy . integrate import odeint
13
14 # tau * dy2 / dt2 + 2* zeta * tau * dy / dt + y = Kp * u
15 Kp = 2.0 # gain
16 tau = 1.0 # time constant
17 zeta = 0.25 # damping factor
18 theta = 0.0 # no time delay
19 du = 1.0 # change in u
20
21 # (1) Transfer Function
22 num = [ Kp ]
23 den = [ tau **2 ,2* zeta * tau ,1]
24 sys1 = signal . TransferFunction ( num , den )
25 t1 , y1 = signal . step ( sys1 )
26
27 # (2) State Space
28 A = [[0.0 ,1.0] ,[ -1.0/ tau **2 , -2.0* zeta / tau ]]
29 B = [[0.0] ,[ Kp / tau **2]]
SYSTEM DYNAMICS SIMULATION USING PYTHON WITH INPUT VARIATION 5

30 C = [1.0 ,0.0]
31 D = 0.0
32 sys2 = signal . StateSpace (A ,B ,C , D )
33 t2 , y2 = signal . step ( sys2 )
34
35 # (3) ODE Integrator
36 def model3 (x , t ):
37 y = x [0]
38 dydt = x [1]
39 dy2dt2 = ( -2.0* zeta * tau * dydt - y + Kp * du )/ tau **2
40 return [ dydt , dy2dt2 ]
41
42 t3 = np . linspace (0 ,25 ,100)
43 x3 = odeint ( model3 ,[0 ,0] , t3 )
44 y3 = x3 [: ,0]
45
46 plt . figure (1)
47 plt . plot ( t1 , y1 * du , ’b - - ’ , linewidth =3 , label = r ’ Transfer Fcn ’)
48 plt . plot ( t2 , y2 * du , ’g : ’ , linewidth =2 , label = r ’ State Space ’)
49 plt . plot ( t3 , y3 , ’r - ’ , linewidth =1 , label = r ’ ODE Integrator ’)
50 y_ss = Kp * du
51 plt . plot ([0 , max ( t1 )] ,[ y_ss , y_ss ] , ’k : ’)
52 plt . xlim ([0 , max ( t1 )])
53 plt . xlabel ( r ’ Time ( $t$ ) ’)
54 plt . ylabel ( r ’ Response ( $y$ ) ’)
55 plt . legend ( loc = ’ best ’)
56 plt . savefig ( ’2 nd_order . pdf ’)
57 plt . show ()
Listing 2. Python example

3.0
Transfer Fcn
State Space
2.5 ODE Integrator

2.0
Response (y)

1.5

1.0

0.5

0.0

0 5 10 15 20 25
Time(t)

Figure 2. System’s responses Listing 2


simulation
simple Robot
program
→u= it
← =
(p ,
if
••
I = (E ,
is IT
p
X = A X t B U

iii. instill
"

I §

?
U
Y =
C X t n

yall )
( Pp )
o

⇒ wog summat the


position

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
thesis
plots
""" stake space VS ONE-HIT
Created on Mon Apr 13 12:00:30 2020

p a


@author: idr
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy import signal The some results
from scipy.integrate import odeint

yq
u = 1. - a ,
um,
gag
t = np.linspace(0, 25, 100) y
u1 = np.ones_like(t) * u

A = np.array([[0., 1.], [0., 0.]])


B = np.array([[0.], [1.]])
next time
just
C = np.array([1., 0.]) ride One simulation
D = 0.0 eigenvalues
dam
eigvals, eigvecs = np.linalg.eig(A)
→ method either :
A
sys1 = signal.StateSpace(A, B, C, D) eigenvectors
1 for funding

7ToH:tHN
than
t1,y1,x1 = signal.lsim(sys1, u1, t, [0., 0.]) eni find condition sea sea o
in

2 state
space
off Ax t the
→ =
def model(x, t, u):

aieonuintmame
'
dxdt = x[1]
dx2dt2 = u
return [dxdt, dx2dt2] .

x2 = odeint(model,
-
[0., 0.], t, (u,)) x =

1¥ =/ model
plt.plot(t1, x1[:,0], '-.r')
plt.plot(t, x2[:,0], ':g')
"
eigenvalues =
roots =
poles
print ("Eigen Values \n = ", eigvals)
f, = O
S z
= O
,

plt.show()
-

meaning the natural behaviour the


system
:
of
is that the tofot will remain still
at initial point .
Unless the
control u is
given
lineatisafion Neat question is how do pick
k -

we or
Escorcia :

control gain
following around se
linearis the system
.
.
- o

closed
the idea is to
pick k so that the -

loop
(
= LE t VE t ee
system hone the desired
eigenvalues poles )
't
( ) d- Cassi
x =
2-
,
E U - T
Before we confirmon the on
,

why the
fzofessor choose
megabit sign
ie -
-

fi ) ( item -
-

+ ye +
en
.
Ha for the controller design

U =
k se

I:÷÷÷÷ I:÷÷÷÷: .e÷¥¥ .ie.IE#er:E:*aeerSfafele


-

"

: :*
which that
. ,
mean
expecting
If the system converges exponentially

=L:c :/ =L : : )
.

""
an

the
u.

.
a. e.
. ..

::÷s
.

I t:÷÷÷t ,
"

-
t

method
ft the observed output is only t than Pole
placement
that the
the idea select Hehe k so
,

(t )
Y ( c o
) Poles megabit red parts eigenvalues
= are
the
,

of the system ate


having negafif teal parts .

C C o
)
computation
=
lets recall the eigenvalues

Cfg ) toemenapmpks
D ofataahix ta
mm!
: o -

(M )
-
det at

Control begign eight )


-

att: ill
-
-
-

Stabilizing the point teas .

is

µm' Id ?
the Lte state given
-

space as
a def = Cm a) Lma N
.
- -
- mum
,
m
Fe =
Ase + BU
,
if = Cse

@g_p.u
= Mima -
limiting )d t M - m,
my

P N (m
- , t ma )X t Meng - M-
Ms - O

ie :

(: f) set
(7) u
A .
.
-
-
Cme
-
-ima > ± EEEa.meim.TT
should *eigenvalues from
To stabilise the
system the control signal U it seems that
finding the corresponding matrix
that element
be given . the question is what is u
of
ra is
affiant .

can stabilise the system .

The solution the fundamental


easier comes
from
The state feedback solution is to
design theorem of algebra
the control
signal
to be proportional to "
the ports in a

polynomial
are
completely determined

the state by the "


coefficients
u = -
KR ± -
(Kc ,
lez ) (I ) , eigcra ) =
,
d
'
- Cme -
ima )d t
minds
- o

te -

coefficient coefficient coefficient


f- or given values of
roots a-
eaigen values ( d. , da ,
. . - du )T
then the characteristic equation is formalised as

( X A) (X da ) Cd du
) the closed loop diagram
f- (d) -
-
. . .
- -
o
=

II (d di )
f-
o
⇐ nth order Be

IT
= -
-

u
-

£=*B
[
for second order

f- a) = (d - A) Cd -
di ) =o

TU
-

If the desired eigenvalues are


given as de = -
i
,
T

stabilise the -
X, =
-
I to
system then the desired
'

characteristic Equation y
aliases the controller
design
(d) (d c) Cd-i ) I 21 +
1--0 always guarantee
f + +

stability ?
=
=

Not
-

The is no
Back to the
professor
answer
state proven
given space .

the be stabilised of course


(Fg )
all system
can

je Ase Bu
(Te! ) E-
.

= t k -
-

state control
is B. then whatever u
can not change
feedback
=o

the word
system dynamic
other
fee
(Rea)
in
)
or
U = -

,
ka = - Kae ,
" "
the
system
can
is not rich then

plugin
e
if B

je Ase Bk se
not be controlled .
To see this
,
-
=

let 's discrete of


si define
a
formula
=
(A -
pie
) se

the state
in space
this is a new
system matrix
after Rue , A Ree = t Buy
u is
given and called It
where instant
-

y y the d- s crete time


.

I Ise also control problem


and see
simple
= a

④ ) (9) )
'
F- CA ) La *
-
-
Bk =
-
en ) •
an .
.
.

in
o

EM: :)
'

Bo

Ro

th )
controller the would move the state
= suppose the
initial to the desired state seat
state ko
from
-

achieved it
that
and take n time step to
.
how

initial slate then

µ
Kf 's no

(ad
the

( )
= -

eight ) -

-
def E - KI =
def -

,
Kao R = A Ro f B Uo
,

! a)
-
-
det a o = Bao
.
.
z
-
d Kei se =
A R, t BUI
,

£ - d (Ig -
X) t k
,
= o = A B Uo t BA
,

IT t ked tie , = O
E -
- 2
dog = A Nr t DU,

have
'

so we

cchatadenshc function
= A CAB Uo t Buc ) t Bur
the desired
AZB Uo t AB Uh , t Dur
d'
=
a 2X t I = O

BY !! )
I
and the
system characteristic function hah " m -
-

x. + e. a * -
- o

therefore the controller gains Mn


Rn
x
In £
Kz = 2 and Kc -
I the state
dimension of
-

n a

the
will stabilise the
M e d- mention of input
systems
Examples

If:÷ )
"
:

C
9)
an
Lila
'
① ie
=L ?
-

see

T '

exists
the state number n = 2
the solution if
and
only if
the of it the
controllability
Fanu
taasnix is

rank (T) -

-
n
T =
(B AB )
(T) linearly independent
( I 9) l! ) ) :( ! I )
tank is the bet
of
mum

(
'
=
tows column #ahu in
of
a-

to check wether the ,


that is want
, if we

given dynamic system is controllable


the rank of
Tt
rank ) = I S n

then validate
we must if
The
system dynamics
number state can not
is
equal to the
of .

Therefore
M is called
controllability matrix
.
be controlled .

precious of matrix

( f) (9)
tank


a
sie
Oo
= see
have
suppose we

Hi t 2 Rz =
4
k
, t 2K = 5
the date number n =
2

what are see and see that fit


those
equation ?
in matrix
form T = (B AB )

l: HT 't:L Nz
i c: :X :lH : : )
-

A-
n

"
m

"
rank (f) = 2 = n

The rave
of CA) HER the
therefore system dynamics
= , and

that where
means rank
deficiencies , is controllable
the ( )
.

tache A is less than the number of


rows
Cng or the number
of columns ( m )
there solution
-
pole placement controllability
of
'

and
.

as no se
,
see that

fit to the Equation .


je
-
= Ase t BU
It will be the same tuesulf of rank
U Kk
deficiency
-
re

for
x, t 27 = 4
⇒ ie =
( A - Bk ) K

goes -1 4K , = 5
-

(⇒ (T)
~

←(
=
A
is not the pole placement
to
arbitrary
independent onsd
sinew the second rows is 2 times the first row
eigenvalues is possible if only if
the matrix E is
full tank
.

rank (F) =
n
I

Point to
point us .
Trajectories . Case studies
-

we know that robot


ivegooay
sie
=L ! ! )
set
(9) u v

is

meant
controllable
that
system dynamic
by giving
,
which
¥0
robot consists of
U = -
KR Segway Dynamic
the control signal
U can
bring sub system Dynamic
desired
system dynamic
to the
the segway a
unicycle t inverted
pendulum e -
- -

state htt However


unicycle (the
it does not babe
.

controller can
necessarily that u

" • sign it as a E- aw

I
state
follow to any arbitrary Jez = Tsin a

trajectory .

r
:{ an.ge?u.-oon-
ta-exam.pe of point maps Is
the state ( p B 7 where
se =
, the state se = ( sci ,
se -
T input -
-

T
P is 8 is
Velocity
the T
the and ( )
position
o
z Csi je )
u w
-
-

,
=
, , ,

If we draw the state in 2b


caof inverted pendulum

NP
sext

1-
t-Bag

.
. .

Ock ,
the blue line is the desired
suppose the state
,
trajectory is it possible that
Io ) of
u can
,
see =
(¢ ,
* the angular position
the state the R* pendulum normal
more Seo to of the

from
given
desired trajectory ( blue line ) ? to the gravity .

lhtow input
The answer is impossible ,

Itueufegtttmheec
.

)
'
Th
feet
'

can the
point mane in the negative a-
,
er

velocity ?
direction
using positive In = torque toon
trajectory the right wheel .

The ' solution may


look like this
Segway state
T

*
B K : ( see ,
see ,
it
,
a
,
E
,
& ,
d)
N

[#
K

• •
ko a = ( Te , Ip)T

/ Y sa the Dynamic
States

P x
-

-
Coosa ,
asana
,
ii. E. it oi , ,
IT
Segway dynamic diff eq .

Mb ) ie doit mbd send ( Io 't E)


3. Lmao t mb das
Iz CT, t Tn )
-
-
=

( Cs Tt mbd Ivi mbd 's info I If ( Tat )


'

Ipa ) 'd
Mw t sin t Ie t
as E- =
Tn

mad cool ie t C- Mbda -


I, ) II t ma
d
'
sin
9 cos
4 To 't mis g d
sing = Tutty

?
'

Sabaean
modeling
to missaoable
horrible diff equation
-

f linearis et at room ( se
,
u ) -
- Co , o )

dad
give
all
parameters value

we have

sie a Aoe t Bu

l:÷÷÷÷÷: t.it
d O
=
Ki
Zz a o

:::÷: i
§ o o

o
o

o
o

o
o

o
72.49
d

O
l O

0
.

I
O

-24 .
-
O

24.15

Check the
controllability Mahin TT of the
system
using python :

rant ( Tl ) =
6 the state number is 7
controllable
which means that thye system is not fully .

the base not move the robot en


y direction
that we can
teoneuedet
for
.

not be controlled
system
state can
complete the
so
for a

the base
only it and ate enough for driving then
If
w
,

system dynamic
state
we can reduce the
by removing the
unicycle

c :*.n÷÷÷÷÷÷n⇒
ie a
O O 2.16 o

: :÷ .

using python
state number is 9
rank (F) = 4 and the new

controllable
rank therefore
the system is completely
that is
full
.

.
,
now let's stabilised the robot at desired
ad =
(od ,
cod ,
O
,
0
IT
in

A T
je = se + B u

the
pendulum position is uptight
and the angular velocity
of
E R Kd the
pendulum is zero
= -

£ = je Since Hd = O

E = A
( e
toed ) t Bu

E A A Bu
=
e t Rd t

÷÷÷ it:L
*.

then

E = Ae t Bu
to the desired delate Rd
by setting the controller to drive ,

matrix is thill the same as


It turns out that the controllability
stabilising at k£-6,0 o
so IT
tyre original system dynamic
,

and still controllable .

Eigen values
the
the pick the of error system
If professor
dynamic as

de du -7.5 dg at da, ( all negative )


Lg
= = = - o
-
= .

-
and characteristic
what is the desired Eg .

ke
)
U
(d de ) CX Mfd A) H da
- -

fay
- -

-
-

E ( A Bk ) ?
=
-
e

find the vector K

and simulate the system responds e tight wheel and


left wheel
are controlled with the same

AT =
( A -
Bk ) / control signal

in: : :÷÷n÷÷÷÷÷÷n :
#hand
exercise this by
: : :c
I
:p
.

and compute eig CF ) by hand


!
Observer the terror dynamic
to
up
until now we know how
predict & = je -
I
the system behaviour by giving the diff
equation of the system and we also know a AK - AE - L (y - CI )
how to stabilise the system called W
by so -
pole placement method the other
how
one more
question for ox we are
going actual observer
to measure the output state y to become
the input state too have full state feedback system
)
-

-
-
Aase - AE -
L Cee - ed
u Y

se
y -
ca : = A ( se - ai ) LC ( se - I
)
1-
-


-

i
-
'

,
-

CA )
i ,

e LC e
L =
i -

.
- -
. . . . .
. -

Since don't
-

what is value
to stabilise the error
dynamic e.
we how w exactly the

have to L such that


of R
from the sensor
reading ,
thus we are we pick
observer real
by
)
going to estimate the state an
haxvee negative
eig (A
LC
.

to
The observer has mimic the
system dynamic
without
giving
the control
signal a path
ie Ase
pole placement again
=

if = Cae

so the

is
copy of the system dynamic I reactor
IIe feig ( A -
LC )) L O

je A E I state
Eixample
=
=
the
estimate -

if I I

¢ ! 1)
c
the dynamic
=
=

Ie
J output I-sat.LI?e se
-

the estimate
-

-
-

Therefore ,
we need a notion
of
how
good
the state estimate mimic the real system .
Y = ( l - l
) K

they we add the state estimate comparison

theofsetuetdltignx )
to the estimate of
the
system dynamic cpaeofcfor )

a AI c- L Cy -
CI ) e- = CA - LC e
w -
p >

9aiatg%Fauhronesh.mu at et Katie 2×1

T
.
,
,
matrix
-
predictor cot rector

e:p ite
:
e .
-
-
-

" "
Leuenberger observer

How do we choose L ?

( j! ÷:L )
' ' '
=
e
Choosing the observer Eoin
,

idea observer L
the
of choosing
the
gain -
is stabilise the Iab tuner such that the ~

A
between the actual state se and
difference
the estimated state
eig (E)
at zero
the characteristic
is
equation
Lim e se I 0
of the observer
-
-
=

t →o .
simvlasi dougan odeout
program

E:L le
:
e
" "
⇐ it : :X :L
-
-

"
III. le
r c
I :L
=L :L
-
-

C
observer

Kitt: :X:b If it :D
-
-

a -

eight ) .
-
det
ft - II
) #!/usr/bin/env python3

.it/--detfII.'
# -*- coding: utf-8 -*-

deff fi
"""
-
-
Created on Mon Feb 24 09:13:35 2020
-

@author: idr
"""

import numpy as np

)
'
III.
" from scipy.integrate import odeint
import matplotlib.pyplot as plt
a
-
plt.rcParams['text.usetex'] = True
thus the characteristic the observer import os
equation
of #
os.environ["PATH"] += os.pathsep + '/usr/local/texlive/2018/
-
bin/x86_64-darwin'

( -
l -
Li -

d) C- 2 + L2
-
d
-

) -
↳ (2-14)=0 # function that returns dz/dt
je
-

An
-

z
- n
def model(z,t):
d't
y
=
-
d(
,

, (3 t Li -
La
) + 12+24 the)
= O dxdt = -z[0] + 2*z[1]
d2xdt2 = -2 * z[1] y = Cx
I - -

y = z[0] - z[1]
- - -

)
- -
- - - n

htt CI
gaiD=
n
desired that the AI
'

now we
eigenvalues d, = I t
- -

=
yhat = z[2] - z[3]
thus the desired characteristic equation as dxhatdt = -z[2] + 2*z[3] - (2./3.)*(y - yhat) CI
d2xhatdt2 = -2 * z[3] + (1./3.)*(y-yhat)
Iti ) ti ) to
r
co - dzdt = [dxdt,d2xdt2, dxhatdt , d2xhatdt2]
d't Xtc . = 0 return dzdt

then we have # initial condition


# z0 = [x1, x2, xhat1, xhat2]
→ ( se ,
Je
Ee SE )
,

z0 = [2,4,-3, 5.] 24 5
3. t Li Le -3
2
-
=

# time points in
It 24 + L2 =
I t = np.linspace(0,10.)
wrong estimates
# solve ODE
solving those we have
z = odeint(model,z0,t)

↳ = -

Ys
# plot results
plt.figure(0) -
10
plt.plot(t,z[:,0],'b-',label=r'$x$')
113
-
↳ =
plt.plot(t,z[:,2],'r--',label=r'$\hat{x}$')

finally if
we pick Kef -

Y, ↳ IT then plt.ylabel('response')
plt.xlabel('time')
-2
will stabilise the estimate plt.legend(loc='best')
the observer error
plt.savefig('observerx.pdf')
to zero

)
plt.figure(1)
-2
( Yg Cy ca )

~
plt.plot(t,z[:,1],'b-',label=r'$\dot{x}$') '
a- at

-

plt.plot(t,z[:,3],'r--',label=r'$\dot{\hat{x}}$')
=

plt.ylabel('response')
plt.xlabel('time') →
Where k = ( se , Jez )T Nz =
Ie ,
plt.legend(loc='best')
plt.savefig('observerxdot.pdf')
The will look like
qtqfife plt.show()

^¥L
sea ① and show that

o -
the estimate converge to the

actual state
t
← O
3 x

2

O
response

K RT
°1 =

°2

°3

0 2 4 6 8 10
time
O
5 ẋ
x̂˙

3
response

1 x' =
E

0 O
0 2 4 6 8 10
time
another words
design
in
does the observer
observable
completely
'

work ? Ahe system


b

by selecting poles always


" "
if She is full rank .

No
the same as the controller design
therefore pole placement for
which does not always work .

an observer to
arbitrary poles /
eigenvalues is possible if ond only
I ⇒ check the Ct the system is completely observable
-
controllability

f
check the
Observability .


e. n Discreet time form controllability
-

A- see
Nute
=

he can
;E⇒95£Ety
=

so for 6=0 -2 ke n -
I ↳
To C Ko
=

Building Block

Y, C Re C Ako

t.kz?ttaeffe-B4J
-

= -

Ye Ck CARµ= Cairo
-
-
-

"

'

I
÷
I

Hnhokahi ob¥l
"" ~ -
Tai CIA no

¥e
÷H¥÷÷)
4-
-

a 9

✓ pokpCaam
^ tells
diode
observability
This building us

that the controller ( state


matrix design
The feedback ) and the observer design
system hang a solution
are done
separately
off
and
only if the orange
.

is
observability matrix
It
r
of prove
fall rank
of
u
a o
TROVE in the matrix
form

Ti-AoetBugfghIsffsugea@J.fA ) (f)
-
Bk Bk

Y = CR
is control Labe 0 A -
LC

and observable
y

U Kae sie CA -
BK ) se
Thi is an upper triangular
= -

⇒ =

matrix let's denote


,
-
the matrix to
state
feedback as

design
theory
.

but we
adnaly have I thus
the
eigenvalues of triangular
,

u = - KI blodetmatnix are
given by the eigen
Values its blocks
the observer of diagonal
now estimate se
using thus :

£ - Asi t Bu + L Cy -
ca )
- -
eighth ) =
eight -
Bk
) eight - Lc
)
Predictor
.

corrector
involves hone
pole placement
which
by
we

H design that
Re ( eight ))
v
- Ek so
e- =
(A - LC ) e
and
-
the observer (the Ceig CA - LC )) to

design
I
separately .

where e K
Therefore
-

SO
Cig
CH )
now the Joint dynamic between

the state feedback dynamic and Thus we can remark


,

observer dynamic by designing feedback the state


state dynamic
and observers separefty
to
% = Ak Bk I
stable
asymptotically then
-

be ,
-
the whole
system will be
thi is the real dynamic
stable also
by substituting
u = - KI
asymptotically ,

je = Ase - Bak CK - e
)

PROVED
= CA -
Bk ) a
t Bke

Observer dynamic
e- = Ca -
Lc ) e
In complex plane

:{
Final Block
Diagram of state
,

the place of poles


feedback with of scones -

and
physics of the system lpcawf of state feedback
06 Servet can be

,¥÷T
÷
T :::÷:¥ o

list
poles

:÷÷÷÷÷÷÷÷÷
.
i

'
÷ .
..

Eigenfunction
*
then
Red poles are
faster
The should
Blue
poles .

Keys : - observer go
much
faster than
the state feedback
otherwise the obsetaet
,

well not be use


full
Note :

the observer
Large gains for
-
-

will not be a
problem
Circe the observer only
be
computed in
software
-
Large gains for state the

feedback may saturate


the actuator :

volts DC motor
for example a 22

can only be driven by max

U = 12 Volts .
Kampala
E-
observability
-

high (Cea )
Robot actuator r =

¥÷'
"i

fi :c:* ):
-

Differential Eq :

boi )
E
gL( Kei
-
-

( to ) }
°

Young}pendent
=

I = moment
of neo
-
ha b -
-
friction coogea.eu
ka :
torque constant ,
i = motor current

state space rank (d) = 2 (full rank )


n
-

-
Ca, it )T ,
si -
- CE , EY ,
a- I
taste control
reference Tracking problem
for position 4=0
Case
the controller should

{ ÷)
dive the

( : Ig )
u
• se + "
'
= '

actuator to
follow the desired state

U*=(f* f-
)
*
reference where
y = ( i o
) a ,

Ext o
⇒ a*=(f* o
)
-
.

controllability -

meaning
that the
angular
T = (B AB ) velocity a* at the desired
angular
OT should

(( ÷ ) ( : !g ) ( Ig)
position be zero
=

begin the state


:
err

ex =
K - R

:*
fi :n:÷¥=f¥,
'


.

in
-

differentiating wrr t .
time

(F) (
full )
* *
tank = 2 rank
in = je - I a. so

the number since the desired


Since '

en = sie state
-

y constant
of state is 2
Ese = Ie Esea R -
Z* Characteristic function of the error


dynamic
-

)
" e- *

) µ ÷ ) f! ) @
+

(
i Aat Bu
A Bk
eig eig
=

Kd
- -
-
-

i.

Eze feat sext


)
?
= A + BU

=
Aea Ar* BU

( :c
+ + l
"
8

( ! ÷) f :* )
Aa*= .
o
o
,
y
-
o,

! Tori ))
dot
a=AeatBg
e- -
-

÷
- . .
the error dynamic

)
of C
-
-

÷
= se

det
)
't
=
cleat n

sett .ua -
one -
d
= C en t C , .

Cea Cl )
(9*1
o
=
t

dfyeo.sk ,
xd ) t 0.2 Kc = O

Cee Ext
d (440.2 Kc ) X eke
'
O
y t t t o =
-

-
term
state output in
of error

and desired state


.
lets fry favorite poles
the actuator dynamic parameters are known : di -

-
-
I de - -
I

b =L characteristic
3=2 , ka -
- o .
I
,
so desired equation
we are
going
to
design
the controller
(ht s ) ( Xtc ) = o

with observer
an
.
Thus the state
T t 2X t I = 0

estimate denoted as I and error


,
thus
estimate
n
I Kz
ly 0.2 = 2
K t
e
-
=
-

the state controller design ke 7.5


feedback =

using pole placement -


o - 2K , = I

U =
-

Kee Kc =
5

En = ( A -
BK ) ee ooo k =
( 5
,
7.5 )

ka ( Kc ka )
le placement for observer
-

P the
The observer design
.

observer
-
characteristic equation of the
we have obtained the state feedback

( ) eigfco )
gains
k >
Car .
so ) eig A - LC -

-
-

( lol
.

where the controller is

84 : ÷) fi! :))
a = -

Keese "
-

remember that

Ese = K -
sext

÷)
dont have
reality but
in we k '

eig
the estimate I this the a
,

f! ! ) )
estimated error is

i. E sett
detff:L! !)
-
⇒ -
o
= -

This estimated error In


given

? ÷)
the controller
we
compute as
⇒ det
-

- o

a =
-
Ki . ,
bus
f- the state output usinganob server

is
the d) ( la X
) t Le o
-
-
- -
-

I = cense t f
't
'

d + Cht 4) d they the =o

Remember this ; '

£
~

a AI + L Cy -
Y ) We want the observer much faster
-

F
p the state controller
than feedback
gaia
Tg: gaffes a. man
lets the desired eigenvalues
matrix pick
predictor Tt¥ de =
- lo de = -
lo

- they the desired characteristic


" "
leuenberger
equation is
observer

) ( Atco )
thus tco
is o

je Ast + L ( y Cei ft
) Ty god
= - -

0
+ too
=

observer error
dynamic
thus
E. CA -
Lc
) e

where → I -14 =
20
4 = 19.5
,
e =
R I the too
tell
-

→ =

↳ =
90.225
Therefor the observer gain
L e-
( 9.5 ,
90.25 )
Complete block diagram tracking #!/usr/bin/env python3
Problem with an Observer control # -*- coding: utf-8 -*-
"""
grate feedback Created on Mon Feb 24 09:13:35 2020 .

Ea=AeatBU-÷
@author: idr

tureen
-

U """

¥÷±e÷¥±u+uaF
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt

Observer plt.rcParams['text.usetex'] = True


import os
os.environ["PATH"] += os.pathsep + '/usr/local/texlive/
2018/bin/x86_64-darwin'

# function that returns dz/dt


def model(e, t, xd, K, L):

In #State feeback controller


→ u - Kein
u = -(K[0]*e[2] + K[1]*e[3])
-
Bu = [0, 0.2 * u]
Ae = [e[1], -0.5*e[1]] ¥:*
I Aea
'

Bu
↳ Ese
dedt = Ae[0] + Bu[0] ee -
+

fu=keTjE7one
d2edt2 = Ae[1] + Bu[1]
"

7%9672.us?cei..o.*
y = e[0]

#observer
yhat = e[2] + xd[0]
Bu_observer = [Bu[0]+L[0]*(y-yhat),
→ Bu[1]+L[1]*(y-yhat)]
Heise

But Lcy I -
)
Ae_observer = [e[3], -0.5*e[3]]
dehatdt = Ae_observer[0] + Bu_observer[0] 3. Ese
Abet But Llg -8 )

Ht:)
-_

d2ehatdt2 = Ae_observer[1] + Bu_observer[1]


a. Cu . dxdt = [dedt,d2edt2, dehatdt , d2ehatdt2]
return dxdt

#xd = [theta desired, thetadot desired]

# Eat Kreis
xd = [np.radians(45.), 0.]
=
x0 = [np.radians(15.), 0.1]
# initial condition

fam )
# e0 = [errortheta0, errorthetadot0, errorthetahat0,

l: .lu
errorthetahatdot0]
ou -
-
-

-
e0 = [x0[0]-xd[0], x0[1]-xd[1], np.radians(10.), -1.]
.

K = [5, 7.5]
L = [19.5, 90.5]

# time points

Eta
t = np.linspace(0,10.)
Jeiadt
AI Bar L
(Y F ) → in -

+ +
-

# solve ODE
-

z = odeint(model,e0,t, args=(xd, K, L,))

in -

Aldrin ) 1- But Ley 5)


# plot results
-

I
-

plt.figure(0)
plt.plot(t,np.degrees(z[:,2]) ,'b-',label=r'$\hat{e}_x$')
plt.ylabel('response')

-
A- Eat Au*t BUT L Cy yn) -
plt.xlabel('time')
plt.legend(loc='best')
plt.savefig('observerehat.pdf')
-

to:* ,
plt.figure(1)

:c:
plt.plot(t,z[:,3],'b-',label=r'$\dot{\hat{e}}_x$')
an plt.ylabel('response')
plt.xlabel('time')
plt.legend(loc='best')
plt.savefig('observerehatdot.pdf')

=L: so
plt.show()


works ! !
thus
In = Aeta 1- But LCY I -

) higher - o
BEYOND POLE PLACEMENT
The general design structure :

ee =

- se
si = A Tet Bu +
①( y - CI
)
t t
stale feeback observer
design design

-
f-town what we have studied both
be derived
design can
using
Pole placement

other methods for example :

K → Linear quadratic optional content

L → using Kalman filter

LQ :

"
K = R BT p
'
ATP PBR BT p
-

° = t PA t Q -

Kalman
"
L - PCT ( Do Dot )
where Do is the covariance
of
the measurement

mise model .

O = At P t PA -1 DI DIT -
PE Cpo pot Jcp

until Dont
worry about
the wrathful
up
now
,

The point is
of other methods you
feedEach
.

methods to the state


may
use other get
K and the observer gain L
gain e

-
-
have studied LTI
congratulation you ,

and control
system Dynamics .

work is How to model


the Rest of the
physical system

You might also like