mech 4420 lecture: state space control
TRANSCRIPT
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
ðµðµðð = ððð¢ð¢ðð â ðŸðŸð·ð·(ð¥ð¥ðð â ððð¥ð¥ðð)
ðµðµ = âðŸðŸð·ð·ð¥ð¥ðð + ððð¢ð¢ + ðŸðŸð·ð·ððð¥ð¥ ðð