Ica20110200012 71434152
Ica20110200012 71434152
Ica20110200012 71434152
u (1)
where I is moment of inertia of the pendulum, u is the
angle in counterclockwise direction with respect to the
vertical line (see Figure 1), and is the distance to the
center of mass (equal to
l
2 L ). Furthermore, the robot is
governed by a equation of motion relating the forces
Figure 1. The inverted pendulum placed on a simplified
mobile robot.
applied by the pendulum on the robot. Then, according to
Newtons law of motion, the equation of motion of the
robot in horizontal direction can be given as
( )
2
= M m x ml cos ml sin F u u u u + +
(2)
where F can be derived out from the physical properties
of the motor to be [7]
2 2
2
=
g
t m t
Km K
K K
F V
Rr Rr
q
x (3)
Here , , , , ,
m t t g
K K K R q and are coefficients de-
pendent on the physical properties of the motor and gear.
The different parameters for (3) is not known for the
robot used in this project. However, [8] provide values
which will be used in the following. Based on the
previous derivation, we can now define four state vari-
ables, given as the state vector
r
| |
T
T
1 2 3 4
= = x x x x x x u u (
x (4)
Equations (1), (2), and (3) need to be linearized in
order to represent the system on state space form
= x Ax BV + (5)
= y Cx (6)
where A , , and are matrices needed for the
control design and is the (input) voltage applied on
the motor. The linearizing point of interest is the unstable
equilibrium point
B C
V
| |
T
= 0 0 0 0 x
The assumption of small angle approximation gives
sin = u u , cos =1 u , and . This lead to the
following linearized equations of motion (note that (3)
will be the same)
=0 u
( )
( )
2
=
mgl mlx
I ml
u
u
+
(7)
( )
( )
=
F ml
x
M m
u
+
(8)
We want to make (7) and (8) more convenient for the
state space representation by expressing u
and x in
the following way
( ) ( )
2 2
2
=
m g m g
t t
K K K K
g
x V
L ml Rr M L ml Rr M L ml
u u +
(9)
( ) ( )
( )
2 2
2
=
m g
t t
m g
t
LK K
mlg
x x
LM ml Rr LM ml
LK K
V
Rr LM ml
u
+
(10)
Copyright 2011 SciRes. ICA
R. EIDE ET AL. 162
where for simplicity
2
=
I ml
L
ml
+
and =
t
M M m + .
Based on these equations and the following relation
T
2 4
= x x x u (
x
we can now represen first
The system on state s en be
t (9) and (10) as a order system.
pace form th
( )
( ) ( )
( )
( )
2 2
2
2 2
2
0 1 0 0 (
0 0
0 0
0
0
m g
m g
t t
m g
t
m g
t
K K
g
LK K
mlg
LM ml Rr LM ml
LK K
Rr LM ml
V
K K
Rr M L ml
(
(
(
(
(
(
(
(
(
(
( +
(
(
(
(
(11)
(12)
Now, by using the values for the different constants
given in [8], the matrix equations becomes
(
(
When having the system on state space form, the
following step is to design a LQR controller (assuming
that all the states are known and can be measured). Then,
by assuming no sensor available for m suring the angle,
we will continue with an observer d sign. Finally, an
op
placement procedure
nkage
es in
co vior. However, one disadvantage with this
ethod is that the placing of the poles at desired
=
0 0 0 1
t
L ml Rr M L ml
(
(
x x
1 0 0 0
=
0 0 1 0
y
(
(
x
0 1 0 0 0
0 15.14 3.04 0
0 0 0 1 0
(
(
(
=
(
x x
3.39
+
(
(
V
0 37.23 31.61 0 8.33
( (
1 0 0 0
0 0 1 0
y
(
=
(
x
ea
e
timal LQR (LQG controller)will be proposed by im-
plementing a Kalman filter.
3. Linear Quadratic Regulator (LQR)
Design
There are different methods, or procedures, to control the
nverted pendulum. One is the pole i
having the advantage of giving a much clearer li
between adjusted parameters and the resulting chang
ntroller beha
m
locations can lead to high gains [8]. In this section a
linear quadratic regulator (LQR) is proposed as a
solution. The principles of a LQR controller is given in
Figure 2. Here is the state space system represented with
its matrices A, B , and C with the LQR controller
(shown with the K ).
The LQR problem rests upon the following three
assumptions [9]:
1) All the states (x(t)) are available for feedback, i.e. it
can be measured by sensors etc.
2) The system a stabiliz ble which means that all of
its unstable mode e cont
re a
s ar rollable
bsv(A,C) and ctrb(A,B)
an
the control area is
ca
for a linear system with quadratic
pe
3) The system are detectable having all its unstable
modes observable
To check whether the system is controllable and
observable, we use the functions o
d find this to be true.
LQR design is a part of what in
lled optimal control. This regulator provides an
optimal control law
rformance index yielding a cost function on the form
[10]
T
( ) ( ) ( ) ( )
T
0
= d J x t t t t t +
}
Qx u Ru (13)
where
T
= Q Q and
T
= R R are weighting parameters
that penalize the states and the control effort, respec-
tively. These matrices are therefore controller tuning
parame
ters.
nce to
se of certain
e the st
It is cru must be chosen in
accorda the want
respon r word;
i
cial that
emphasize we
states, or in
Q
othe
to give the
how we will
penaliz ates. Likewise, the chosen value(s) of R
will penalize the control effort u . Hence, in an optimal
control problem the control system seeks to maximize
the return from the system with m nimum cost. In a LQR
design, because of the quadratic performance index of
the cost function, the system has a mathematical solution
that yields an optimal control law
( ) ( ) = t x t u K (14)
where u is the control input and K is the gain given
as
1
=
T
S
Q
0 0 0 1
(
and the control weight of the performance index R was
set to 1.
Here we can see that the chosen values in Q result in
a relatively large penalty in the states
(16)
1
x and
3
x . This
means that if
1
x or
3
x
e effect
is large, th e
will amplify of
e larg values in Q
th
1
x and
3
x in the opti-
n problem are to mization proble . he izat
minimize J , the optim cont m
m Since t
al
optim
rol
io
ust forc u e the states
1
x and
3
x to be small (which make s ysically sen e ph
since
1
x and
3
x represent the position of the robot and
the angle of the pendulum
ha
, ectively). Th a resp is v lues
must be modified during subsequent iterations to achieve
as good response as possible (refer to th ext section for
results). On the other nd, the small
e n
R relative to t
max values in Q involves v y low enalty on the
control effort u in the minimization of
he
er p
J , and the
optimal control u can then be rge. For this small R,
e gain K can then be large resulting in a faster response.
In the physical world this might involve instability
problems, especially in systems with saturation [8].
After having specified the initial weighting factors,
one important task is then to simulate to check if the
results correspond with the specified d ign goals given
in the introduction If not, an adjustment of the weighting
factors to get a controller more in line with t e specified
design goals must be performed. However, difficulty in
finding the right weighting factors limits the application
of the LQR based controller synthesis [?]. By an iterative
study when changing Q values and running the
la
th
es
.
h
com-
mand K =lqr(A,B,Q,R)
| | 10.0000 12.6123 25.8648 6.7915 = K .
The simulation of time response with this controller
will be shown in the next section.
State Estimation
As mentioned for the case of the LQR controller, all
sensors for measuring the different states are assumed to
be available. This is not valid assumption in practice. A
are not immediately avai
a
void of sensors means that all states (full-order state
observers), or some of the states (reduced order observer),
lable for use in any control
schemes beyond just stabilization. Thus, an observer is
re
e schematics of the
stem with the observer is shown in Figure 3 below.
from Figure 3, the observer state
eq
lied upon to supply accurate estimations of the states at
all robot-pendulum positions. Th
sy
As can be seen
uations are given by
( )
= x Ax Bu L y Cx + +
(17)
= y Cx (18)
where x is the estimate of the actual state x . Further-
more, Equations (17) and (18) can be re-written to
become
( )
= x A LC x Bu Ly + +
(19)
This, in turn, is the governing equations for a full
order observer, having two inputs u and y and one
output, x . Since we already know and servers
of this ki is simple in design a
estimation of all the states around t
From 3 we can se
difference between the mea
estima uts and correct the mde
Th
A, B
nd
o
u, ob
nd
Figure
ted outp
provides accurate
he linearized point.
e that the observer is im-
plemented by using a duplicate of the linearized system
dynamics and adding in a correction term that is simply a
gain on the error in the estimates. Thus, we will feed
back the sured and the
l continuously.
e proportional observer gain matrix, L, can be found
by pole placement method by use of e placecommand
in MATLAB. The poles were determined to be ten times
faster than the system poles. These were found to be
( ) | |
T
* = 18.0542, 5.4482, 3.4398, 2.4187 eig A B K ,
which yields the gain matrix
34.4 0.2
91.0 1.1
=
30.4 52.5
1103.6 726.4
th
(
(
(
(
(
L (20)
When combining the control-law design with the esti-
mator design we can get the compensator (see Section 6
for results).
4. Kalman Filter Desig
n
In the previous design of the state observer, the mea-
surements = y Cx
is not usually the case in
were assumed to be
practical li
inputs yielding the state equations to be on the general
stochastic state space form
noise free. This
fe. Other unknown
=
=
x Ax Bu Gd
y Cx Hd n
+ +
+ +
(21)
where the matrices can be set to an identity matrix, G
H can be set to ro, is stationary, zero mean ze d
Copyright 2011 SciRes. ICA
R. EIDE ET AL. 164
Figure 3. Schematic of state space control using a observer
where L is the observer gain and K is the LQR gain matrix.
Gaussian white process noise, and is sensor noise of
the same kind.
In this section we will show how the Kalman filter can
be applied to estimate the state vector,
n
x
u
and the output
vector by using the known inputs and the mea-
sureme . Block schematics of a Kalman filter
connected to the plant is depicted in Figure 4.
It can be shown that this will result in an optimal state
estimation. The Kalman filter is essentially a set of
inimizes the estimated error covariance when some
.
is given by
y
nts
y
mathematical equations that implement a predictor-cor-
rector type estimator that is optimal in the sense that it
m
presumed conditions are met [12] The mean square
estimation error
( ) ( ) ( ) ( ) ) ( )
=
T
( J E x t x t x t x t
(
(
(22)
where
T
(
( ) ( ) ( ) ( )
=0 E x t x t y t
(
(23)
The optimal Kalman gain is given by
( ) ( )
1
=
T
e
L t S t C R
(24)
where ( )
e
S t is the same as J given in (22). Further-
more, when inf t , the alge
T
braic Riccati equation can
be written
1
e
(25)
and are the process and measurement
noise c n pectively. Tuning
red if these are not known. Note that when
co er will be used
for m e the position. Since this device does
not involv an can in the fo
mal Kalman gain for
as ( ) =0
e
S t
0=
T
e e n e n
S A AS Q S C R CS
+ +
where
n
Q
ovaria
filter are requi
easurem
e
Finally, the sub-opti
n
R
ces, res
nt of
y noise, we
of the Kalman
ntrolling the robot, a quadrature encod
llowing set =0
n
R .
a steady state
Kalman filter can be expressed as
1
=
T
e
L S C R
.
5. LQG Controller
The LQG controller is simply the combi
ar feed
ot system. The sche-
atics a LQG is in essence similar to that depicted in
nce, the observer gain matrix
in this figure can now be defined as the Kalman gain.
nation of a
Kalman filter with a regular LQR controller. The se-
paration principle guarantees that these can be designed
and computed independently [13]. LQG controllers can
be used both in linear time-invariant systems as well as
in linear time-variant systems. The application to linear
time-variant systems enables the design of line -
back controllers for non-linear uncertain systems, which
is the case for the pendulum-rob
m
Figure 3 in Section 3.1. He
L
However, we also assume disturbances in form of noise,
such that the system in compressed form can be
described as in Figure 5.
From the system given by (21), the feedback control
law given by (14), and the full state observer equation
given by (19) defined previously, we can by combing
these have the following output-feedback controller to be
( )
=
=
x A LC BK x Ly
u Kx
+
(26)
which is the equations the software is based upon when
lculating the state estimates. Since the optimal LQR
controller for this system is already found to have the
feedback gain matrix
ca
| | 10.0000 12.6123 K = 25.8648 6.7915
be
this will
used directly in the LQG design. The remaining is to
find the Kalman gain matrix. We first assume the system
as given in (21). After the measurement and disturbance
noise covariance matrices are determined, the MATLAB
Figure 4. Kalman filter used as an optimal observer.
Figure 5. LQG regulator.
Copyright 2011 SciRes. ICA
R. EIDE ET AL. 165
function kalman was used to find the optimal Kalman
gain L and the covariance matrix P. Measurement noise
covariance matrix is determined out from an expected
noise on each channel. The Kalman gain was found as
(27
6. Simulations
Figure 6 gives the time response of the system with a
step input simulated by use of lsim function in
MATLAB.
Note that a steady state error was reduced by a scalin
The reason for the difference between the plots is due
to the different simulation methods. When simulating the
LQG, we made it be that only the
subjected to a impulse force. This resulted in the Figure
8.
We actually see here that the LQR gave better results.
4.9544 5.0879
0.7797 0.8612
=
25.9957 27.8975
L
(
(
(
(
5.0879 5.4689
(
)
g
factor N after t was calculated
by a rscale function. Figure 7 is the response when using
a observer to estimate the states. Note that the simulation
in this case was done in the Simulink environment with a
impulse function as input.
he reference. This factor
pendulum was
. Conclusions 7
This report has shown that by manipulating the state/
control weightings and noise covariance matrices pro-
perly, both LQR and LQG will give satisfactory result.
Although the results has been somewhat limited, it has
provided us with some useful knowledge concerning
Figure 6. Time response of the system using a LQR con-
troller.
Figure 7. Time response of the system with LQR and ob-
server.
Figure 8. Time response of the system with LQG and im-
ulse force on pendulum.
differences between LQR and LQG control. It could
have been interesting to see how other cost functions
would have affected the results, and how the system
would have reacted if some of the input values had been
changed.
8. References
[1] T. Ilic, D. Pavkovic and D. Zorc, Modeling and Control
of a Pneumatically Actuated Inverted Pendulum, ISA
Transactions, Vol. 48, No. 3, 2009, pp. 327-335.
doi:10.1016/j.isatra.2009.03.004
p
[2] J . Ngamwiwit, N. Komine, S. Nundrakwang and T. Ben-
janarasuth, Hybrid Controller for Swinging up Inverted
Pendulum System, Proceedings of the 44th IEEE Con-
- ference on Decision and Control, and the European Con
trol Conference, Plaza de Espaa Seville, 12-15 Decem-
Copyright 2011 SciRes. ICA
R. EIDE ET AL.
Copyright 2011 SciRes. ICA
166
] J . F. Hauser and A. Saccon, On the Driven Inverted
ical University of Cluj-Napoca, Cluj-Napoca, 2005.
Ikeda and H. O. Wang, Fuzzy Regulators
servers: Relaxed Stability Conditions and
ber 2005.
[3
Pendulum, Proceedings of the 5th International Con-
ference on Information, Communications and Signal
Processing, Bangkok, 6-9 December, 2005.
[4] R. Balan and V. Maties, A Solution of the Inverse Pen-
dulum on a Cart Problem Using Predictive Control,
Techn
[5] K. Tanaka, T.
and Fuzzy Ob
Lmibased Designs, IEEE Transactions on Fuzzy Systems,
Vol. 6, No. 2, 1998, pp. 250-265.
doi:10.1109/91.669023
[6] C. Xu and X. Yu, Mathematical Modeling of Elastic
Inverted Pendulum Control System, Journal of Control
Theory and Applications, Vol. 2, No. 3, 2004, pp.
281-282. doi:10.1007/s11768-004-0010-1
[7] J . Lam, Control of an Inverted Pendulum, Georgia
Tech College of Computing, Georgia, 2009.
[8] A. E. Frazhol, The Control of an Inverted Pendulum,
School of Aeronautics and Astronautics, Purdue Univer-
sity, Indiana, 2007.
[9] M. Athans, The Linear Quadratic LQR problem, Mas-
sachusetts Institute of Technology, Massachusetts, 1981.
[10] R. S. Burns, Advanced Control Engineering, Butter-
worth Heinemann, Oxford, 2001.
[11] J . Hespanha, Undergraduate Lecture Notes on LQG/
LQR Controller Design, 2007.
[12] G. Welch and G. Bishop, An Introduction to the Kalman
Filter, University of North Carolina, North Carolina,
2001.
[13] H. Morimoto, Adaptive LQG Regulator via the Separa-
tion Principle, IEEE Transactions on Automatic Control,
Vol. 35, No. 1, 1991, pp. 85-88. doi:10.1109/9.45150