MECH 4420 Lecture: State Space Control
Transcript of MECH 4420 Lecture: State Space Control
MECH 4420 Lecture:State Space Control
David Bevly
1
State Space Controlβ’ There are tools built to design controllers using state space
representationβ’ These can be useful for all kinds of systems including vehicle
dynamicsβ We already have a state space representation of the bicycle model:
β This model can easily be augmented to include heading and lateral position
β Note that state space allows for multiple inputs (unlike transfer functions). This is advantageous in vehicle dynamics where there can be multiple inputs: front steer, rear steer, differential braking, etc.
2
( )Ξ΄
Ξ²Ξ²Ξ±
Ξ±
+
+β=
ββ
β
Z
f
f
ZZ IaCmVC
VIC
IC
mVC
mVC
rr 21
210 1
State Space Controlβ’ Recall the full state space representation:
β x is nx1 (n=# of states and also the system order)β y is mx1 (m=# of measurements or outputs)β u is Lx1 (L=# of inputs)β A is nxnβ B is nxLβ D is mxL (D is nearly always zero)
β’ Also recall the eigenvalues of the system will be the eigenvalues of the A Matrix! 3
οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯ + π΅π΅π΅π΅π¦π¦ = πΆπΆπ₯π₯ + π·π·π΅π΅
Regulatorβ’ Regulator: Drives states to zero
β We will look at how to introduce a non-zero reference laterβ’ Why not just set u=0?
β Results in:β Note the differential equation becomes a homogeneous
differential equation:
1) Doesnβt guarantee π₯π₯ β 0 (what if the system is unstable (i.e., eigenvalues of A are positive or in the right half plane)
2) Even if the system is stable such that π₯π₯ β 0, canβt dictate the response to zero (i.e. overshoot, settle time, etc.
4
οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯
οΏ½ΜοΏ½π₯ β π΄π΄π₯π₯ = 0
οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯ + π΅π΅π΅π΅
Introduce State Feedback
β’ Instead of making u=0, set:β’ This is setting the reference vector (R) to zero
β Known as regulator design (R=0) β Note K is a matrix of size Lxnβ For a single input system, K is a vector of size 1xn
β Substituting this into the state space equation:
β Results in:
β Where the new (βclosed loopβ) A is:
5
οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯ + π΅π΅π΅π΅
π΅π΅ = βπΎπΎπ₯π₯
οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯ + π΅π΅ βπΎπΎπ₯π₯
οΏ½ΜοΏ½π₯ = π΄π΄ β π΅π΅πΎπΎ π₯π₯ = π΄π΄πΆπΆπΆπΆπ₯π₯
π΄π΄πΆπΆπΆπΆ = π΄π΄ β π΅π΅πΎπΎ
π΅π΅ = πΎπΎ π π β π₯π₯ = βπΎπΎπ₯π₯
Introduce State Feedbackβ’ New closed loop differential equation is again
homogeneous
β However, now I have the ability to make ACL behave like I want
β’ I can set K to make ACL:β Ensure stabilityβ Set specifications (bandwidth, overshoot, rise time, etc).
Β» All your 3140 knowledge is still useful with state space control design
β Requires that I have access (knowledge of) all the states (i.e. entire x vector)
β’ Called βFull Stateβ Feedback6
οΏ½ΜοΏ½π₯ = (π΄π΄ β π΅π΅πΎπΎ)π₯π₯οΏ½ΜοΏ½π₯ = (π΄π΄πΆπΆπΆπΆ)π₯π₯
Solving for K
β’ Recall how to solve for the eigenvalues from state space representation:
β Or in matlab:β’ >> eig(A)
β’ So now we substitute
β where
7
ππππππ π΄π΄πΆπΆπΆπΆ β det π π π π β π΄π΄πΆπΆπΆπΆ = 0
π΄π΄πΆπΆπΆπΆ = π΄π΄ β π΅π΅πΎπΎ
ππππππ π΄π΄ β det π π π π β π΄π΄ = 0
Solving for Kβ’ So basically, we solve for K such that:
det π π π π β π΄π΄ β π΅π΅πΎπΎ = πππππ π ππππππππ πΆπΆ.πΈπΈ.β Sound familiar?
β’ Its essentially coefficient matchingβ Where does the desired characteristic equation
(C.E.) come fromβ’ Same place as 3140 β from desired eigenvalue specs
β bandwidth, overshoot, settle time, rise time, etc.
β For 1st or 2nd order single input systems, solving for K (scalar or 1x2 vector) is simple algebra
β Or use matlabβ’ >>K=place(A,B,s_des)
8
Controllability
β’ Is it always possible to solve for K such that the roots of det π π π π β π΄π΄ β π΅π΅πΎπΎ = 0 match our desired eigenvalues (s_des)?β It is if the system is βcontrollableβ
β’ A system being controllable means that it is possible to find a matrix K such that the eigenvalues can be placed anywhere I choose.β Note the yaw dynamics are not controllable if the
front tires saturateβ’ But it is stable, so although canβt set the response of
A-BK (i.e. the controlled system), the yaw rate will settle to zero on its own.
9
Determining Controllability
β’ Controllability is determined by checking the rank of the controllability Matrix:
πΆπΆ = π΅π΅ π΄π΄π΅π΅ β― π΄π΄ππβ1π΅π΅β C will be nxnβ If C is full rank (rank=n), then the system is said
to be βcontrollableββ’ Full rank means all the rows of C are independentβ’ Again, this simply means that there exists a matrix K
such that the eig(A-BK)=sdes
β Matlab will form this matrix for you:>>C=ctrb(A,B)>>rank(C)
10
Additional Comments on Controllability
β’ Additionally, a non-controllable doesnβt mean you canβt control the system. It simply means you canβt move the eigenvalues anywhere you want.β In the case of the vehicle with CΞ±f=0, notice that the input vector B=0.
So in this case, you canβt move the eigenvalues at all.β However in some cases, it may be possible to move the eigenvalues
and control the system, you just canβt place them anywhere.β’ This is similar to a proportional controller on a 2nd order system:
οΏ½ΜοΏ½π₯ + οΏ½ΜοΏ½π₯ + πΎπΎππ = 0
β’ This system can be controlled, however there is only a limited subset of closed-loop eigenvalues (think root locus). There are not enough degrees of freedom to set the eigenvalues anywhere (this requires PD control).
β’ Matlab will give an error if the system is uncontrollable:β βCanβt place the eigenvalues thereβ
11
Introducing a Referenceβ’ In state space you canβt just say:
π΅π΅ = πΎπΎ(π π β π₯π₯)β’ Why not:
1) You donβt know what steady state u (uss) is needed to maintain the desired stateβ’ This is the because the closed loop GDC may not be oneβ’ Its basically the same as the need for pre-reference scaling in
classical (3140) control2) The reference (or desired state) R is a vector and you
may not easily know what you want all the states to beβ’ For some systems this is easy (if I am trying to control pendulum to
10 degrees, then I know I want ππππππππ = 10 ππππππ & οΏ½ΜοΏ½πππππππ = 0 or R=[10 0]
β’ But think about the vehicle dynamic example. If you want the yaw rate to be 10 rad/sec, what should Ξ²des=? since R=[rdes Ξ²des]
12
Introducing a Referenceβ’ So you must solve for what the reference should be for the
other states and what the steady state input (uss) needs to be to hold that reference.
β’ Note that it is easy to solve for the steady state output in state space.
β’ Given the state space equations:
β’ Simply set to solve for the steady state x:
13
οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯ + π΅π΅π΅π΅π¦π¦ = πΆπΆπ₯π₯ + π·π·π΅π΅
0 = π΄π΄π₯π₯ππππ + π΅π΅π΅π΅πππππ₯π₯ππππ = βπ΄π΄β1π΅π΅π΅π΅ππππ
οΏ½ΜοΏ½π₯ = 0
π¦π¦ππππ = πΆπΆπ₯π₯ππππ + π·π·π΅π΅ππππ
Introducing a Referenceβ’ yss sets which output (i.e. which state within the state vector x
you are want as your desired state or desired reference d)β’ So given:
β’ So we now define the reference (the desired state) and steady state input to hold that reference as:
β’ These can now be placed into a coupled set of equations (written in matrix form):
β’ Note: I switch to using βdβ as the reference state since βrβ is yaw rate in vehicle dynamics. 14
0 = π΄π΄π₯π₯ππππ + π΅π΅π΅π΅ππππππ = π¦π¦ππππ = πΆπΆπ₯π₯ππππ + π·π·π΅π΅ππππ
π΄π΄ π΅π΅πΆπΆ π·π·
πππ₯π₯πππ’π’
= 01
π₯π₯ππππ = πππ₯π₯πππ΅π΅ππππ = πππ’π’ππ
Introducing a Reference
β’ We can then solve the previous coupled equations by:
β’ The reference is then utilized with the following equation:
β’ Or written another way:
β’ Substituting this input into the state space equations:
15
πππ₯π₯πππ’π’
= π΄π΄ π΅π΅πΆπΆ π·π·
β1 01
π΅π΅ = πππ’π’ππ β πΎπΎ(π₯π₯ β πππ₯π₯ππ)
π΅π΅ = βπΎπΎπ₯π₯ + πππ’π’ + πΎπΎπππ₯π₯ ππ
οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯ + π΅π΅π΅π΅οΏ½ΜοΏ½π₯ = π΄π΄π₯π₯ + π΅π΅{βπΎπΎπ₯π₯ + πππ’π’ + πΎπΎπππ₯π₯ ππ}οΏ½ΜοΏ½π₯ = (π΄π΄ β π΅π΅πΎπΎ)π₯π₯ + π΅π΅πππ’π’ + π΅π΅πΎπΎπππ₯π₯ ππ
Introducing a Reference
β’ So you must solve for what the reference should be for the other states and what the steady state input (uss) needs to be to hold that reference
β’ Note the homogeneous solution does not change. It is still governed by
οΏ½ΜοΏ½π₯ = (π΄π΄ β π΅π΅πΎπΎ)π₯π₯
β Therefore the eigenvalues have not changedβ’ However, the particular solution has now changed such that
π¦π¦ = πΆπΆπ₯π₯ππππ β ππβ’ Also note that:
16
οΏ½ΜοΏ½π₯ = (π΄π΄ β π΅π΅πΎπΎ)π₯π₯ + π΅π΅πππ’π’ + π΅π΅πΎπΎπππ₯π₯ ππ
π₯π₯ππππππ = π π = πππ₯π₯ππ
Adding Integral Control is SS
β’ To add integral control, simply augment the state space model by adding a new state that is the integral of the state:
β’ Note that the above new A matrix will have the same eigenvalues as the original A plus one additional eigenvalue at (you guessed it) the origin.
β’ The control input now becomes:
π΅π΅ = β πΎπΎ πΎπΎπΌπΌ
π₯π₯
οΏ½π₯π₯
17
οΏ½ΜοΏ½π₯π₯π₯ = π΄π΄ 0
1 0
π₯π₯
οΏ½π₯π₯ + π΅π΅0 π΅π΅
Augmenting the Yaw Dynamic StatesV = velocityr = yaw rate = οΏ½ΜοΏ½πΟ = heading (or yaw)Ξ½ = vehicle courseΞ΄ = steer angleΞ² = body sideslip angleΞ± = tire sideslip angle
VF
Ξ±F
VR
Ξ±R
Ξ΄
Vx
Vy
VrΞ²
N
E
Ο
Ξ½
18
οΏ½ΜοΏ½π¦ = πππ π ππππ ππ + π½π½= πππ₯π₯sin ππ + πππ¦π¦cos ππ
οΏ½ΜοΏ½π¦ β πππ₯π₯ππ + πππ¦π¦
β’ Lateral velocity is defined as:
β’ Assuming small angles:
οΏ½ΜοΏ½ππ¦π¦οΏ½ΜοΏ½π
=
βππ0ππππ
βππ1ππππ
β ππβππ1π π π§π§ππ
βππ2π π π§π§ππ
πππ¦π¦ππ +
πΆπΆπΌπΌππππ
πππΆπΆπΌπΌπππ π π§π§
πΏπΏ
Adding Heading ( )
οΏ½ΜοΏ½ππ¦π¦οΏ½ΜοΏ½ποΏ½ΜοΏ½π
=
βππ0ππππ
βππ1ππππ
β ππ 0βππ1π π π§π§ππ
βππ2π π π§π§ππ
0
0 1 0
πππ¦π¦ππππ
+
πΆπΆπΌπΌπππππππΆπΆπΌπΌπππ π π§π§0
πΏπΏ
β’ Now 3rd order, so 3 eigenvalues:β 2 from the bicycle model (unchanged) and 1 pure
integrator (same as with transfer functions)β’ The reference is now heading:
ππ = ππ = π¦π¦ππππ = 0 0 1πππ¦π¦ππππ
r=Ο
19
Adding Lateral Position ( )
οΏ½ΜοΏ½ππ¦π¦οΏ½ΜοΏ½ποΏ½ΜοΏ½ποΏ½ΜοΏ½π¦
=
βππ0ππππ
βππ1ππππ
β ππ 0 0βππ1π π π§π§ππ
βππ2π π π§π§ππ
0 0
0 1 0 01 0 πππ₯π₯ 0
πππ¦π¦πππππ¦π¦
+
πΆπΆπΌπΌππππ
πππΆπΆπΌπΌπππ π π§π§00
πΏπΏ
β’ Now 4th order, so 4 eigenvalues:β 2 from the bicycle model (unchanged) and 2 integrators
(one for heading and one for lateral position)β’ Note: You donβt have to treat the lateral velocity (Vy)
as a disturbance like you did with transfer functionsβ It can be included directly in the state space format!
20
οΏ½ΜοΏ½π¦ = πππ₯π₯ππ + πππ¦π¦
Adding Lateral Position ( )
οΏ½ΜοΏ½ππ¦π¦οΏ½ΜοΏ½ποΏ½ΜοΏ½ποΏ½ΜοΏ½π¦
=
βππ0ππππ
βππ1ππππ
β ππ 0 0βππ1π π π§π§ππ
βππ2π π π§π§ππ
0 0
0 1 0 01 0 πππ₯π₯ 0
πππ¦π¦πππππ¦π¦
+
πΆπΆπΌπΌππππ
πππΆπΆπΌπΌπππ π π§π§00
πΏπΏ
β’ The reference is now lateral position:
ππ = π¦π¦ = π¦π¦ππππ = 0 0 0 1
πππ¦π¦πππππ¦π¦
21
οΏ½ΜοΏ½π¦ = πππ₯π₯ππ + πππ¦π¦
Simple First Order Example
Given the model and control input:
Solving for the closed loop equation of motion:
Solving for the closed loop characteristic equation:
Solving for the control gain to place the closed loop eigenvalue at -10:
So the state space control becomes:
22
οΏ½ΜοΏ½π₯ = β1π₯π₯ + πΉπΉ
πΉπΉ = βπΎπΎπ₯π₯
det{π π + 1 + πΎπΎ } = 0
οΏ½ΜοΏ½π₯ = β(1 + πΎπΎ)π₯π₯
π π + 1 + πΎπΎ = 0
π π ππππππ = β10
πΎπΎ = 9
πΉπΉ = β9π₯π₯
Simple First Order Example
β’ In Matlab:>>A=-1;B=1;>>eig(A) >>K=place(A,B,-10)>>eig(A-BK)
23
πΎπΎ = 9
2nd Order (Pendulum) Example
Lets consider the linearized pendulum model:
Picking some values for the pendulum and then placing into state space
Then using the state space regulator of the form u=-Kx
Solving for the closed loop state space equations
24
π½π½οΏ½ΜοΏ½π + πποΏ½ΜοΏ½π + ππππππππ = ππ
οΏ½ΜοΏ½π + 1οΏ½ΜοΏ½π + 25ππ = ππ
οΏ½ΜοΏ½ποΏ½ΜοΏ½π
= β1 β251 0
οΏ½ΜοΏ½πππ
+ 10 ππ
ππ = βπΎπΎ οΏ½ΜοΏ½πππ
= β πΎπΎ1 πΎπΎ2 οΏ½ΜοΏ½πππ
οΏ½ΜοΏ½ποΏ½ΜοΏ½π
= β1 β251 0
οΏ½ΜοΏ½πππβ πΎπΎ1 πΎπΎ2 οΏ½ΜοΏ½π
ππ= β1 β πΎπΎ1 β25 β πΎπΎ2
1 0οΏ½ΜοΏ½πππ
2nd Order (Pendulum) Example
25
π π 2 + 1 + πΎπΎ1 π π + 25 + πΎπΎ2 = 0
det π π π π β β1 β πΎπΎ1 β25 β πΎπΎ21 0 = det π π + 1 + πΎπΎ1 25 + πΎπΎ2
β1 π π = 0
Solving for the closed loop characteristic equation:
Choosing a desired closed loop response of or
Results in the following desired characteristic equation
Then solving for the control gains:
or
ππππ = 14.14 ππππππ ππ = 0.707
π π 2 + 20π π + 200 = 0
π π = β10 Β± 10ππ
πΎπΎ = 19 175πΎπΎ1 = 19πΎπΎ2 = 175
Simple First Order Example
β’ In Matlab:>>A=[-1 -25;1 0];B=[1 ; 0];>>eig(A) >>K=place(A,B,[-10+10j,-10-10j])>>eig(A-BK)
26
πΎπΎ = 19 175
ππ = β 19 175 οΏ½ΜοΏ½πππ
= β19οΏ½ΜοΏ½π β 175ππ
2nd Order (Pendulum) Example
β’ Note that K1 is essentially Kd and K2 is essentially Kpβ Get the exact same values if you designed a
PD controller for the pendulum using classical (3140) methods
β However for the vehicle, itβs a little different, since the states are not yaw rate and yaw acceleration (K1 will be a lateral velocity gain and K2 will be a yaw rate gain)
β’ Although you can recast the bicycle model transfer function into a state space with the states of yaw rate and yaw acceleration.
27
State Space Control in Discrete
β’ State space control in discrete is incredibly convenient (and essentially the same as continuous)
β’ Discretize your state space model>>[Ad,Bd,Cd,Dd]=c2dm(A,B,C,D,dt,βzohβ);
β’ Convert your desired eigenvalues from continuous to discrete:
β’ The rest is the sameβ Solve for discrete control gain matrix to place the
eigenvalues of (AD-BDKD) at zdes
β Same command in Matlab>>Kd=place(Ad,Bd,Zdes)
28
π§π§ππππππ = ππππππππππβπ‘π‘
Discrete State Space Control
β’ Discrete State Space Model
β’ Inserting controller:
β’ Results in
β’ Closed-looped discrete characteristic equation
29
π₯π₯ππ+1 = π΄π΄π·π·π₯π₯ππ + π΅π΅π·π·π΅π΅ππ
π΅π΅ππ = βπΎπΎπ·π·π₯π₯ππ
π₯π₯ππ+1 = π΄π΄π·π·π₯π₯ππ + π΅π΅π·π·(βπΎπΎπ·π·π₯π₯)
π₯π₯ππ+1 = (π΄π΄π·π·βπ΅π΅π·π·πΎπΎπ·π·)π₯π₯ππ
det{π§π§π π β (π΄π΄π·π·βπ΅π΅π·π·πΎπΎπ·π·)}=0
Simple 1st order example in Discrete
β’ Lets look at the exact same first order as we did previously in continuous:
β’ First we will determine discrete state model using a sample rate of 0.01 seconds using Matlab which results in:
β’ Then we need to find the desired closed loop eigenvalue in discrete:
30
π§π§ππππππ = ππ(β10)(0.01) = 0.905
οΏ½ΜοΏ½π₯ = β1π₯π₯ + πΉπΉ
π π ππππππ = β10
π₯π₯ππ+1 = 0.99π₯π₯ππ + 0.01πΉπΉππ
Simple First Order Example
Given the discrete model and control input:
Solving for the closed loop equation of motion:
Solving for the closed loop characteristic equation:
Solving for the control gain to place the discrete closed loop eigenvalue at 0.9048:
So the state space control becomes:
31
det{π§π§ β 0.99 β 0.01πΎπΎπ·π· } = 0
π§π§ β 0.99 β 0.01πΎπΎπ·π· = 0
π₯π₯ππ+1 = 0.99π₯π₯ππ + 0.01πΉπΉππ
π₯π₯ππ+1 = (0.99 β 0.01πΎπΎπ·π·)π₯π₯ππ
π§π§ππππππ = 0.9048 = (0.99 β 0.01πΎπΎπ·π·)πΎπΎπ·π· = 8.62
πΉπΉππ = βπΎπΎπ·π·π₯π₯ππ
πΉπΉππ = β8.62π₯π₯ππ
Simple 1st order example in Discrete
β’ In Matlab>>sdes=-10; dt=0.01;>>A=-1;B=1;C=1;D=0;>>[Ad,Cd,Dd,Dd]=c2dm(A,B,C,D,dt,βzohβ);>>zdes=exp(sdes*dt)>>Kd=place(Ad,Bd,zdes)
(Note the value is different due to rounding)
(Control implementation)
(Discrete simulation)
32
π₯π₯ππ+1 = 0.99π₯π₯ππ + 0.01πΉπΉππ
πΎπΎπ·π· = 8.5639
πΉπΉππ = β8.5639π₯π₯ππ
Introducing a Reference in Discreteβ’ It is easy to solve for the steady state output in discrete state
space.β The steady state x (and y) will be the same in continuous and discrete
β’ Given the state space equations:
β’ Simply set to solve for the steady state x:
β’ Note that xss does not change from continuous to discrete!33
π₯π₯ππππ = (π π β π΄π΄π·π·)β1π΅π΅π΅π΅ππππ
π₯π₯ππ+1 = π₯π₯ππ
π¦π¦ππππ = πΆπΆπ·π·π₯π₯ππππ + π·π·π·π·π΅π΅ππππ
π₯π₯ππ+1 = π΄π΄π·π·π₯π₯ππ + π΅π΅π·π·π΅π΅πππ¦π¦ππ = πΆπΆπ·π·π₯π₯ππ + π·π·π·π·π΅π΅ππ
π₯π₯ππ = π΄π΄π·π·π₯π₯ππ + π΅π΅π·π·π΅π΅ππ
Introducing a Reference in Discrete
β’ Since the steady state x (and y and u) are exactly the same in discrete (as continuous), the discrete reference is exactly the same as continuous. In fact you can simply solve for Nxand Nu from the continuous domain:
β’ The reference is then utilized in discrete with the following equation:
β’ Or written another way:
β’ And (just as in continuous), the reference does not change the closed loop eigenvalue.
34
πππ₯π₯πππ’π’
= π π β π΄π΄π·π· π΅π΅π·π·πΆπΆπ·π· π·π·π·π·
β1 01 = π΄π΄ π΅π΅
πΆπΆ π·π·β1 0
1
π΅π΅ππ = πππ’π’ππ β πΎπΎπ·π·(π₯π₯ππ β πππ₯π₯ππ)
π΅π΅ = βπΎπΎπ·π·π₯π₯ππ + πππ’π’ + πΎπΎπ·π·πππ₯π₯ ππ