Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

LQR Feedforward

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20
At a glance
Powered by AI
The key takeaways are about optimal linear quadratic (LQ) control and linear quadratic regulators (LQR) for minimizing a quadratic performance index and the use of pole placement for decoupling control with state feedback.

Optimal LQ control minimizes a quadratic performance index to find the optimal control input by solving the Hamiltonian function and differential Riccati equation for time-varying systems or the algebraic Riccati equation for time-invariant systems.

An LQR is a type of optimal control that minimizes a quadratic performance index for a linear system with no terminal constraints by solving the algebraic Riccati equation to find the state feedback gain.

Model-Based Controller Design

Optimal linear quadratic (LQ) control


Given the LTI plant model, with directly measurable state :
() = () + ()
;
() = () + ()

, ,

Find the control to minimize the performance index (cost):


1

= 2 + 2

where = > 0, = 0, = 0 are weight matrices

The optimal LQR control is found by minimizing the Hamiltonian function:


1

= + + () () + ()
2
where () is the Lagrangian multiplier

=0
+ = 0
= 1

= () + = () = +
So, let

= +
+ =
= ()

For LTI systems

= ()

Optimal LQ control:

() = ()()

r=0

u
-

where () = 1 ()
and () is the solution of the differential Riccati equation (DRE):
= () + () + ()1 () ,
=

Plant

Optimal Linear Quadratic (LQ) Control


Linear quadratic regulator (LQR)
Given the plant model:

() = () + ()
;
() = () + ()

, ,

Minimize the performance index (cost), for = (steady-state case):


1

2 0
> 0, =

=
where =

+
0 are weight matrices

For = , = (constant)
LQR control:

r=0

() = ()

u
-

K
where = 1
and is the solution of the algebraic Riccati equation (ARE):
+ + 1 = 0

Closed-loop system equation ( = 0):


= +
= +

Or, equivalently, the quadruple , , ,

Plant

Optimal Linear Quadratic (LQ) Control


Linear quadratic regulator (LQR)
Given the plant model:

() = () + ()
;
() = () + ()

, ,

Let = +

LQR state feedback control gain:

u
+

and is the solution of the algebraic Riccati equation (ARE):


+ + 1 = 0

Choose N so that the closed-loop DC-gain is equal to one.


Closed-loop system equation:
1

Or, the quadruple , , ,


dc-Gain: 0 = 1 + = 1

Feedforward control gain:

= +
= +
Or, equivalently, =

Plant

Linear quadratic regulator (LQR)


Matlab functions: are(),

lqr(), care(), dcgain(), r=0

For example: P= are(A,B*inv(R)*B,Q);

Example:

0
0
= 0 , = 1
0
30

Plant

[K,P]=lqr(A,B,Q,R);
[P,L,K]=care(A,B,Q,R,S,E);
0.2
0
() = () + ()
Let
, with = 0
() = () + ()
0
0

0.5
0.5
0
0
0

0
1.6
14.3
0
0

0
0
85.8
33.3
0

0
0
0 ,
100
10

0 , =0.

Find the LQR control () = () and plot the closed-loop step response
for = 1, = , 0,0,0,0 , and = 1,5,10,50,100.
Also, for =100, plot the closed-loop states

Linear quadratic regulator (LQR)


Matlab code:
A=[-0.2,0.5,0,0,0; 0,-0.5,1.6,0,0;
0,0,-14.3,85.8,0; 0,0,0,-33.3,100;
0,0,0,0,-10]; B=[0;0;0;0;30];
C=[1,0,0,0,0]; D=0; rho=1;
R=1; Q=diag([rho,0,0,0,0]);
for rho=[1,5,10,50,100],
Q(1,1)=rho; [K,P] =lqr(A,B,Q,R),
step(ss(A-B*K,B,C,D)); hold on;
end, hold off;

Or, instead of lqr(), use:

0.0326
0.0044
0.0004
0.0009
0.0056

Optimal solution:
P=
0.3563
0.0326
0.0026
0.0056
0.0309

Plant

0.0026
0.0004
0.0000
0.0001
0.0005

0.0056
0.0009
0.0001
0.0002
0.0012

