Habib 2020
Habib 2020
Abstract—An inverted pendulum system has potential performance of the system with LQR controller was evaluated
applications in different domains that motivate researchers for through both simulation and experiment. In defining the Q
new innovative development. An inverted pendulum system is an matrix, more weight was given to the position states (and less
underactuated, nonlinear, inherently unstable and a weight for the velocity states) to control the pendulums and
multivariable system. The system is modelled mainly through
the cart quickly; the input weighting matrix (R) was defined in
2020 21st International Conference on Research and Education in Mechatronics (REM) | 978-1-7281-6224-9/20/$31.00 ©2020 IEEE | DOI: 10.1109/REM49740.2020.9313893
Authorized licensed use limited to: UNIVERSITY OF WESTERN ONTARIO. Downloaded on May 26,2021 at 05:26:02 UTC from IEEE Xplore. Restrictions apply.
addition, GA and PSO are used to tune the Q and R matrices 1
T0 = mc x02 (4)
needed in the design of an LQR controller. 2
1
II. SYSTEM MODELING T1 = m p 1 [ x 0 + θ1 l 1 c o s θ 1 ] 2
2 (5)
This section presents the schematic of a planar DIP system 1 1
and the non-linear mathematical model in part A, while part B + m p 1θ12 l 1 2 s i n 2 θ 1 + J 1θ12
and C deal with the linearization of the non-linear 2 2
mathematical model and the state space representation, 1
T2 = m p 2 [ x 0 + θ1l1 cos θ 1 + θ2 l 2 cos θ 2 ]2 +
respectively. 2 (6)
1 1
A. The Physical and Mathematical Model of a DIP on a Cart
m p 2 [θ1l1 sin θ 1 + θ2 l 2 sin θ 2 ] 2 + J 1θ22
2 2
Euler-Lagrange dynamic formulation is used to model DIP in
[4], [5]. This section introduces the derivation of the nonlinear Where x0 is the cart position; θ1 is the lower pendulum angle
dynamic equation of DIP based on the principles of Euler- and θ2 is the upper pendulum angle
Lagrange approach. The physical model of the system is
illustrated in Fig. 1 and its parameters are described in Table I. Then, T can be obtained as
1
T= ( mc + m p1 + m p 2 ) x02 +
2
1 1
( m p1l12 + m p 2 l12 + J 1 )θ12 + ( m p 2 l2 2 + J 2 )θ22 (7)
2 2
+ ( m p1l1 + m p 2 l1 ) x0θ1 cos θ1 +
m p 2 l2 x0θ2 cos θ 2 + m p 2 l1l2 cos(θ1 − θ 2 )θ1θ2
The total potential energy in the system is:
Fig. 1. A Double Inverted Pendulum (DIP) on a cart
P = P0 + P1 + P2 (8)
Table I. Parameters of a double inverted pendulum
Where P0, P1, P2 are the potential energy terms for the cart, the
Parameter Value Unit lower pendulum, and the upper pendulum, respectively.
Mass of the cart, mc 0.7 Kg
Mass of the lower pendulum, mp1 0.5 Kg P0 = 0 (9)
Mass of the upper pendulum, mp2 0.3 Kg
P1 = m p 1 gl1 cos θ 1 (10)
Earth’s gravity, g 9.8 m/s2
Length of the lower pendulum, l1 0.45 m P2 = m p 2 g (l1 cos θ1 + l2 cos θ 2 ) (11)
Length of the upper pendulum, l2 0.35 m
Then, the total potential energy is:
Moment of inertia of the lower pendulum, J1 0.005 kg.m2
Moment of inertia of the upper pendulum, J2 0.005 kg.m2 P = (mp1l1 + mp 2l1 ) g cos θ1 + mp 2 gl2 cos θ2 (12)
∂ ∂L ∂L (1) 1
− = Fi L= ( mc + m p1 + m p 2 ) x02 +
∂ t ∂ q i ∂ q i 2
1 1
From Euler-Lagrange equation, Fi represent the ( m p1l12 + m p 2 l12 + J 1 )θ12 + ( m p 2 l2 2 + J 2 )θ22 +
generalized system forces or external inputs, qi is representing 2 2
(13)
the system coordinates and L is called the Lagrangian and it is ( m p1l1 + m p 2 l1 ) x 0θ1 cos θ1 + m p 2 l2 x0θ2 cos θ 2 +
the difference between the total kinetic (T) and the total
potential (P) energy in the system. m p 2 l1l2 cos(θ1 − θ 2 )θ1θ2 − ( m P1l1 + m P 2 l1 ) g cos θ1
L =T −P (2)
− m P 2 gl2 cos θ 2
Where T0, T1, T2 are the kinetic energy terms for the cart, the
The Lagrange equation with x0 component has an external
lower pendulum, and the upper pendulum, respectively. input denoted by u .
Authorized licensed use limited to: UNIVERSITY OF WESTERN ONTARIO. Downloaded on May 26,2021 at 05:26:02 UTC from IEEE Xplore. Restrictions apply.
( mc + m p1 + m p 2 ) x0 + ( m p1l1 + m p 2 l1 )θ1 cos θ1 + n =
− b1
;z =
− b 4 b5 a 3 g b b ( a g ) + b5 ( a1 g )
;e = 1 3 1
m p 2 l2θ2 cos θ 2 − ( m p1l1 + m p 2 l1 )θ12 sin θ1 (14) b2 b2 b2
− m p 2 l2θ22 sin θ 2 = u b a g b (b b ( a g ) + b5 ( a1 g ))
r = 3 1 − 6 1 3 1
(m l 2 + m l 2 + J )θ + (m l + m l ) x cos θ + b5 b2b5
p1 1 p2 1 1 1 p1 1 p2 1 0 1
x1 0 1 0 0 0 0 x1 0
B. Linearization of DIP x 0 k
2 0 p 0 q x
0 2
Equation (14), (15) and (16) are linearized about the
x3 0 0 1 0 0 1 x3 0 (26)
pendulum upright position ( at θ1 = 0 and θ 2 = 0 ). = + u
x 4 0 0 r 0 v 0 x4 w
x5 0 0 0 0 0
1 x5 0
cos θ1 = 1,sin θ1 = θ1 , cos θ 2 = 1,sin θ 2 = θ 2
x 6 0 0 e 0 z 0 x6 n
cos(θ1 − θ 2 ) = 1,sin(θ1 − θ 2 ) = θ1 − θ 2
θ 2 = 0,θ 2 = 0,θ = 0, θ = 0
1 2 1 2 y = Cx + Du (27)
This yields three linear equations
x0 + a1θ1 + a3θ2 = u
a0 (17) The matrix A, B, C, D of the system’s dynamic equation are:
a 4 = m p 2 l1l2 ; a5 = m p 2 l22 + J 2 C = I 6 ; D = [ 0]
Authorized licensed use limited to: UNIVERSITY OF WESTERN ONTARIO. Downloaded on May 26,2021 at 05:26:02 UTC from IEEE Xplore. Restrictions apply.
The control goals are: The first step when using GA or PSO to tune the Q and R
matrices is to initialize the chromosome (genes) in the case of
i. To stabilize the lower and upper pendulum at upright GA or the swarm particle in the case of PSO. Each
position, and chromosome or particle is represented by a vector z whose
ii. To command the cart to a new position (0.1 meters). elements represent the Q and R matrices. Where z(1)
represents Q(1,1), z(2) represents Q(3,3), z(3) represents
The initial condition used for the purpose of simulation is: Q(5,5) and z(4) represents R value. Then, other parameters
x_0= [0; 0; 5*pi/180; 0; 5*pi/180; 0] like the population and bounds of the algorithms are also
defined. To get the optimal control parameters, an objective
B. Pole Placement Control function (J_optim) is proposed based on the control input and
Integral Time Square Error (ITSE) [25].
In pole-placement method, the closed-loop poles are
located at desired positions by means of a state feedback (with 1
∞ ∞
(30)
u t .e
T 2
J _ o p tim = Ru dt + dt
an appropriate gain for the system states). However, a 2 0 0
necessary condition for placing a pole at any arbitrary point is Both algorithms minimize this objective function through
that the system must be completely state controllable. This test dissimilar processes as illustrated in Fig. 3 and the optimal
is also known as the Kalman’s test.
solution is iteratively searched until the algorithm reached any
The system was tested for controllability, and a dominant of the stopping criteria such as the number of generations or
pole placement of 4.6% overshoot and 1sec settling time was iterations, function tolerance and time limit.
designed. Then, a separation factor of 2 was used for the other
poles.
C. LQR Control
LQR is an optimal control technique that accounts for Q
and R matrices representing the weights or cost functions to
states deviation and control input respectively [11].
In (28), a function J_lqr (the performance index) is defined
which can also be interpreted as the energy function. The
objective in LQR design is to arrive at an optimal control law
that minimizes the performance index [10].
∞
1 (28)
2 0
J _ lqr = ( x T Q x + u T R u ) dt
Authorized licensed use limited to: UNIVERSITY OF WESTERN ONTARIO. Downloaded on May 26,2021 at 05:26:02 UTC from IEEE Xplore. Restrictions apply.
A. Simulation Results for Pole Placement Control
Based on the formulated requirements in Table I and the
discussion in part B of section III, the desired pole location is:
desired_pole = [-4+4.08j, -4-4.08j, -8, -8, -8, -8]
The controller gain, K is then calculated using this
command: Kpole-placment = acker (A, B,des_pole)
The obtained control gain was used with the system block Fig. 5. The cart position response with LQR controller
diagram developed in Simulink (as illustrated in Fig. 2) and
the results are shown in Table III.
Table III. Summary of the system performance with pole placement control
Time response Cart Lower Pendulum Upper Pendulum
characteristics Position angle angle
Ts (s) 0.0791 0.0487 0.1389
Ts (s) 1.6029 1.5413 1.7047
P.A (m/rad) 0.2249 0.1756 0.0893
ess (m/rad) 0 0 0 Fig. 6. The lower and upper pendulum angle response with LQR controller
Authorized licensed use limited to: UNIVERSITY OF WESTERN ONTARIO. Downloaded on May 26,2021 at 05:26:02 UTC from IEEE Xplore. Restrictions apply.
[6] Q. Qian, D. Dongmei, L. Feng, and T. Yongchuan, “Stabilization of the
double inverted pendulum based on discrete-time model predictive
control,” in 2011 IEEE International Conference on Automation and
Logistics (ICAL), Chongqing, China, Aug. 2011, pp. 243–247, doi:
10.1109/ICAL.2011.6024721.
[7] A. Jain, D. Tayal, and N. Sehgal, “Control of Non-Linear Inverted
Pendulum using Fuzzy Logic Controller,” Int. J. Comput. Appl., vol. 69,
no. 27, pp. 7–11, May 2013, doi: 10.5120/12141-8278.
Fig. 8. 2D Animation of the system control
[8] A. N. K. Nasir, “Performance Comparison between Sliding Mode
Control (SMC) and PD-PID Controllers for a Nonlinear Inverted
V. DISCUSSION Pendulum System,” vol. 4, no. 10, p. 6, 2010.
By examining the results in Table V and those in Table IV [9] A. Jose, C. Augustine, S. M. Malola, and K. Chacko, “Performance
Study of PID Controller and LQR Technique for Inverted Pendulum,”
and III, it can be deduced that the PSO tuned LQR gave the World J. Eng. Technol., vol. 03, no. 02, pp. 76–81, 2015, doi:
overall best transient performance in comparison with the GA 10.4236/wjet.2015.32008.
tuned and manually tuned LQR and the pole-placement [10] G. A. Sultan and Z. K. Farej, “Design and Performance Analysis of LQR
controller. The settling time of the cart, the lower pendulum, Controller for Stabilizing Double Inverted Pendulum System,” Circ.
and the upper pendulum were improved by 11.85%, 51.26% Comput. Sci., vol. 2, no. 9, pp. 1–5, Oct. 2017, doi: 10.22632/ccs-2017-
and 39.9% respectively by the PSO tuned LQR when 252-45.
compared with the results of the pole-placement controller. In [11] D. T. Ratnayake and M. Parnichkun, “LQR-Based Stabilization and
Position Control of a Mobile Double Inverted Pendulum,” IOP Conf.
addition, the results in Table V (in which similar optimization Ser. Mater. Sci. Eng., vol. 886, p. 012034, Jul. 2020, doi: 10.1088/1757-
parameters were defined for GA and PSO) validates that PSO 899X/886/1/012034.
is better than GA when searching for the optimal values of the [12] T. F. Tang, S. H. Chong, and K. K. Pang, “Stabilisation of a rotary
Q and R matrices used in LQR control. inverted pendulum system with double-PID and LQR control:
experimental verification,” Int. J. Automation and Control, p. 16, 2020.
VI. CONCLUSION [13] A. I. Isa, M. F. Hamza, and M. Muhammad, “Hybrid Fuzzy Control of
In this paper, the model of a double inverted pendulum Nonlinear Inverted Pendulum System,” p. 14, 2019.
was developed using Euler-Lagrange dynamic formulation, [14] S. K. Yadav and M. N. Singh, “Optimal Control of Double Inverted
Pendulum Using LQR Controller,” vol. 2, no. 2, p. 5, 2012.
and pole placement and LQR controllers were designed to
[15] T. T. Sarkar and L. Dewan, “Pole-placement, PID and genetic algorithm
stabilize the system. The performance of each controller was based stabilization of inverted pendulum,” in 2017 8th International
tested in MATLAB/Simulink simulation environment and the Conference on Computing, Communication and Networking
system gave satisfactory results based on the control goals and Technologies (ICCCNT), Delhi, Jul. 2017, pp. 1–6, doi:
requirements: the pendulums stabilized in less than 3 s with an 10.1109/ICCCNT.2017.8204047.
overshoot less than 20 degrees and the cart move to 0.1 meters [16] A. A. Roshdy, L. Yu zheng, H. F. Mokbel, and W. Tongyu,
in less than 3 seconds with a rise time less than 0.5 s. “Stabilization of Real Inverted Pendulum Using Pole Separation Factor,”
presented at the 1st International Conference on Mechanical Engineering
Furthermore, the Q and R matrices of the LQR controller were and Material Science), China, 2012, doi: 10.2991/mems.2012.107.
tuned by using GA and PSO algorithms. From the simulation [17] E. Vinodh Kumar and J. Jerome, “Robust LQR Controller Design for
results, the PSO-tuned LQR controller gave the overall best Stabilizing and Trajectory Tracking of Inverted Pendulum,” Procedia
transient performance in comparison with the GA tuned and Eng., vol. 64, pp. 169–178, 2013, doi: 10.1016/j.proeng.2013.09.088.
manually tuned LQR and the pole-placement controller. [18] S.-J. Huang, S.-S. Chen, and S.-C. Lin, “Design and Motion Control of a
Two-Wheel Inverted Pendulum Robot,” vol. 13, no. 3, p. 8, 2019.
The future aspect of this research will be centred on the
[19] K. Hassani and W.-S. Lee, “Optimal Tuning of Linear Quadratic
development of a modular and cheap double inverted Regulators Using Quantum Particle Swarm Optimization,” p. 8, 2014.
pendulum system, including intelligent and robust control. [20] L. Moysis, “Balancing a double inverted pendulum using optimal
control and Laguerre functions,” p. 10, 2016.
REFERENCES [21] A. Al-Mahturi and H. Wahid, “Optimal Tuning of Linear Quadratic
Regulator Controller Using a Particle Swarm Optimization for Two-
[1] I. Siradjuddin, B. Setiawan, A. Fahmi, Z. Amalia, and E. Rohadi, “State Rotor Aerodynamical System,” Int. J. Electron. Commun. Eng., vol. 11,
space control using LQR method for a cart-inverted pendulum linearised no. 2, p. 7, 2017.
model,” vol. 17, no. 01, p. 9, 2017.
[22] C. Sravan Bharadwaj, T. Sudhakar Babu, and N. Rajasekar, “Tuning
[2] A. Cerda-Lugo, A. Gonzalez, A. Cardenas, and D. Piovesan, PID Controller for Inverted Pendulum Using Genetic Algorithm,” in
“Experimental Estimation of a Second Order, Double Inverted Pendulum Advances in Systems, Control and Automation, vol. 442, A. Konkani, R.
Parameters for the study of Human Balancing,” in 2019 41st Annual Bera, and S. Paul, Eds. Singapore: Springer Singapore, 2018, pp. 395–
International Conference of the IEEE Engineering in Medicine and 404.
Biology Society (EMBC), Berlin, Germany, Jul. 2019, pp. 4117–4120,
doi: 10.1109/EMBC.2019.8857611. [23] M. A. Sen and M. Kalyoncu, “Optimal Tuning of a LQR Controller for
an Inverted Pendulum Using the Bees Algorithm,” J. Autom. Control
[3] A. KAMIL and et al., “A comprehensive approach to double inverted Eng., vol. 4, no. 5, p. 4, 2016.
pendulum modeling,” 2019, doi: 10.24425/ACS.2019.130201.
[24] H. G. Kamil, O. T. Makki, and H. M. Umran, “Optimal tuning of a
[4] K. Srikanth and N. K. G V, “Stabilization At Upright Equilibrium Linear Quadratic Regulator for Position Control using Particle Swarm
Position of a Double Inverted Pendulum With Unconstrained Bat Optimisation,” IOP Conf. Ser. Mater. Sci. Eng., vol. 671, p. 012047, Jan.
Optimization,” Int. J. Comput. Sci. Appl., vol. 5, no. 5, pp. 87–101, Oct. 2020, doi: 10.1088/1757-899X/671/1/012047.
2015, doi: 10.5121/ijcsa.2015.5508.
[25] Hazem I. Ali and Alza A. Mahmood, “LQR Design using Particle
[5] R. Banerjee, N. Dey, U. Mondal, and B. Hazra, “Stabilization of Double
Swarm Optimization.pdf.” Iraq Academic Scientific Journals, 2016,
Link Inverted Pendulum Using LQR,” in 2018 International Conference [Online]. Available: https://www.iasj.net.
on Current Trends towards Converging Technologies (ICCTCT),
Coimbatore, Mar. 2018, pp. 1–6, doi: 10.1109/ICCTCT.2018.8550915.
Authorized licensed use limited to: UNIVERSITY OF WESTERN ONTARIO. Downloaded on May 26,2021 at 05:26:02 UTC from IEEE Xplore. Restrictions apply.