Observer and state-space model Problemè 1
Consider the following state-space model:
x ˙ = [ 0 1 0 0 0 1 − 5 − 6 0 ] x + [ 0 0 1 ] u y = [ 1 0 0 ] x \begin{aligned}
\dot{x} &= \begin{bmatrix}
0 & 1 & 0 \\
0 & 0 & 1 \\
-5 & -6 & 0 \\
\end{bmatrix} x + \begin{bmatrix}
0 \\
0 \\
1 \\
\end{bmatrix} u \\
y &= \begin{bmatrix}
1 & 0 & 0 \\
\end{bmatrix} x
\end{aligned} x ˙ y = 0 0 − 5 1 0 − 6 0 1 0 x + 0 0 1 u = [ 1 0 0 ] x
Design an observer to place the observer poles at -10, -10, -15
Solution
The characteristic equation of the observer is given by:
d e t ( s I − ( A − L C ) ) = ( s + 10 ) ( s + 10 ) ( s + 15 ) = s 3 + 35 s 2 + 350 s + 1500 det(sI - (A - LC)) = (s + 10)(s + 10)(s + 15) = s^3 + 35s^2 + 350s + 1500 d e t ( s I − ( A − L C )) = ( s + 10 ) ( s + 10 ) ( s + 15 ) = s 3 + 35 s 2 + 350 s + 1500
From the coefficients of the characteristic equation we get
d e t ( s I − ( A − L C ) ) = s 3 + ( l 1 − 6 ) s 2 + ( l 2 − 5 − 6 l 1 ) s + ( l 3 − 5 l 2 ) det(sI - (A-LC)) = s^3 + (l_1-6)s^2 + (l_2-5-6l_1)s + (l_3-5l_2) d e t ( s I − ( A − L C )) = s 3 + ( l 1 − 6 ) s 2 + ( l 2 − 5 − 6 l 1 ) s + ( l 3 − 5 l 2 )
Solving for the coefficients we get the observer gain matrix:
L = [ 4505 601 41 ] L = \begin{bmatrix}
4505 \\
601 \\
41
\end{bmatrix} L = 4505 601 41
Thus the observer dynamics are given by:
x ^ ˙ = [ 0 1 0 0 0 1 − 5 − 6 0 ] x ^ + [ 0 0 1 ] u + [ 4505 601 41 ] ( y − y ^ ) \dot{\hat{x}} = \begin{bmatrix}
0 & 1 & 0 \\
0 & 0 & 1 \\
-5 & -6 & 0 \\
\end{bmatrix} \hat{x} + \begin{bmatrix}
0 \\
0 \\
1 \\
\end{bmatrix} u + \begin{bmatrix}
4505 \\
601 \\
41 \\
\end{bmatrix} (y - \hat{y}) x ^ ˙ = 0 0 − 5 1 0 − 6 0 1 0 x ^ + 0 0 1 u + 4505 601 41 ( y − y ^ )
Problemè 2
Given the plant
x ˙ = [ − 1 1 0 2 ] x + [ 0 1 ] u y = [ 1 1 ] x \begin{aligned}
\dot{x} &= \begin{bmatrix}
-1 & 1 \\
0 & 2 \\
\end{bmatrix} x + \begin{bmatrix}
0 \\
1 \\
\end{bmatrix} u \\
y &= \begin{bmatrix}
1 & 1 \\
\end{bmatrix} x
\end{aligned} x ˙ y = [ − 1 0 1 2 ] x + [ 0 1 ] u = [ 1 1 ] x
Design an integral controller to yield a 10% overshoot, 0.5 second settling time and zero steady-state error for a step input.
Solution
The code for the integral controller is given by p2.py .
Add an integrator to the plant to ensure zero steady-state error for a step input.
The augmented state-space model becomes:
x ˙ a = [ − 1 1 0 0 2 0 − 1 − 1 0 ] x a + [ 0 1 0 ] u \dot{x}_a = \begin{bmatrix}
-1 & 1 & 0 \\
0 & 2 & 0 \\
-1 & -1 & 0 \\
\end{bmatrix} x_a + \begin{bmatrix}
0 \\
1 \\
0 \\
\end{bmatrix} u x ˙ a = − 1 0 − 1 1 2 − 1 0 0 0 x a + 0 1 0 u
y = [ 1 1 0 ] x a y = \begin{bmatrix}
1 & 1 & 0 \\
\end{bmatrix} x_a y = [ 1 1 0 ] x a
where
x_a = \begin{bmatrix}
x \\
\int e \, dt \\
\end{bmatrix}
$$ and $e = r - y$ is the tracking error.
Then, design the state feedback gains
K = \begin{bmatrix}
k_1 & k_2 & k_i \
\end{bmatrix}
s u c h t h a t t h e c l o s e d − l o o p s y s t e m m e e t s t h e t r a n s i e n t r e s p o n s e s p e c i f i c a t i o n s . T h e c h a r a c t e r i s t i c e q u a t i o n o f t h e c l o s e d − l o o p s y s t e m i s : such that the closed-loop system meets the transient response specifications.
The characteristic equation of the closed-loop system is:
s u c h t ha tt h ec l ose d − l oo p sys t e mm ee t s t h e t r an s i e n t res p o n ses p ec i f i c a t i o n s . T h ec ha r a c t er i s t i ce q u a t i o n o f t h ec l ose d − l oo p sys t e mi s :
\left| sI - (A_a - B_aK) \right| = 0
E x p a n d i n g t h i s y i e l d s :
Expanding this yields:
E x p an d in g t hi sy i e l d s :
(s + k_1)(s^2 + (1 - k_2)s + k_i) = 0
T h e c o n t r o l l a w t h e n g i v e n b y :
The control law then given by:
T h eco n t ro ll a wt h e n g i v e nb y :
u = -Kx_a = -k_1x_1 - k_2x_2 - k_i\int{e , dt}
T h e c o d e y i e l d s : ‘ ‘ ‘ p r o l o g z e t a : 0.5911550337988974 o m e g a n : 13.53282902556064 D e s i r e d p o l e s : [ − 8. + 10.91501083 j − 8. − 10.91501083 j − 135.32829026 + 0. j ] P l a n t m o d e l : < L i n e a r I O S y s t e m > : s y s [ 2 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u t p u t s ( 1 ) : [ ′ y [ 0 ] ′ ] S t a t e s ( 2 ) : [ ′ x [ 0 ] ′ , ′ x [ 1 ] ′ ] A = [ [ − 1.1. ] [ 0.2. ] ] B = [ [ 0. ] [ 1. ] ] C = [ [ 1.1. ] ] D = [ [ 0. ] ] A u g m e n t e d p l a n t m o d e l : < L i n e a r I O S y s t e m > : s y s [ 3 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u t p u t s ( 1 ) : [ ′ y [ 0 ] ′ ] S t a t e s ( 3 ) : [ ′ x [ 0 ] ′ , ′ x [ 1 ] ′ , ′ x [ 2 ] ′ ] A = [ [ − 1.1.0. ] [ 0.2.0. ] [ − 1. − 1.0. ] ] B = [ [ 0. ] [ 1. ] [ 0. ] ] C = [ [ 1.1.0. ] ] D = [ [ 0. ] ] S t a t e f e e d b a c k g a i n s : K = [ [ − 10193.77795361152.32829026 − 12391.83976888 ] ] I n t e g r a l c o n t r o l l e r t r a n s f e r f u n c t i o n : − 1.239 e + 04 − − − − − − − − − − s O p e n − l o o p t r a n s f e r f u n c t i o n : < L i n e a r I C S y s t e m > : s y s [ 6 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u t p u t s ( 1 ) : [ ′ y [ 0 ] ′ ] S t a t e s ( 3 ) : [ ′ s y s [ 4 ] x [ 0 ] ′ , ′ s y s [ 2 ] x [ 0 ] ′ , ′ s y s [ 2 ] x [ 1 ] ′ ] A = [ [ − 0.00000000 e + 000.00000000 e + 000.00000000 e + 00 ] [ 0.00000000 e + 00 − 1.00000000 e + 001.00000000 e + 00 ] [ − 1.23918398 e + 040.00000000 e + 002.00000000 e + 00 ] ] B = [ [ 1. ] [ 0. ] [ 0. ] ] C = [ [ 0.1.1. ] ] D = [ [ 0. ] ] C l o s e d − l o o p t r a n s f e r f u n c t i o n : < L i n e a r I C S y s t e m > : s y s [ 9 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u t p u t s ( 1 ) : [ ′ y [ 0 ] ′ ] S t a t e s ( 3 ) : [ ′ s y s [ 6 ] s y s [ 4 ] x [ 0 ] ′ , ′ s y s [ 6 ] s y s [ 2 ] x [ 0 ] ′ , ′ s y s [ 6 ] s y s [ 2 ] x [ 1 ] ′ ] A = [ [ 0.00000000 e + 00 − 1.00000000 e + 00 − 1.00000000 e + 00 ] [ 0.00000000 e + 00 − 1.00000000 e + 001.00000000 e + 00 ] [ − 1.23918398 e + 040.00000000 e + 002.00000000 e + 00 ] ] B = [ [ 1. ] [ 0. ] [ 0. ] ] C = [ [ 0.1.1. ] ] D = [ [ 0. ] ] ‘ ‘ ‘ The code yields:
```prolog
zeta: 0.5911550337988974 omega_n: 13.53282902556064
Desired poles: [ -8. +10.91501083j -8. -10.91501083j
-135.32829026 +0.j ]
Plant model:
<LinearIOSystem>: sys[2]
Inputs (1): ['u[0]']
Outputs (1): ['y[0]']
States (2): ['x[0]', 'x[1]']
A = [[-1. 1.]
[ 0. 2.]]
B = [[0.]
[1.]]
C = [[1. 1.]]
D = [[0.]]
Augmented plant model:
<LinearIOSystem>: sys[3]
Inputs (1): ['u[0]']
Outputs (1): ['y[0]']
States (3): ['x[0]', 'x[1]', 'x[2]']
A = [[-1. 1. 0.]
[ 0. 2. 0.]
[-1. -1. 0.]]
B = [[0.]
[1.]
[0.]]
C = [[1. 1. 0.]]
D = [[0.]]
State feedback gains:
K = [[-10193.77795361 152.32829026 -12391.83976888]]
Integral controller transfer function:
-1.239e+04
----------
s
Open-loop transfer function:
<LinearICSystem>: sys[6]
Inputs (1): ['u[0]']
Outputs (1): ['y[0]']
States (3): ['sys[4]_x[0]', 'sys[2]_x[0]', 'sys[2]_x[1]']
A = [[-0.00000000e+00 0.00000000e+00 0.00000000e+00]
[ 0.00000000e+00 -1.00000000e+00 1.00000000e+00]
[-1.23918398e+04 0.00000000e+00 2.00000000e+00]]
B = [[1.]
[0.]
[0.]]
C = [[0. 1. 1.]]
D = [[0.]]
Closed-loop transfer function:
<LinearICSystem>: sys[9]
Inputs (1): ['u[0]']
Outputs (1): ['y[0]']
States (3): ['sys[6]_sys[4]_x[0]', 'sys[6]_sys[2]_x[0]', 'sys[6]_sys[2]_x[1]']
A = [[ 0.00000000e+00 -1.00000000e+00 -1.00000000e+00]
[ 0.00000000e+00 -1.00000000e+00 1.00000000e+00]
[-1.23918398e+04 0.00000000e+00 2.00000000e+00]]
B = [[1.]
[0.]
[0.]]
C = [[0. 1. 1.]]
D = [[0.]]
``` T h eco d ey i e l d s : ‘‘‘ p ro l o g ze t a : 0.5911550337988974 o m e g a n : 13.53282902556064 Des i re d p o l es : [ − 8. + 10.91501083 j − 8. − 10.91501083 j − 135.32829026 + 0. j ] Pl an t m o d e l :< L in e a r I OS ys t e m >: sys [ 2 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u tp u t s ( 1 ) : [ ′ y [ 0 ] ′ ] St a t es ( 2 ) : [ ′ x [ 0 ] ′ , ′ x [ 1 ] ′ ] A = [[ − 1.1. ] [ 0.2. ]] B = [[ 0. ] [ 1. ]] C = [[ 1.1. ]] D = [[ 0. ]] A ug m e n t e d pl an t m o d e l :< L in e a r I OS ys t e m >: sys [ 3 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u tp u t s ( 1 ) : [ ′ y [ 0 ] ′ ] St a t es ( 3 ) : [ ′ x [ 0 ] ′ , ′ x [ 1 ] ′ , ′ x [ 2 ] ′ ] A = [[ − 1.1.0. ] [ 0.2.0. ] [ − 1. − 1.0. ]] B = [[ 0. ] [ 1. ] [ 0. ]] C = [[ 1.1.0. ]] D = [[ 0. ]] St a t e f ee d ba c k g ain s : K = [[ − 10193.77795361152.32829026 − 12391.83976888 ]] I n t e g r a l co n t ro ll er t r an s f er f u n c t i o n : − 1.239 e + 04 − − − − − − − − − − s Op e n − l oo pt r an s f er f u n c t i o n :< L in e a r I CS ys t e m >: sys [ 6 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u tp u t s ( 1 ) : [ ′ y [ 0 ] ′ ] St a t es ( 3 ) : [ ′ sys [ 4 ] x [ 0 ] ′ , ′ sys [ 2 ] x [ 0 ] ′ , ′ sys [ 2 ] x [ 1 ] ′ ] A = [[ − 0.00000000 e + 000.00000000 e + 000.00000000 e + 00 ] [ 0.00000000 e + 00 − 1.00000000 e + 001.00000000 e + 00 ] [ − 1.23918398 e + 040.00000000 e + 002.00000000 e + 00 ]] B = [[ 1. ] [ 0. ] [ 0. ]] C = [[ 0.1.1. ]] D = [[ 0. ]] Cl ose d − l oo pt r an s f er f u n c t i o n :< L in e a r I CS ys t e m >: sys [ 9 ] I n p u t s ( 1 ) : [ ′ u [ 0 ] ′ ] O u tp u t s ( 1 ) : [ ′ y [ 0 ] ′ ] St a t es ( 3 ) : [ ′ sys [ 6 ] s ys [ 4 ] x [ 0 ] ′ , ′ sys [ 6 ] s ys [ 2 ] x [ 0 ] ′ , ′ sys [ 6 ] s ys [ 2 ] x [ 1 ] ′ ] A = [[ 0.00000000 e + 00 − 1.00000000 e + 00 − 1.00000000 e + 00 ] [ 0.00000000 e + 00 − 1.00000000 e + 001.00000000 e + 00 ] [ − 1.23918398 e + 040.00000000 e + 002.00000000 e + 00 ]] B = [[ 1. ] [ 0. ] [ 0. ]] C = [[ 0.1.1. ]] D = [[ 0. ]] ‘‘‘