0.0309
0.0056
0.0005
0.0012
0.0088

K=
0.9260 0.1678 0.0157 0.0371 0.2653

= +
Closed-loop Step Response

P=are(A,B*inv(R)*B',Q),
K=inv(R)*B'*P,

Step Response
1.4

States x2, , x5

=1

1.2

Closed-loop states

Amplitude

Q(1,1)=100; [K,P] =lqr(A,B,Q,R); Ac=A-B*K;


[y,t,x]=step(ss(Ac,B,C,D)); plot(t,x(:,2:5)); grid;

=5

0.6
0.4

-2

0.2

-4

0.8

-6

0
0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

0.5

1
Time (sec)

1.5

LQR for Discrete-Time Systems


Discrete-time LQ control
Given the plant model:

( + 1) = () + ()
;
() = () + ()

, ,

Minimize the performance index (cost):


1

=
+
=0
2

where = > 0, = 0 are weight matrices

Discrete LQ control:

() = ()

where = 1 ()
and () is the solution of the dynamic/difference Riccati equation (DRE):
= + 1 + 1 1 + 1 + , =

For steady-state case ( = )


P is a constant matrix

Discrete LQR

() = ()

where = + 1
and = 1 +

Matlab functions:
dlqr(), dare(),

Selection of Weighting Matrices


Single-input, single-output (SISO) case:
LQR control (a possible choice for weight matrices)
= 1, = (1 , , ), where is the maximum expected value
of state ()

Cheap control (control effort is inexpensive)


= 1, = 0 , where 0 = 0 0 and > 0 is a large number

Expensive control (control effort is expensive)

= 1, = 0 , where 0 = 0 0 and > 0 is a small number

Terminal control (terminal state must tend to zero)


= 0, = 0 , where 0 = 0 0 and tends to infinity
Here, the DRE changes to:

= () + () () 1 () ,

= 0

Equivalently, let = 1 ()
() = () + () 1 ,

= 0

LQR with Degree of Stability


Plant model:
Degree of stability

() = () + ()
() = () + ()

All closed-loop poles are to the left of


Define a new performance index (cost)
1

=2

where = > 0, = 0 are weight matrices


Define a new state variable and control

() = ()
() = ()

New state equation and performance index (cost)


() = + () + ()
1
= 2 +
0

LQR with degree of stability


() = ()

Matlab code:
P=are((A_a*eye(size(A))),B*inv(R)*B,Q);
k=inv(R)*B*P;
u=-k*x;
or use lqr() with A replaced with (A+I)

where = 1
and the modified ARE is: ( + ) + + + 1 = 0

Observer Design
LQR assumptions:
1. Plant model is perfectly known:

() = () + ()
() = () + ()

2. All states are directly measurable


If assumption 1 is not true (the model has uncertainties), use robust control
If assumption 2 is not true (only the output is measurable), use an observer
System must be observable

Observer (state estimator) design:

Create a copy of the plant model with corrective term

= + + ( )
= +
Choose the observer gain so that all eigenvalues of are in LHP
Plant
u

Observer
= + +

() = () + ()
() = () + ()

Observer-Based Controller Design


For plant model, (assuming that the state vector is not measured):
= +
= +

An observer-based controller has the form:


= + + ( )
= +

The observer can be written as:

= + +

Plant

Observer

Or, by superposition:

= +
= +
= +

- - uu G (s)
u
u

Observer-based controller, ( = + ):

= +
()
=

= +
=
=

() = + ()

Guc(s)

G(s)

Gy(s)

u
Gy(s)

G(s)

Observer-Based Controller Design


Matlab function: reg(),
Syntax:

[Ac,Bc,Cc,Dc]=reg(A,B,C,D,K,Ko);
Or:
Gc=-reg(G,K,Ko)

Example:
= 1 0

Let

() = () + ()
, with
() = () + ()

0 0 0 , =0.

0
0
0
0.2 0.5
0
1.6
0
0
0
0.5
0
0
14.3 85.8
0 , = 0 ,
= 0
0
0
0
0
33.3 100
30
0
0
0
0
10

Find the observer-based LQR control = + for = 1, = 1,0,0,0,0 , using


an observer gain = 8.3 979.24 19367.61 4293.85 0 , and then plot the closedr
e
u
y
loop step response.
A=[-0.2,0.5,0,0,0; 0,-0.5,1.6,0,0;
0,0,-14.3,85.8,0; 0,0,0,-33.3,100;
0,0,0,0,-10]; B=[0;0;0;0;30];
C=[1,0,0,0,0]; D=0; R=1; Q=diag([1,0,0,0,0]);
G=ss(A,B,C,D); [K,P] =lqr(A,B,Q,R);
Ko=[-8.3,979.24,-19367.61,4293.85,0]';
Gc=-reg(G,K,Ko); zpk(Gc),
Gcl1=ss(A-B*K,B,C,D); Gcl2=feedback(Gc*G,1,-1);
step(Gcl1,Gcl2);
11.4839 (s+33.34) (s+14.3) (s+10) (s+1.792)
() = (s+20.92) (s^2 + 30.19s + 328.1) (s^2 + 6.845s + 120)

G(s)

Step Response
From: In(1) To: u1
1.6

Observer-based
LQR

1.4
1.2
Amplitude

Matlab code:

Gc(s)

1
0.8

Full-state feedback
LQR

0.6
0.4
0.2
0

0.5

1.5
Time (sec)

2.5

Pole Placement Design Technique


= +

Given the system = + with a state feedback control = +


If , is controllable and is directly measurable, the closed-loop poles
(eigenvalues of ) can be arbitrarily assigned
Imaginary poles, however, must come in conjugate pairs

The systems open-loop characteristic equation is:


= = + 1 1 + + 1 +

The systems closed-loop characteristic equation is:


= + = + 1 1 + + 1 + ()

Let the desired closed-loop poles be:

, = 1, ,

The desired closed-loop characteristic equation can be written as :


=

=1

Feedback gain =

= + 1 1 + + 1 +

can be found, by equating

1 = 1

= 1
1 = 1
=

= ?

and , as

Pole Placement Control Algorithms


Bass-Gura algorithm

= 1 1

where

= 1 1

, =

is the non-singular Hankel matrix

1 2
2 3
1 , and =


1 1
1

1
1

Ackermanns algorithm
Can be applied only to SISO systems
= 0

where = 1

0 1 1
, =

Numerically robust pole-placement algorithm (place)


Can be applied to MIMO systems
Desired poles must all be distinct

Matlab functions: bass_pp(), acker(), place(),


K=bass_pp(A,B,pdes)
K=acker(A,B,pdes)
K=place(A,B,pdes)
where pdes = desired closed-loop poles

Matlab function for Bass-Gura algorithm


function K=bass_pp(A,B,p)
n=length(B); a1=poly(p);
alpha=[a1(n:-1:2),1]; C=ctrb(A,B);
a=poly(A); aa=[a(n:-1:2),1]; L=hankel(aa);
K=(a1(n+1:-1:2)-a(n+1:-1:2))*inv(L)*inv(C);

Pole Placement Control Design


Example: Consider the multivariable system model
0
1
= 0
0
2
0

2
0
1
0
0
0

0
0
0
0
0
1

0 2
0
0
0
0
3
0
1
0
0
1

= +
with
= +

0
1
2
1
0
0
0 , = 0
1 , =
1 0 0 0
0
0 1
0
0
1
0
0
0

0 0 , =0

Design a state feedback control = + so the closed-loop poles are at:


= 1, 2, 3, 4, 1j. Also draw the closed-loop step response.

Matlab code:

Control gains:

8.0037 26.0056 26.1122 16.3759 23.2324 28.7704


0.1759 3.0018
3.1317 7.7366 2.0396
2.6613
10.9884
0
=
0
13.6388
=

Step Response
From: In(1)

From: In(2)

3.5
3
2.5
2
Amplitude

A=[0,2,0,0,-2,0; 1,0,0,0,0,-1; 0,1,0,0,0,0; 0,0,0,3,0,0; 2,0,0,1,0,0; 0,0,-1,0,1,0];


B=[1,2; 0,0; 0,1; 0,-1; 0,1; 0,0]; C=[1,0,0,0,0,0]; D=0;
pdes=[-1,-2,-3,-4,-1+i,-1-i];
K=place(A,B,pdes), N=inv(diag(dcgain(ss((A-B*K),B,C,D)))),
eig(A-B*K), sys_cl=ss((A-B*K),B*N,C,D); dcgain(sys_cl);
step(sys_cl);

Response to u1

Response to u2

1.5
1
0.5
0
-0.5
-1

6
0
Time (sec)

Pole Placement Control Design Technique


Observer design using pole placement technique
Dual of control design problem
Matlab functions: place(), acker(),

Example: Given the plant


= 1 2 3

0
= +
with
= 0
= +
0
0

1 0 0
0
0 1 0 , = 1 ,
0 0 1
0
0 11 0
1

4 , =0

Design an observer with poles at: 1,2,3,4 = 1, 2, 1

Matlab code:
A=[0,1,0,0; 0,0,-1,0; 0,0,0,1; 0,0,11,0];
B=[0; 1; 0; -1]; C=[1,2,3,4]; D=0;
pdes=[-1, -2, -1+i, -1-i];
Ko=place(A',C',pdes)', eig(A-Ko*C),

Observer gain:
0.2203
= 0.4750
0.4238
1.2247

Pole Placement Control Design Technique


Observer-based controller design using pole placement
= +
r
= +
= + + ( )
= +

Plant:
Controller:
Equivalently:

()

+
()

0
()
+
= =
()

u
uy

G(s)

Gc(s)

Closed-loop system:

=
+

DC-gain = (0) = 1

Observer

ur

Grc(s)

Plant

Pole Placement Control Design Technique


Observer-based controller design using pole placement
0.3 0.1
= +
Example: Given the plant = + with = 1
0.1
1.5 8.9

2
0.05
0 , = 0 ,
4
0.05

= 1 2 3 , =0

Design an observer-based controller = + so the closed-loop poles are


at: 1,2,3 = 1, 2, 3 and the observer poles are at 1,2,3 = 10, 20, 30
Controller gains:
= 3.6496 5.7189 0.3873 ,

A=[-0.3,0.1,-0.05; 1,0.1,0; -1.5,-8.9,-0.05];


225.8203

=
17.9695 ,

B=[2; 0; 4]; C=[1,2,3]; D=0;


107.1698
pcdes=[-1, -2, -3]; podes=[-10, -20, -30];
= 0.1106
K=place(A,B,pcdes), Ko=place(A',C',podes)',
N=inv(dcgain(ss([A,-B*K;Ko*C,A-B*K-Ko*C],[B;B],[C,-D*K],D))),
Gcl=ss([A,-B*K;Ko*C,A-B*K-Ko*C],[B;B]*N,[C,-D*K],D*N);
Step(Gcl);

Step Response
1.2
1
0.8
Amplitude

Matlab code:

0.6
0.4
0.2
0
-0.2

4
Time (sec)

Decoupling Control of Multivariable Systems


Decoupling control with state feedback
Plant (A,B,C,D) with m inputs and m outputs
State feedback control: =

Decoupled Model G1(s)


v
u
y
Gc(s)
N
G(s)

For each row of , let 0,1, , 1 be the smallest integer where 0

Decoupler gains:

1 1 +1
1 1
= 1 1 , =
, (if 1 =
is nonsingular)


+1

Decoupled model:
1 =

, , +1
1 +1

Now, design a controller for each 1 :


= 1 , ,

Matlab function: decoupler(),


Syntax: [G1,K,d,N]=decoupler(G)
where G and G1 are the plant and decoupled models,
K and N are the feedback and feedforward gains,
d is the vector of djs

Matlab code for decoupler function:


function [G1,K,d,Gam]=decoupler(G)
A=G.a; B=G.b; C=G.c; [n,m]=size(G.b); B1=[]; K0=[];
for j=1:m,
for k=0:n-1,
if norm(C(j,:)*A^k*B)>eps, d(j)=k; break; end,
end,
B1=[B1; C(j,:)*A^d(j)*B]; K0=[K0; C(j,:)*A^(d(j)+1)];
end,
Gam=inv(B1); K=Gam*K0;
G1=minreal(tf(ss(A-B*K,B,C,G.d))*inv(B1));

Decoupling Control of Multivariable Systems


Pole placement decoupling control with state feedback
State feedback control: =

Define:

1 1 +1 + 1,1 1 + + 1,1 +1
1 1
=
and =

+1

+ ,1 + + , +1

Decoupled System
r
u
y
N
G(s)

Pole placement: Assign control gains so that the transfer function of the jth subsystem is equal to
the nj-th-order optimal ITAE standard TF: =
n

Denominator of with =

Mp nts

2 + 1.41 + 2

2 4.6% 6.0
2%

3 + 1.75 2 + 2.152 + 3

7.6

4 1.9% 5.4

4 + 2.1 3 + 2.42 2 + 2.73 + 4

5 2.1% 6.6

5 + 2.8 4 + 5.02 3 + 5.53 2 + 2.44 + 5

5%

7.8 6 + 2.25 5 + 6.62 4 + 8.63 3 + 7.454 2 + 2.955 + 6

Decoupled transfer function:

Control gains:

1 =

, = +1 , with parameters:

Matlab code for std_tf function:

1
3

1
+1 ++ 1 +

function G=std_tf(wn,n)
if n>6, disp('n must be less than 7'); end
M=[1,1,0,0,0,0,0; 1,1.4,1,0,0,0,0;
1,1.75,2.15,1,0,0,0; 1,2.1,3.4,2.7,1,0,0;
1,2.8,5,5.5,3.4,1,0; 1,3.25,6.6,8.6,7.45,3.95,1];
G=tf(wn^n,M(n,1:n+1).*(wn*ones(1,n+1)).^[0:n]);
1,1 +1

1 +1 +1,1 1 ++1,1 +1

,,

, +1

+1 +,1 ++,+1

= 1 , = 1 , with = (1,1+1, , +,+1 ), (if is nonsingular)

Pole Placement Control Design Technique


Pole placement decoupling control with state feedback
Matlab functions: std_tf(), decouple_pp(), Matlab code for decouple_pp function:
Syntax: G=std_tf(wn,n);
[G1,K,d,N]=decouple_pp(G,wn)

Example: For plant


2.25
5
1.25
1.25
2.25
4.25
=
0.25 0.5 1.25
1.25 1.75 0.25
0 0
=
0 0

= +
with
= +

0.5
4
0.25 , = 2
2
1
0
0.75

6
4 , = 0
2
0
2

0
2

0 1
,
0 2

function [G1,K,d,N]=decouple_pp(G,wn)
A=G.a; B=G.b; C=G.c; [n,m]=size(G.b); E=[]; F=[];
for j=1:m,
for i=0:n-1,
if norm(C(j,:)*A^i*B)>eps, d(j)=i; break; end,
end,
g1=std_tf(wn,d(j)+1); [~,cc]=tfdata(g1,'v');
F=[F; C(j,:)*polyvalm(cc,A)]; E=[E; C(j,:)*A^d(j)*B];
end,
Gam=inv(E); K=Gam*F; G0=tf(ss(A-B*K,B,C,G.d));
N=Gam*inv(dcgain(G0*Gam)); G1=minreal(G0*N);

Design an observer-based controller


Controller gains:
0.125 2.125 0.375 4.375
= + so the closed-loop poles are
=
,
0.625
0.875
0.125
2.125
defined by the optimal ITAE standard transfer
7.5 1.25
Step Response
=
function with = 5 rad/sec
2.5
0
From: In(1)

From: In(2)

1 =

+5

0
5
+5

Amplitude

A=[2.25,-5,-1.25,-0.5; 2.25,-4.25,-1.25,-0.25;
0.25,-0.5,-1.25,-1; 1.25,-1.75,-0.25,-0.75];
B=[4,6; 2,4; 2,2; 0,2]; C=[0,0,0,1; 0,2,0,2]; D=[0,0; 0,0];
G=ss(A,B,C,D); [G1,K,d,N]=decouple_pp(G,5),
step(G1);

Decoupled TF:

0.5
0
-0.5
-1
1

To: Out(2)

Matlab code:

To: Out(1)

0.5

3 0
Time (sec)

You might also like