Triple Inverted Pendulum Control Comparison
Triple Inverted Pendulum Control Comparison
Abstract— The inverted triple pendulum is one of the the systems under study [3]. Controllers based on inverted
most interesting systems for control theory researchers pendulum stabilization are used in human balance simulation
due to its properties of major interest to control theory [4], missile launch and control [5], etc.
researchers due to its properties such as nonlinearity and
the fact that it is an underactuated system. In this work we In the literature, different inverted pendulum systems and
have used two control schemes using the triple inverted their control methods have been studied extensively [6]. as
pendulum to analyze and compare the time it takes to the simple inverted pendulum [7]. double inverted pendulum
stabilize the system to its vertical position using each [8]. triple inverted pendulum [2], [9]. However, this article
of the control strategies presented in this paper. In the only studies the triple inverted pendulum system because it
first scheme a linear quadratic regulator (LQR) was used,
while in the second control scheme a Fuzzy-PSO controller presents a higher degree of difficulty due to its considerable
was used. Both control strategies were developed under a increase in instability.
scheme with a reference signal of zero and an initial posi- In [10] the triple inverted pendulum is stabilized using a
tion of the system. The results show that using the Fuzzy- robust computational controller based on linear discrete-time
PSO controller results in faster stabilization and shorter theory. In [11] it is stabilized using a single-input feedback
overshoot compared to the LQR controller.
controller. In [12] a discrete-time H-theory based controller
Index Terms— Fuzzy controller, Inverted triple pendulum is designed and a robust dynamic observer is implemented. In
on a cart, Algorithm PSO, Stabilization, Objective function, [2] an oscillation controller based on a two-degree-of-freedom
Controller LQR.
scheme is designed and implemented.
The mathematical technique that uses linguistic variables
I. I NTRODUCTION and membership functions, commonly known as fuzzy logic,
has shown excellent results in the interpretation of decisions
T HE inverted pendulum is one of the most important
systems in dynamics and is a very relevant topic of
analysis in the control literature [1].The main reason for this
for the control of nonlinear systems, resembling human think-
ing [13].
Thus, researchers have resorted to the implementation of
is that it constitutes an underactuated system with a nonlinear,
fuzzy controllers for single, double and triple inverted pendu-
unstable and nonminimum-phase behavior and thus reveals
lum stabilization [14], [15], [16], [17]. Fuzzy controllers can
many interesting system-theoretic properties [2].
even be combined with other control techniques, developing
The control problem consists of obtaining dynamic models
more robust and efficient control schemes [18].
of systems and using them to determine control laws or
However, achieving parameter tuning of a fuzzy controller
strategies to achieve the desired response and performance of
is not always straightforward and efficient, trial and error
This paper was submitted on January 28, 2022 for review. This work methods can be time consuming [19]. Thus, in recent years,
was supported by the Faculty of Mechanical Engineering and Production bio-inspired intelligence methods have been developed and
Sciences of the ESPOL Polytechnic Universit successfully applied to tune the controllers of an inverted
Jorge Hurel works at the Faculty of Mechanical Engineering and Pro-
duction Sciences at ESPOL Polytechnic University, Guayaquil, Ecuador pendulum such as particle swarm optimization (PSO) [20],
(e-mail: jhurel@[Link]). [21], [22] .
Darwin Alvarado works at the research department at The Pso algorithm is a metaheuristic method based on
ESPOL Polytechnic University, Guayaquil, Ecuador (e-mail:
jodaalva@[Link]). the behavior shown by swarms of bees whose function is to
Juan Peralta works at the Faculty of Mechanical Engineering and Pro- optimize an objective function by updating the position and
duction Sciences at ESPOL Polytechnic University, Guayaquil, Ecuador velocity of the swarm [23]. This technique presents a high
(e-mail: jperal@[Link]).
Jorge Amaya works at the Faculty of Mechanical Engineering and quality solution with more stable convergences and shorter
Production Sciences at ESPOL Polytechnic University, Guayaquil, computation time.
Ecuador (e-mail: jlamaya@[Link]). This paper proposes to implement the PSO method for
Francisca Flores works at the Faculty of Natural Sciences and Math-
ematics at ESPOL Polytechnic University, Guayaquil, Ecuador (e-mail: tuning the scaling factors of normalized fuzzy controllers
ffloresn@[Link]). to stabilize a triple inverted pendulum, and compare it with
2 GENERIC COLORIZED JOURNAL, VOL. XX, NO. XX, XXXX 2017
𝑚3 , 𝑙3 , 𝐽3 𝜃3
d ∂L ∂L ∂R
( )− + = τδi1 , i = 1, 2, 3, 4 (1)
dt ∂ q˙i ∂qi ∂ q˙i
x
where 21 mc x˙c 2 represents the kinetic energy of the cart and
1
P3 ˙ 2 1 P3 J θ˙2 represents the kinetic energy of
2 i=1 mi Bi + 2 i=1 i i
Fig. 1. Schematics of the triple pendulum on a cart.
the pendulums.
The potential energy of the system is given by:
an LQR controller. The actuator force of the triple inverted V = g[m1 B1,2 + m2 B2,2 + m3 B3,2 ] (3)
pendulum system is based on the feedback of the error (e)
and error rate (er) of the angle and position of the cart. where g is the acceleration of gravity. The equations of
motion are as follows:
The rest of the paper is organized as follows: Section
II presents the mathematical model of the inverted triple
pendulum. Section III presents the LQR controller. Section a0 q¨0 + a1 (q¨1 cos q1 − q˙1 2 sin q1 ) + a2 (q¨2 cos q2
(4)
IV presents the proposed fuzzy controller with PSO tuning. −q˙2 2 sin q2 ) + a3 (q¨3 cos q3 − q˙3 2 sin q3 ) = τ
Section V presents the implementation of the PSO algorithm.
Section VI discusses the experimental results. Finally, Section
a1 (q¨0 cos q1 − g sin q1 ) + a4 (q¨2 cos(q2 − q1 )
VII is devoted to conclusions.
−q˙2 2 sin(q2 − q1 )) + a5 (q¨3 cos(q3 − q1 )
(5)
II. M ATHEMATICAL M ODEL −q˙3 2 sin(q3 − q1 )) + b1 q¨1 + J1 q¨1 + d1 q˙1
−d2 (q˙2 − q˙1 ) = 0
The triple inverted pendulum system is shown in Figure 7.
It consists of three rigid links whose length is represented by
l1 , l2 , l3 respectively. These links are connected by means of a2 (q¨0 cos q2 − gsin q2 ) + a4 (q¨1 cos(q2 − q1 )
revolute joints. The first link at its lower joint is connected +q˙1 2 sin(q2 − q1 )) + a6 (q¨3 cos(q3 − q2 )
(6)
with a cart which moves along the horizontal axis due to the −q˙3 2 sin(q3 − q2 )) + b2 q¨2 + J2 q¨2
force u(t), exerted by means of a controller. The mass of the
+d2 (q˙2 − q˙1 ) − d3 (q˙3 − q˙2 ) = 0
links is denoted by m1 , m2 , m3 and the mass of the cart
by mc . The angles formed by the links with respect to the
vertical axis are denoted by θ1 , θ2 , θ3 respectively and the a3 (q¨0 cos q3 − gsin q3 ) + a5 (q¨1 cos(q3 − q1 )
displacement of the cart with respect to the reference frame +q˙1 2 sin(q3 − q1 )) + a6 (q¨2 cos(q3 − q2 ))
(7)
[x0 , y0 ] is represented by xc . +q˙2 2 sin((q3 − q2 )) + b3 q¨3 + J3 q¨3
+d3 (q˙3 − q˙2 ) = 0
A. Equations of motion The equations of motion expressed in vector notation can
The system has four degrees of freedom [xc ,θ1 ,θ2 ,θ3 ], be written as follows:
therefore four generalized coordinates are chosen [q1 , q2 , q3 ,
q4 ]. The position of the center of mass of each link with respect D(q)q̈ + C(q, q̇)q̇ + Gq̇ + g(q) = τ (8)
to the reference frame [x0 ,y0 ], is given by:
The equilibrium points of the system are
[xc , θ1 , θ2 θ3 , x˙c , θ˙1 , θ˙2 , θ˙3 ]T = [0, 0, 0, 0, 0, 0, 0, 0]T .
B1 = [xc + c1 sinθ1 , c1 cosθ1 ] Therefore, the state-space model of the linearized model is
obtained as follows
B2 = [xc + l1 sinθ1 + c2 sinθ2 ,
l1 cosθ1 + c2 cosθ2 ]
ẋ = Ax + Bu
B3 = [xc + l1 sinθ1 + l2 sinθ2 + c3 sinθ3 , (9)
y = Cx + Du
l1 cosθ1 + l2 cosθ2 + c3 cosθ3 ]
Using the parameters indicated in Table 1, the state matrices
The equations of motion of the system are given by: are obtained as follows.
AUTHOR et al.: PREPARATION OF PAPERS FOR IEEE TRANSACTIONS AND JOURNALS (FEBRUARY 2017) 3
0 0 0 0 1 0 0 0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
To determine the optimal change of control, the Hamilton
function is derived and equated to zero to obtain:
0 0 0 0 0 0 0 1
A= 0 18.2787 −0.9534 0.0269 0 0.6039 −0.0075
0.0005 ,
0 −144.5732 54.2372 −1.5302 0 −4.7965 0.1561 −0.0288
0 75.0684 −80.3780 11.9416 0 2.5125 −0.2048 0.0806
0 −8.2026 46.2486 −38.7707 0 −0.2903 0.1592 −0.1713
0
0
u(t) = −Kx(t) = R−1 B T P x(t) (12)
00
1 0 0 0 0 0 0 0 0
B= , C= 0 1 0 0 0 0 0 0 , D= 0
0.8223
−2.7813
00100000 0 Where the value of P is determined using the algebraic
00010000 0
0.2008 Riccati equation,given as follows:
−0.0219
Scaling
factor Scaling
factor
Start
Yes No
Fig. 3. Block diagram for the PSO-FUZZY control system.
Is K<=Max(ite)?
NS NB NM NM NS ZE PS PM
ZE NM NM NS ZE PS PM PM
Where pi is the position of the particle i, k+1 represents
PS NM NS ZE PS PM PM PB
the next iteration, vi is the velocity of the particle. c1 and c2
PM NS ZE PS PM PB PB PB
are the social and cognitive accelerations for the best local
PB ZE PS PM PB PB PB PB
and global positions, respectively, r1(k) and r2(k) are random
numbers in the interval [0; 1], and w is the inertial momentum
or weight constant.
V. PARTICLE S WARM O PTIMIZATION (PSO) In this paper, an objective function is proposed in order
The PSO algorithm optimizes an objective function by to tune the fuzzy controllers to allow the stabilization of the
means of a multidimensional stochastic global search, its triple inverted pendulum system. The objective function is
application is relatively easy and very accurate results can represented by the errors of the system states and by the
always be obtained. overshoots in them, as shown below:
The PSO algorithm comprises a fixed number of particles
coexisting in the solution space. This set of particles performs
Z
a collaborative search for an optimal position, making use of F = [4(ec )2 + 12(e1 )2 + 10(e2 )2 + 8.5(e3 )2
a cognitive component that intuits the particle to improve its (16)
+0.3(max(ec )) + 0.6(max(e1 )) + 0.35(max(e2 ))
own location that it creates, and a social component that drags
the particle towards the global best particle so far. +0.35(max(e3 ))
The process that executes the PSO algorithm is presented in Where, The error index of each state is given by ei =
Figure 4. Where the best position of the i-th particle (Libest) (yrefi − yobti ), where yrefi is the reference position of our
and the best global position of the swarm (Gbest) is tracked system in this case is zero for all states. And yobti is the
and stored by implementing the following equation: position obtained in each state.
AUTHOR et al.: PREPARATION OF PAPERS FOR IEEE TRANSACTIONS AND JOURNALS (FEBRUARY 2017) 5
y
+
CONTROLLER LQR TRIPLE PENDULUM
− Pendulum 1
Reference
in out
Pendulum 2
Fuzzy Controller3
in out
+
Fuzzy Controller y
+
+ TRIPLE PENDULUM
+
+ Pendulum 3
in out
in out
Fuzzy Controller2
TABLE IV
G AINS GENERATED RESULTS
Results
(b) LQR PSO
Fig. 5. Membership functions for normalized variables: (a) input variable GAIN Results GAIN Results
e (er is similar); (b) output variable Signal. 3.1623 A -0.7192
-7.4107 B -0.5438
-4.5701 C -0.7040
VI. A NALYSIS AND R ESULTS
2.3414 A1 -0.1772
K
In this section the experimental results are presented where 5.2449 B1 1.4340
both control schemes have been developed in Matlab/Simulink -0.6742 C1 -0.9123
implementing the LQR controller and the PSO algorithm -1.8765 A2 -0.4516
to find the gains and the scaling factors respectively. The -0.7389 B2 1.2779
fuzzy controller has been developed using the Matlab Fuzzy C2 -1.0911
Toolbox. The parameters used for the PSO optimisation are
A3 0.8128
shown in table III.
B3 0.2294
C3 -1.3621
TABLE III
PSO / F UZZY PARAMETERS
Figure 7 (c) shows the angular response of pendulum 3 state space in Simulink to be implemented by both controllers.
where the initial state position is 0.349 rad, and also shows The LQR controller with zero reference signal and initial
that although the settling time is shorter with the Fuzzy-PSO position of the system was developed in Matlab/Simulink. The
controller, the overshoot generated in this case is slightly larger PSO algorithm was developed to adjust the scaling factors
compared to that generated with the LQR. of the fuzzy controller, with the objective of stabilizing the
system with a reference signal of zero, with an initial system
position of 0.349 radians at the third pendulum. The run
time of the PSO algorithm required to find the necessary
scaling factors was 3570 seconds. The stabilization time of
the pendulum using the LQR controller was 4.6 seconds.
While the stabilization time using the gains found by PSO
was 2.92 seconds. Therefore, the control strategy using the
PSO algorithm is much more efficient than the LQR controller.
ACKNOWLEDGMENT
This work was supported by the Faculty of Mechanical En-
gineering and Production Sciences of the ESPOL Polytechnic
Universit
(a)
R EFERENCES
[1] M. El-Hawwary, A. Elshafei, H. Emara, and H. Fattah, “Adaptive
fuzzy control of the inverted pendulum problem,” IEEE Transactions
on Control Systems Technology, vol. 14, no. 6, pp. 1135–1144, 2006.
[2] T. Glück, A. Eder, and A. Kugi, “Swing-up control of a triple pendulum
on a cart with experimental validation,” Automatica, vol. 49, no. 3, pp.
801–808, 2013.
[3] L. B. Prasad, B. Tyagi, and H. O. Gupta, “Optimal control of nonlinear
inverted pendulum system using (pid) controller and (lqr): Performance
analysis without and witn disturbance input,” International Journal of
Automation and Computing, vol. 11, no. 6, 2014.
[4] L. Chang, S. Piao, X. Leng, Z. He, and Z. Zhu, “Inverted pendulum
model for turn-planning for biped robot,” Physical Communication,
vol. 42, p. 101168, 2020.
[5] I. Krzysztofik and Z. Koruba, “Adaptive control of anti-aircraft missile
launcher mounted on a mobile base,” Theoretical and Applied Mechanics
Letters, vol. 2, no. 4, p. 043008, 2012.
[6] Z. S. Kizir, Bingul, and C. Oysu, “Fuzzy control of a real time inverted
(b) pendulum system,” Journal of Intelligent and Fuzzy Systems, vol. 21,
pp. 121–133, 2010.
[7] K. Yoshida, “Swing-up control of an inverted pendulum by energy-
based methods,” in Procedings of the American Control Conference,
San Diego, California, 1999, pp. 4045–4047.
[8] K. Graichen, M. Treuer, and M. Zeitz, “Swing-up of the double pendu-
lum on a cart by feedforward and feedback control with experimental
validation,” Automatica, vol. 43, no. 1, pp. 63–71, 2007.
[9] ——, “Fast side-stepping of the triple inverted pendulum via constrained
nonlinear feedforward control design,” in Proceedings of the 44th IEEE
Conference on Decision and Control, 2005, pp. 1096–1101.
[10] G. A. Medrano-Cerda, “Robust stabilization of a triple inverted
pendulum-cart,” International Journal of Control, vol. 68, no. 4, pp.
849–865, 1997.
[11] K. G. Eltohamy and C.-Y. Kuo, “Nonlinear optimal control of a triple
link inverted pendulum with single control input,” International Journal
of Control, vol. 69, no. 2, pp. 239–256, 1998.
[12] V. Tsachouridis and G. Medrano-Cerda, “Discrete-time h control of a
triple inverted pendulum with single control input,” Control Theory and
(c) Applications, IEE Proceedings -.
Fig. 7. Stabilization of triple pendulum: (a) Pendulum 1; (b) Pendulum [13] H. Belyadi and A. Haghighat, “Chapter 8 - fuzzy logic,” in Machine
2; (c) Pendulum 3 Learning Guide for Oil and Gas Using Python, H. Belyadi and
. A. Haghighat, Eds. Gulf Professional Publishing, 2021, pp. 381–418.
[14] J. Yi and N. Yubazaki, “Stabilization fuzzy control of inverted pendulum
systems,” Artificial Intelligence in Engineering, vol. 14, no. 2, pp. 153–
VII. C ONCLUSIONS 163, 2000.
[15] M. El-Bardini and A. M. El-Nagar, “Interval type-2 fuzzy pid controller
In the work presented, a comparative analysis of the stability for uncertain nonlinear inverted pendulum system,” ISA Transactions,
of the triple inverted pendulum system was performed by vol. 53, no. 3, pp. 732–743, 2014.
[16] A. I. Roose, S. Yahya, and H. Al-Rizzo, “Fuzzy-logic control of an
applying the use of an LQR controller and a Fuzzy-PSO inverted pendulum on a cart,” Computers and Electrical Engineering,
controller. The TIP system was linearized and represented in vol. 61, pp. 31–47, 2017.
AUTHOR et al.: PREPARATION OF PAPERS FOR IEEE TRANSACTIONS AND JOURNALS (FEBRUARY 2017) 7
[17] F. Cheng, G. Zhong, Youshan Li, and Z. Xu, “Fuzzy control of a double-
inverted pendulum,” Fuzzy Sets and Systems, vol. 79, no. 3, pp. 315–321,
1996.
[18] Z. B. Hazem, M. J. Fotuhi, and Z. Bingul, “Development of a fuzzy-
lqr and fuzzy-lqg stability control for a double link rotary inverted
pendulum,” Journal of the Franklin Institute, vol. 357, no. 15, pp.
10 529–10 556, 2020.
[19] S. Chopra, R. Mitra, and V. Kumar, “A robust scheme for tuning of
fuzzy pi type controller,” in 2006 3rd International IEEE Conference
Intelligent Systems, 2006, pp. 300–305.
[20] M. Hamza, H. J. YAP, and I. Choudhury, “Genetic algorithm and
particle swarm optimization based cascade interval type 2 fuzzy pd
controller for rotary inverted pendulum system,” Mathematical Problems
in Engineering, vol. 2015, 06 2015.
[21] H. B. T.J. Shima, “Pso-based integral sliding mode controller for optimal
swing-up and stabilization of the cart-inverted pendulum system,” Nige-
rian Journal of Technological Development, vol. 18, no. 2, pp. 88–97,
2021.
[22] U. Onen, A. Çakan, and I. Ilhan, “Particle swarm optimization based lqr
control of an inverted pendulum,” Engineering and Technology Journal,
vol. 2, pp. 168–174, 05 2017.
[23] A. Abdelbar, S. Abdelshahid, and D. Wunsch, “Fuzzy pso: a gener-
alization of particle swarm optimization,” in Proceedings. 2005 IEEE
International Joint Conference on Neural Networks, 2005., vol. 2, 2005,
pp. 1086–1091 vol. 2.
[24] E. T. M. Jibril, M. Tadese, “Comparison of a triple inverted pendulum
stabilization using optimal control technique,” Multidisciplinary Aca-
demic Journal Publisher, 2020.