MECH 4420 Lecture: State Space Control

34
MECH 4420 Lecture: State Space Control David Bevly 1

Transcript of MECH 4420 Lecture: State Space Control

Page 1: MECH 4420 Lecture: State Space Control

MECH 4420 Lecture:State Space Control

David Bevly

1

Page 2: MECH 4420 Lecture: State Space Control

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

Page 3: MECH 4420 Lecture: State Space Control

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

οΏ½Μ‡οΏ½π‘₯ = 𝐴𝐴π‘₯π‘₯ + 𝐡𝐡𝐡𝐡𝑦𝑦 = 𝐢𝐢π‘₯π‘₯ + 𝐷𝐷𝐡𝐡

Page 4: MECH 4420 Lecture: State Space Control

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

οΏ½Μ‡οΏ½π‘₯ = 𝐴𝐴π‘₯π‘₯ + 𝐡𝐡𝐡𝐡

Page 5: MECH 4420 Lecture: State Space Control

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

οΏ½Μ‡οΏ½π‘₯ = 𝐴𝐴π‘₯π‘₯ + 𝐡𝐡𝐡𝐡

𝐡𝐡 = βˆ’πΎπΎπ‘₯π‘₯

οΏ½Μ‡οΏ½π‘₯ = 𝐴𝐴π‘₯π‘₯ + 𝐡𝐡 βˆ’πΎπΎπ‘₯π‘₯

οΏ½Μ‡οΏ½π‘₯ = 𝐴𝐴 βˆ’ 𝐡𝐡𝐾𝐾 π‘₯π‘₯ = 𝐴𝐴𝐢𝐢𝐢𝐢π‘₯π‘₯

𝐴𝐴𝐢𝐢𝐢𝐢 = 𝐴𝐴 βˆ’ 𝐡𝐡𝐾𝐾

𝐡𝐡 = 𝐾𝐾 𝑅𝑅 βˆ’ π‘₯π‘₯ = βˆ’πΎπΎπ‘₯π‘₯

Page 6: MECH 4420 Lecture: State Space Control

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

οΏ½Μ‡οΏ½π‘₯ = (𝐴𝐴 βˆ’ 𝐡𝐡𝐾𝐾)π‘₯π‘₯οΏ½Μ‡οΏ½π‘₯ = (𝐴𝐴𝐢𝐢𝐢𝐢)π‘₯π‘₯

Page 7: MECH 4420 Lecture: State Space Control

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

Page 8: MECH 4420 Lecture: State Space Control

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

Page 9: MECH 4420 Lecture: State Space Control

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

Page 10: MECH 4420 Lecture: State Space Control

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

Page 11: MECH 4420 Lecture: State Space Control

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

Page 12: MECH 4420 Lecture: State Space Control

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

Page 13: MECH 4420 Lecture: State Space Control

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

𝑦𝑦𝑑𝑑𝑑𝑑 = 𝐢𝐢π‘₯π‘₯𝑑𝑑𝑑𝑑 + 𝐷𝐷𝐡𝐡𝑑𝑑𝑑𝑑

Page 14: MECH 4420 Lecture: State Space Control

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

π‘₯π‘₯𝑑𝑑𝑑𝑑 = 𝑁𝑁π‘₯π‘₯𝑑𝑑𝐡𝐡𝑑𝑑𝑑𝑑 = 𝑁𝑁𝑒𝑒𝑑𝑑

Page 15: MECH 4420 Lecture: State Space Control

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

𝐡𝐡 = 𝑁𝑁𝑒𝑒𝑑𝑑 βˆ’ 𝐾𝐾(π‘₯π‘₯ βˆ’ 𝑁𝑁π‘₯π‘₯𝑑𝑑)

𝐡𝐡 = βˆ’πΎπΎπ‘₯π‘₯ + 𝑁𝑁𝑒𝑒 + 𝐾𝐾𝑁𝑁π‘₯π‘₯ 𝑑𝑑

οΏ½Μ‡οΏ½π‘₯ = 𝐴𝐴π‘₯π‘₯ + 𝐡𝐡𝐡𝐡�̇�π‘₯ = 𝐴𝐴π‘₯π‘₯ + 𝐡𝐡{βˆ’πΎπΎπ‘₯π‘₯ + 𝑁𝑁𝑒𝑒 + 𝐾𝐾𝑁𝑁π‘₯π‘₯ 𝑑𝑑}οΏ½Μ‡οΏ½π‘₯ = (𝐴𝐴 βˆ’ 𝐡𝐡𝐾𝐾)π‘₯π‘₯ + 𝐡𝐡𝑁𝑁𝑒𝑒 + 𝐡𝐡𝐾𝐾𝑁𝑁π‘₯π‘₯ 𝑑𝑑

Page 16: MECH 4420 Lecture: State Space Control

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

οΏ½Μ‡οΏ½π‘₯ = (𝐴𝐴 βˆ’ 𝐡𝐡𝐾𝐾)π‘₯π‘₯ + 𝐡𝐡𝑁𝑁𝑒𝑒 + 𝐡𝐡𝐾𝐾𝑁𝑁π‘₯π‘₯ 𝑑𝑑

