Sei sulla pagina 1di 9

Quadratic Optimal Regulator Homework Problem

Aiman H.

In this homework, Ill try to demonstrate the use of the quadratic optimal regulator design technique on
the performance of the inverted-pendulum problem that weve already addressed using other design
techniques.

The system is shown in the figure below:

Figure(1)

where M=2kg, m=0.1kg, and l=0.5m. The system equations are given by:

Accordingly, we have the following:

Using the above details, Ill use MATLAB to find the state feedback gain matrix K in conjunction with the
new Quadratic Optimal Regulator technique. In MaTLAB, the following command is used to solve the
Raccati equation and to determine the state feedback control matrix K:

K=lqr(A,B,Q,R)

1
Quadratic Optimal Regulator Homework Problem
Aiman H.

Where A & B are the plant and input matrixes for the given system. Q & R are the weighting functions
for both the system states and input respectively. Hence, we can see that both have a major effect on
the system performance.

A major part of tackling this problem, is finding the Q and R matrices values that will allow us to get the
required response. In our case here, the Q matrix is related with the following state variables:

For the design requirements, it is desired to keep the pendulum to be straight as much as possible, with
the appropriate position and speed. Based on that, our selection of the Q matrix values should be
reflected on our desire to achieve the design criteria.

Since there no clear method as to how we could choose our Q matrix values, it is usually a good practice
to set the matrix to identity matrix and measure out the system response, then, Ill try to tweak the
matrix to suit my requirements, this approach is a Trail-Error approach.

The following program illustrate the first trail:


% Homework- Inverted pendulum using QOR-Case1-Unitiy Q
clc
A=[0 1 0 0;20.601 0 0 0;0 0 0 1;-0.4905 0 0 0];
B=[0;-1;0;0.5];
C=[0 0 1 0];
D=[0];

Ahat=[A zeros(4,1);-C 0];


Bhat=[B;0];
Q=[1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1]
R=[0.01];

[K,P,E]=lqr(Ahat,Bhat,Q,R);
K1=-K(1,5);
KK=[K(1,1) K(1,2) K(1,3) K(1,4)];
AA=[A-B*KK B*K1;-C 0];
BB=[zeros(4,1);1];
CC=[C 0];
DD=[0];
t=[0:0.1:20];
[y,x,t]=step(AA,BB,CC,DD,1,t);

K =

-132.5272 -31.2543 -24.1882 -24.2534 10.0000

2
Quadratic Optimal Regulator Homework Problem
Aiman H.

P =

22.4743 4.3842 6.8894 6.1178 -3.1254


4.3842 0.9500 1.4624 1.2750 -0.6705
6.8894 1.4624 4.7255 2.4411 -2.4253
6.1178 1.2750 2.4411 2.0649 -1.1409
-3.1254 -0.6705 -2.4253 -1.1409 2.4188

Figure(2)

From that, we can see the response to be as shown in the following figure:

Figure(3)

3
Quadratic Optimal Regulator Homework Problem
Aiman H.

Figure(4)

Figure(5)

4
Quadratic Optimal Regulator Homework Problem
Aiman H.

Figure(6)

Theres a good rule of thumb, that could help us to visualize the effect of the Q matrix on the system
variables. The rule is called Brysons Rule, and it states the following:

The Xi-max and Ui-max represent the largest desired response


or control input for that component of the state/actuator
signal.

Using that rule, Ill try to minimize the pendulum tilt angle and the angular speed by a factor of 10
degrees for the first one and 10 rad/sec for the second one, as shown below:
% Homework- Inverted pendulum using QOR-Case3-Modified Q-Less theta and
% angular speed
clc
A=[0 1 0 0;20.601 0 0 0;0 0 0 1;-0.4905 0 0 0];
B=[0;-1;0;0.5];
C=[0 0 1 0];

5
Quadratic Optimal Regulator Homework Problem
Aiman H.

D=[0];

Ahat=[A zeros(4,1);-C 0];


Bhat=[B;0];
Q=[100 0 0 0 0
0 100 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1]
R=[0.01];

[K,P,E]=lqr(Ahat,Bhat,Q,R);
K1=-K(1,5);
KK=[K(1,1) K(1,2) K(1,3) K(1,4)];
AA=[A-B*KK B*K1;-C 0];
BB=[zeros(4,1);1];
CC=[C 0];
DD=[0];
t=[0:0.1:20];
[y,x,t]=step(AA,BB,CC,DD,1,t);

I got the following results:

Figure(7)

6
Quadratic Optimal Regulator Homework Problem
Aiman H.

Figure(8)

Figure(9)

By comparing the plots. We can clearly see that the modified Q matrix has resulted in decreasing the tilt
angle and angular speed (by increasing their settling time for example, which lead to the fact that we are
getting our response in a faster way than before).

Next, Ill try to increase the position and speed response of the system using the same method. Both by
a factor of 5 meters for the first one and 10 m/s for the second one.

7
Quadratic Optimal Regulator Homework Problem
Aiman H.

The following program details the third trial:


% Homework- Inverted pendulum using QOR-Case4-Modified Q-Less theta and
% angular speed/Higher Linear Speed & Position
clc
A=[0 1 0 0;20.601 0 0 0;0 0 0 1;-0.4905 0 0 0];
B=[0;-1;0;0.5];
C=[0 0 1 0];
D=[0];

Ahat=[A zeros(4,1);-C 0];


Bhat=[B;0];
Q=[100 0 0 0 0
0 100 0 0 0
0 0 1 0 0
0 0 0 1/25 0
0 0 0 0 1/100]
R=[0.01];

[K,P,E]=lqr(Ahat,Bhat,Q,R);
K1=-K(1,5);
KK=[K(1,1) K(1,2) K(1,3) K(1,4)];
AA=[A-B*KK B*K1;-C 0];
BB=[zeros(4,1);1];
CC=[C 0];
DD=[0];
t=[0:0.1:100];
[y,x,t]=step(AA,BB,CC,DD,1,t);

Figure(10)

8
Quadratic Optimal Regulator Homework Problem
Aiman H.

Figure(11)

Again, by comparing the graphs for both speed and position. It can be clearly seen that (from figure 10 &
11) the position for example, shows more stable behavior than in the first trial, which leads to more
consistent physical behavior (although it is somewhat slow), moreover, it is noticed that the position
response has no overshot, and response is similar to that of an overdamped system, which could lead us
to the conclusion that, our modification for X3 has lead to increase the damping ratio of the system (in
effect).

As for the speed, the system after the modification exhibits more consistent speed throughout, as
opposite to what is shown in the first trial, to be more precise, we can see that the speed response in
figure(11) have a higher spike/overshot, and it take more time to reach it steady state value, which I
think is due to the fact that, increasing the Q factor related to X4 has led to this slowing down
behavior.

Hence, it is clear now that the Quadratic Optimal Regulator give a much continent way to address the
overall system performance. One drawback is that the performance obtained here might not always
satisfies more intricate design characteristics. This is because, the quadratic optimal approach seems to
average out the system parameters to get the required optimal performance, as can be seen in the X3
and X4 response behaviors, this could come between the attempt to get more exact performance
characteristics (such as specific overshoot or settling time).

Potrebbero piacerti anche