Proceedings of the Second International Conference on Inventive Systems and Control (ICISC 2018)
IEEE Xplore Compliant - Part Number:CFP18J06-ART, ISBN:978-1-5386-0807-4; DVD Part Number:CFP18J06DVD, ISBN:978-1-5386-0806-7
Optimal Control of a Ball and Beam System through
LQR and LQG
Rahul Soni Dr.Sathans
Electrical Engineering Department Electrical Engineering Department
NIT Kurukshetra NIT Kurukshetra
Kurukshetra, India. Kurukshetra, India.
[email protected] [email protected] Abstract—This paper presents the design of an optimal This work implements the state feedback translation of the
control strategy for a 2 degree of freedom standard laboratory linear quadratic regulator (LQR) control algorithm. The
system - Ball and Beam. The system is an open loop and non- controller formulations are developed using the linearized
linear system, which is inherently unstable. A linear quadratic prototype of ball and beam system. The optimal control design
regulator (LQR) is designed and implemented with an objective algorithm of LQG, which is a composition of a linear quadratic
to control the position of ball on the beam by varying the angular estimator (Kalman filter) and a LQR, is used for optimal
position of beam. As all states of system are not measurable, control of ball and beam system. The simple and established
therefore, an observer based state feedback is applied. The LQR control algorithms are widely used for controlling the
modelling and simulation of the LQR strategy for controlling the
linear system dynamics and the same is made use of in this
system is carried out on MATLAB SIMULINK platform. The
paper. The system performance has been comparatively studied
LQR strategy is very effective in stabilizing the system. A
comparative analysis is also presented for LQR and Linear with and without noise and presented in this paper. The
Quadratic Gaussian (LQG) control under the effect of sensor comparative analysis of the results demonstrate the
noises in simulation. effectiveness of the control approaches.
The remaining sections of this paper are structured as
Keywords— Ball and beam system, LQR, Observer, LQG follows. Second section discusses the mathematical modeling
I. INTRODUCTION of ball and beam system, followed by third section, which
describes the optimal control using LQR, elaborated briefly.
The ball and beam system is a standard laboratory Fourth section highlights the state estimation (Kalman filter)
equipment that can be used to verify and validate different and LQG (Full state observer), whereas, in fifth section, the
control strategies. This system finds its use very common as SIMULINK model and simulation results are presented. Lastly,
this being a simple, well defined and standard structure [1]. in sixth section, the conclusion of this paper is presented, while
The position of ball on beam is systematically controlled by at the end, a concise list of reference is given.
varying the input angle of beam, which is the most important
action in this system [1-2]. It is an open loop unstable system. II. BALL AND BEAM SYSTEM
This system finds it use in horizontally stabilizing the aerial
vehicle during the time of landing and in balancing the goods A. System Description
carried by a robot. Ball and beam system comprises, as its main elements, the
base, a ball, a beam, gear, support block, and motor etc., which
Due to the system being highly complex and non-linear, are the mechanical parts of this system, as shown in Fig.1. One
some model free control and optimization design approaches end of beam is rigid by a shaft, whereas, the other end rotates
such as Fuzzy control, Neural network, Phase lead up and down on which a ball is free to move [1]. Here, the
compensation, particle swarm optimization etc. have been used inclination angle of beam is controlled by making the pulley
to set and stabilize the ball position on beam and the beam run through controlling the position of DC servomotor.
angular position [3]. In order to stabilize the system, there is
the requirement of phase advance in the control system, but the
presence of noise is more at high frequencies, so, trade-off is
required [4]. Various control concepts have been used in
various studies of the ball and beam system. Because of the
ball and beam system being inherently unstable, the position of
ball can be adjusted in absence of limit for an unchangeable
input angular position of beam [5]. This feature makes the ball
and beam system a suitable equipment for verifying the various
control design strategies. The systems has two degree of
freedom (DOFs). Fig. 1: Schematic of a ball beam system
978-1-5386-0807-4/18/$31.00 ©2018 IEEE 179
Proceedings of the Second International Conference on Inventive Systems and Control (ICISC 2018)
IEEE Xplore Compliant - Part Number:CFP18J06-ART, ISBN:978-1-5386-0807-4; DVD Part Number:CFP18J06DVD, ISBN:978-1-5386-0806-7
B. Mathematical modelling TABLE I. PARAMETERS OF BALL BEAM SYSTEM
In modeling the system mathematically, it is assumed that Parameters Value
the beam length as L, beam angular position is θ, which is M 0.05 kg
limited, d is the distance between contact point and the center. Rb 0.01m
G 9.81 m/s2
Accordingly, the mathematical expression between inclination L 40 cm
angle (α) and angular position of beam (θ) can be described as D 4 cm
[1,3] J 2. 0 ×10-2 kgm2
Jb 2. 0 ×10-6 kgm2
α = (1)
To stop the ball at a particular location on the beam is Putting the values of the parameters from Table I in (6), (7),
accomplished by controller through adjusting the angle of gear. (8) and (9), the state space model can be developed as given in
The movement of ball on the beam can be expressed by a (10) and (11).
kinematic expression as under:
ª x 1 º ª 0 1 0 0 º ª x1 º ª 0 º
( + M) ̈ + Mg sin = Mr( ) (2) « » « »« » « »
x 0 0 7 . 0071 0 x2 0
« 2» « »« » « »u
Where, g is the gravity constant, M is the mass of ball, Jb is « x 3 » « 0 0 0 1»«x3 » « 0 »
the rotational inertia of ball, r is the ball position on beam and « » « »« » « »
Rb is the radius of ball. Here, the friction is considered to be ¬ x 4 ¼ ¬ 24 . 5225 0 0 0 ¼ ¬ x 4 ¼ ¬ 49 . 9950 ¼ (10)
negligible when ball moves on the beam [1]. Since the
inclination angle (α) is very close to the zero, therefore, a ª x1 º
« »
linearized model at α = 0 degree is expressed as: ª1 0 0 0º x2
« »
y « »
¬0 0 1 0¼ « x3 »
̈ =- =- (3) « »
( ) ¬x4 ¼ (11)
Now, taking the Laplace transform of equation (3), we get The controller is then designed utilizing the linear model of
( )
the ball and beam system. The next section describes the LQG
=− ∙ (4) controller.
( ) ( )
III. LINEAR QUADRATIC REGULATOR
The transfer function of system is expressed by the
expression: The synthesize of a control process if leads to extremization
of performance then it is referred to as optimal control, which
( ) . provides the best possible behavior. The main aim of the
=− (5)
( ) optimal control is to satisfy, to the best possible extent, the
The desired ball position is at the centre i.e. at 20 cm and physical constraints and at the same time to extremize
error allowance is presumed to be ±1 . For the proposed (Maximize or Minimize) a suitable performance index or cost
method of control, the ball and beam system is considered as function [6]. Optimal control is obtained using LQR, which is
an ideal investigation model. one of the best strategies. To exercise control, LQR takes the
dynamic system states and control input. Since, LQR is simple,
The non-linear version of ball and beam system can be optimal and robust, therefore, is used most commonly [7]. For
linearized about the equilibrium point (r = 0, ̇ = 0, = 0, ̇ = the LQR design, system matrices A and B must be controllable.
0) leading to the following equations representing the linear
version of ball and beam system Linearization is done about the equilibrium point with the
initial conditions as x[0]= [0,0,0.1,0] . Consequently, the
̇ = (6) linear state space equations are given as
̇ =− (7) ̇ = Ax + Bu (12)
̇ = (8) where, x = [r, ̇ , , ̇ ]
̇ =− + (9) The state feedback control = − tends to
where, = r, = ̇ , = , = ̇ ̇= ( − ) (13)
In above equations, the parameters used are defined as Where, K is obtained from minimization of performance index
below and their nominal values are given in Table I [1].
J = ∫( + ) (14)
= , = , =
Where, Q is positive semi definite symmetric constant matrix
and R is positive definite symmetric constant matrix.
978-1-5386-0807-4/18/$31.00 ©2018 IEEE 180
Proceedings of the Second International Conference on Inventive Systems and Control (ICISC 2018)
IEEE Xplore Compliant - Part Number:CFP18J06-ART, ISBN:978-1-5386-0807-4; DVD Part Number:CFP18J06DVD, ISBN:978-1-5386-0806-7
K is then obtained as
= (15)
Where, P is the positive definite symmetric constant matrix,
which is evaluated from the solution of Algebraical Ricatti
Equation i.e.
+ – + = 0 (16)
In the process of using LQR approach in the design of
optimal control of ball and beam system, all the dynamic
system states i.e. ball position (r), ball velocity ( ̇ ), beam
angular position( ), and beam angular velocity ( ̇ ) are Fig. 2: Block diagram of Luenberger observer
considered free for calculation. These are then used in the
LQR. The LQR is designed making use of the linear state space
model of dynamic system. LQR control involves changing the State vector is given as = − ̂ , on differentiating
poles location of the system to optimal location on which both sides, we get
depends the time response, overshoot, steady state. It is
therefore, obvious that LQR strategy is superior to the pole ̇= ̇− ̇ (19)
placement methodologies as LQR method gives more accurate
From above equations, we get
results.
̇=( − ) (20)
Because, the ball position in the ball and beam system is
the only measurable state and the rest of the states are not The characteristic equation of error is given by
measurable, therefore, an observer is to be designed for this
system for which system matrices A and C must be observable | –( − )| = 0 (21)
[8]. Then the control vector is given by = − , where is Here, L must be chosen so as to ensure that (A-LC) has
the estimated state vector. stable roots. The convergence of (t) must be independent of
IV. STATE ESTIMATION (0). Here, equation (21) is without input control vector
because A, B and C are taken as identical in both the plant and
This section is primarily about estimating all-state variables observer. Therefore, convergence of estimation error tends
of ball and beam system, which is denoted by and the to zero regardless of input control vector. L must be selected in
control vector, consequently is given by = − . a similar manner as K is selected in control design method [9].
A. Full - order state Observer We assume observer error root at desired location, which is
The estimation of state variables is accomplished a state specified as = ʎ , ʎ . . . . . . . . . . . . . . . ʎ leading to desired
observer or merely an observer, as depicted in Fig. 2. The state observer characteristic equation as
equation of system is given by (10) where, A and B are n×n
(s − ʎ ) (s − ʎ ). . . . . . . . (s − ʎ ) = 0 (22)
and n×1 real constant matrices, respectively.
To evaluate L, the coefficients in (21) & (22) need to be
The measurement equation of system is given by =
compared and this is possible when plant is completely
where, C is 1× real constant matrix.
observable i.e.(A, C) must be observable.
To estimate the all-state variables, we construct a model of
B. Kalman filtering
the system as
Kalman filtering is extensively used to estimate
̇= + (17) instantaneous position of moving objects and in target tracking,
Where, is the estimate of actual state. The difference navigation, digital image processing, pattern recognition etc.
between measured and estimated output is applied back for Kalman filter is a least-variant estimation algorithm, which
expediting the estimation process and with this error signal, the derive optimal state estimation. A linear addition of x(t), u(t)
model is continuously corrected. and w(t) represents the state equation, whereas, a linear
addition of x(t) and v(t) represents the observation equation.
The state equations for this is given as Therefore, with the help of state equation and observation
̇= equation, a dynamical model can be constructed as [10].
+ + ( − ) (18)
State equation is defined as:
where L is n× 1 real constant matrix.
( ) = ( − 1) + ( − 1) + ( ) (23)
Observation equation is defined as:
y(t) = Cx(t) + v(t) (24)
978-1-5386-0807-4/18/$31.00 ©2018 IEEE 181
Proceedings of the Second International Conference on Inventive Systems and Control (ICISC 2018)
IEEE Xplore Compliant - Part Number:CFP18J06-ART, ISBN:978-1-5386-0807-4; DVD Part Number:CFP18J06DVD, ISBN:978-1-5386-0806-7
where, x(t) is state vector, u(t) is control vector, y(t) is which was satisfied. The observer poles are chosen as -20,-25,-
observation vector, A is state transition matrix, C is observation 30,-35 and the observer gain (L) is computed as
matrix, w(t) is system noise vector and v(t) is observation noise T
matrix. Here, w(t) and v(t) are supposed to be positive, ª 56 . 032 766 . 969 9 . 68 152 . 34 º
L
symmetric & uncorrelated, with mean zero white noise vectors. « »
¬ 5 . 105 147 . 89 53 . 967 707 . 99 ¼
Mean and covariance of w(t) and v(t) are defined as follows:
For this system, first we computed the LQR gain matrix by
E{w(t)} = 0, E{w(t)wT(t)} = Q using Q and R matrices. After some trial, we got suitable Q and
E{v(t)} = 0, E{v(t)vT(t)} = R R matrices, as following, for the system.
E{w(t)vT(t)} = E{v(t)wT(t)} = 0 ª10 0 0 0 º
« »
From the Kalman filtering theory, also known as Bayesian 0 100 0 0
Q « », R [1 ]
filtering theory, a prediction equations (Time update) and a « 0 0 10 0 »
correction equations (Measurement update) are obtained. « »
¬ 0 0 0 100 ¼
Prediction equations (Time update) are defined as follows: Now, on solving algebraic riccatti equation, the optimal
( ) = A (t − 1) + Bu(t − 1) (25) feedback gain was obtained as
( ) = AP(t − 1)A + Q (26) = [ −3.6906 − 11.7158 40.7948 10.043 ]
Correction equations (Measurement update) are defined as Putting these values in Simulink model, given by Fig-3,
follows: with initial states; x[0] =[0 0 0.1 0]T , the simulation is carried
out. The response of LQR without noise is given in Fig-4. The
K = P C (CP C + R) (27) response of LQR shows that the system is stable with settling
time of 7.28 sec for ball position and 2.25 sec for angular
= + ( − ) (28)
position of beam and steady state error is zero for both states.
= (1 − ) (29)
Where, Kt is Kalman gain matrix, is maximum filter
measure, Pt is filter deflection matrix, ( ) is the prior
estimate and (t) is the prior error covariance.
Since kalman filter with the LQR is known as the LQG
control, so, in this work we also design a LQG control.
For the system
̇ = Ax + Bu + w (30)
y = Cx + v (31)
LQG regulator minimizes the cost function of the following
type
= {lim → ∫[ , ] } (32)
Fig. 3: Simulink implementation of LQR with observer
Where, the process noise w and measurement noise v are
Gaussian white noises with covariance Qwv = E([w;v] *
[wT,vT]) and Qxu = E([x,u]*[xT uT]) .
V. SIMULATION AND RESULTS
This section presents the modelling and simulation of the
LQR and LQG controllers on the considered system. The ball
position on the beam and the angular position of the beam are
utilized as the state feedback to the controller to control the ball
and beam system. Since ball position and angular position of
beam are the only two measurable states, so to obtain the
remaining states an observer is designed. For this first we
checked the observability of system via Kalman test. After
performing the observability test we found that the system is Fig. 4(a): Ball Position
observable. Then we checked the controllability of the system
978-1-5386-0807-4/18/$31.00 ©2018 IEEE 182
Proceedings of the Second International Conference on Inventive Systems and Control (ICISC 2018)
IEEE Xplore Compliant - Part Number:CFP18J06-ART, ISBN:978-1-5386-0807-4; DVD Part Number:CFP18J06DVD, ISBN:978-1-5386-0806-7
Fig. 6(b): Beam Angle
Fig. 4(b): Beam Angle
The response of LQR with the noise shows that the system is
Simulation runs are again carried out after introducing a unstable with ball vibrating around mean position.
measurement noise, as in Fig. 5, in the sensor and the response
Extending the work further, a LQR controller with Kalman
is again verified, which is given by Fig-6.
filter for estimation of state was designed, which is also known
as LQG control. The matrices chosen for LQG are
= (0.1,0.1,0.1,0.1,1)
= (10,100,10,100,1,1)
Solving for the LQG, the solution is a state space model of
LQG as given by
ª 5 . 383 1 2 . 283 0 º ª 5 . 383 2 . 283 º
« » « »
12 . 09 0 1 . 678 0 12 . 09 8 . 685
xˆ « » xˆ « »y
« 2 . 283 0 7 . 566 1 » « 2 . 283 7 . 566 »
« » « »
¬ 50 . 06 32 . 22 120 . 9 20 . 96 ¼ ¬ 20 . 88 26 . 23 ¼
y >1 . 074 0 . 6445 1 . 894 0 . 4192 @ xˆ
Implementing LQG strategy, as per depiction in Fig. 7, on
Fig. 5: Measurement noise the system under investigation, the response is obtained under
the impact of measurement noise, which is given in Fig.8.
Fig. 7: Simulink implementation of LQG
In case of both control strategies, it can be seen that the
stability has been achieved with and without the sensor noise,
but, LQG proves more effective in handling the noise as
against LQR with observer. For quantitative analysis, the
Fig. 6(a): Ball Position settling time and steady stare error have been tabulated in
Table II.
978-1-5386-0807-4/18/$31.00 ©2018 IEEE 183
Proceedings of the Second International Conference on Inventive Systems and Control (ICISC 2018)
IEEE Xplore Compliant - Part Number:CFP18J06-ART, ISBN:978-1-5386-0807-4; DVD Part Number:CFP18J06DVD, ISBN:978-1-5386-0806-7
VI. CONCLUSION
The LQR controller has been designed and implemented
for a ball and beam standard nonlinear and unstable system to
stabilize it in the presence and absence of sensor noise. For
comparative analysis, LQG control was also designed and
implemented on to the same system under same conditions. It
is observed that the LQR, designed via arbitrary choice of
weighting matrices, has been successful to stabilize the system.
The state estimation was also performed, as required for LQG
control. When the system is corrupted with the sensor noise,
the LQR with observer is not able to achieve stability and the
ball is seen moving back and forth. While on the other hand,
the LQG control shows better response, as it takes care of the
Fig. 8(a): Ball Position measurement noise and stabilizes the system successfully.
REFERENCES
[1] WU Yuanyuan, LIU Yongxin. Fuzzy PID Controller Design and
Implementation in Ball- Beam System. Proceedings of the 4th Chinese
Control Confrence. 28-30 july, 2015.
[2] Muhammad Asif Rana, Zubair Usman, Zeeshan Shareef. Automatic
Control of Ball and Beam System Using Particle Swarm Optimization.
IEEE International Symposium on Computatational Intelligence and
Informatics, pp.529-534, 2011.
[3] P.V. Mani Maalini, G.Prabhakar, S.Selvaperumal, Modelling and
Control of Ball and Beam System using PID Controller, International
Conference on Advanced Communication Control and Computing
Technologies (ICACCCT), 2016.
[4] Mohammad Keshmiri, Ali Fellah Jahromi, Abolfazl Mohebbi,
Mohammad Hadi Amoozgar and Wen-Fang Xie, international journal on
Fig. 8(b): Beam Angle smart sensing and intelligent systems, vol. 5, no. 1, march 2012.
[5] M K Choudhary, G Naresh Kumar, ESO Based LQR Controller for Ball
and Beam System, IFAC (International Federation of Automatic
Control) Hosting by Elsevier Ltd, pp.607-610, 2016.
TABLE II. QUANTITATIVE RESPONSE CHARACTERISTICS
[6] M Gopal, Digital Control State Variable Methods: Conventional and
Settling Steady state Intelligent Control systems 4th edition, pp.449-451, 2012
Controller State
time(sec) error [7] Donatien Nganga- Kouya, Franics A.Okou, A New adaptive state
Ball position 7.28 0 Feedback Controller For the Ball And Beam System, IEEE CCECE,
pp.247-252, 2011.
LQR with observer angular position
2.24 0 [8] Vinodh Kumar E, Jovitha Jerome, Raaja G, State Dependent Riccati
of beam Equation based Nonlinear Controller Design for Ball and Beam System,
12th GLOBAL CONGRESS ON MANUFACTURING AND
Ball position - 0.00005
LQR with observer MANAGEMENT, GCMM, pp.1896-1905, 2014.
with noise angular position [9] Carlos G. Bolívar-Vincenty, Gerson Beauchamp-Báez, Modelling the
2.25 0.00001
of beam Ball-and-Beam System From Newtonian Mechanics and from Lagrange
Methods, 12th Latin American and Caribbean Conference for
Ball position 4.25 0.00002 Engineering and Technology Guayaquil, Ecuador, 22-24 july 2014.
LQG angular position [10] Qiang Li, Ranyang Li, Kaifan Ji, Wei Dai, Kalman Filter and Its
2.20 0
of beam Application, 8th International Conference on Intelligent Networks and
Intelligent Systems, pp. 74-77, 2015
978-1-5386-0807-4/18/$31.00 ©2018 IEEE 184