π‘₯π‘₯𝑑𝑑𝑑𝑑𝑑𝑑 = 𝑅𝑅 = 𝑁𝑁π‘₯π‘₯𝑑𝑑

Page 17: MECH 4420 Lecture: State Space Control

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 𝐡𝐡

Page 18: MECH 4420 Lecture: State Space Control

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𝑠𝑠𝑧𝑧𝑉𝑉

𝑉𝑉𝑦𝑦𝑑𝑑 +

πΆπΆπ›Όπ›Όπ‘“π‘“π‘šπ‘š

π‘Žπ‘ŽπΆπΆπ›Όπ›Όπ‘“π‘“π‘ π‘ π‘§π‘§

𝛿𝛿

Page 19: MECH 4420 Lecture: State Space Control

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

Page 20: MECH 4420 Lecture: State Space Control

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

�̇�𝑦 = 𝑉𝑉π‘₯π‘₯πœ“πœ“ + 𝑉𝑉𝑦𝑦

Page 21: MECH 4420 Lecture: State Space Control

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

�̇�𝑦 = 𝑉𝑉π‘₯π‘₯πœ“πœ“ + 𝑉𝑉𝑦𝑦

Page 22: MECH 4420 Lecture: State Space Control

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π‘₯π‘₯

Page 23: MECH 4420 Lecture: State Space Control

Simple First Order Example

β€’ In Matlab:>>A=-1;B=1;>>eig(A) >>K=place(A,B,-10)>>eig(A-BK)

23

𝐾𝐾 = 9

Page 24: MECH 4420 Lecture: State Space Control

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οΏ½Μ‡οΏ½πœƒπœƒπœƒ

Page 25: MECH 4420 Lecture: State Space Control

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

Page 26: MECH 4420 Lecture: State Space Control

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πœƒπœƒ

Page 27: MECH 4420 Lecture: State Space Control

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

Page 28: MECH 4420 Lecture: State Space Control

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

𝑧𝑧𝑑𝑑𝑑𝑑𝑑𝑑 = π‘’π‘’π‘‘π‘‘π‘‘π‘‘π‘‘π‘‘π‘‘π‘‘βˆ†π‘‘π‘‘

Page 29: MECH 4420 Lecture: State Space Control

Discrete State Space Control

β€’ Discrete State Space Model

β€’ Inserting controller:

β€’ Results in

β€’ Closed-looped discrete characteristic equation

29

π‘₯π‘₯π‘˜π‘˜+1 = 𝐴𝐴𝐷𝐷π‘₯π‘₯π‘˜π‘˜ + π΅π΅π·π·π΅π΅π‘˜π‘˜

π΅π΅π‘˜π‘˜ = βˆ’πΎπΎπ·π·π‘₯π‘₯π‘˜π‘˜

π‘₯π‘₯π‘˜π‘˜+1 = 𝐴𝐴𝐷𝐷π‘₯π‘₯π‘˜π‘˜ + 𝐡𝐡𝐷𝐷(βˆ’πΎπΎπ·π·π‘₯π‘₯)

π‘₯π‘₯π‘˜π‘˜+1 = (π΄π΄π·π·βˆ’π΅π΅π·π·πΎπΎπ·π·)π‘₯π‘₯π‘˜π‘˜

det{𝑧𝑧𝑠𝑠 βˆ’ (π΄π΄π·π·βˆ’π΅π΅π·π·πΎπΎπ·π·)}=0

Page 30: MECH 4420 Lecture: State Space Control

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πΉπΉπ‘˜π‘˜

Page 31: MECH 4420 Lecture: State Space Control

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π‘₯π‘₯π‘˜π‘˜

Page 32: MECH 4420 Lecture: State Space Control

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π‘₯π‘₯π‘˜π‘˜

Page 33: MECH 4420 Lecture: State Space Control

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 = 𝐴𝐴𝐷𝐷π‘₯π‘₯π‘˜π‘˜ + π΅π΅π·π·π΅π΅π‘˜π‘˜π‘¦π‘¦π‘˜π‘˜ = 𝐢𝐢𝐷𝐷π‘₯π‘₯π‘˜π‘˜ + π·π·π·π·π΅π΅π‘˜π‘˜

π‘₯π‘₯π‘˜π‘˜ = 𝐴𝐴𝐷𝐷π‘₯π‘₯π‘˜π‘˜ + π΅π΅π·π·π΅π΅π‘˜π‘˜

Page 34: MECH 4420 Lecture: State Space Control

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

π΅π΅π‘˜π‘˜ = 𝑁𝑁𝑒𝑒𝑑𝑑 βˆ’ 𝐾𝐾𝐷𝐷(π‘₯π‘₯π‘˜π‘˜ βˆ’ 𝑁𝑁π‘₯π‘₯𝑑𝑑)

𝐡𝐡 = βˆ’πΎπΎπ·π·π‘₯π‘₯π‘˜π‘˜ + 𝑁𝑁𝑒𝑒 + 𝐾𝐾𝐷𝐷𝑁𝑁π‘₯π‘₯ 𝑑𝑑