You are on page 1of 6

Robust LQR Based ANFIS Control of x-z Inverted Pendulum

Ishan Chawla1, Vikram Chopra2, Ashish Singla3


1,3
Department of Mechanical Engineering, Thapar Institute of Engineering & Technology, Patiala, India
2
Department of Electrical & Instrumentation Engineering, Thapar Institute of Engineering & Technology, Patiala, India
1
ishanchawla4@gmail.com, 2vikram.chopra@thapar.edu, 3ashish.singla@thapar.edu

Abstract: Inverted pendulum is a highly unstable, nonlinear input multiple output (SIMO) system with one degree of under
and an under-actuated system. Its dynamics resembles many actuation. Even though, the structure of XIP is simple, its
real-time systems such as segways, self-balancing robots, control is still a challenging task. The x-y inverted pendulum
vertical take-off and landing aircraft (VTOL) and crane (XYIP) is a classification of spherical inverted pendulum,
lifting containers etc. These real-time applications demand where cart moves in the x-y horizontal plane to control the
the need of a robust controller. In literature, many different pendulum pivoted by a universal joint to the cart. The XYIP is
control strategies have been discussed to stabilize an inverted highly nonlinear in nature due to which control of XYIP is a
pendulum, out of them, the most robust being fuzzy control complex task. The x-z inverted pendulum (XZIP) is a
and sliding mode control. The former is difficult to tune and generalized case of XIP, which moves in both horizontal and
has a problem of rule explosion for multivariable system, vertical planes to control the pendulum. Since XZIP can also
whereas the latter has a problem of discontinuity and move in vertical, it represents a realistic model of practical
chattering. To address the issues in fuzzy controller, a novel systems such as planer vertical take-off and land aircrafts,
robust linear quadratic regulator (LQR) based adaptive- rocket, buildings during earthquake.
network fuzzy inference system (ANFIS) controller is
proposed and implemented on the stabilization of x-z inverted In literature, three kinds of control problems exist, i.e., swing
pendulum. The proposed controller is able to solve the up control [5], stabilization control [6] and tracking control [7].
problem of robustness in the LQR controller as well as the Out of these, stabilization and tracking control are extensively
difficulty in tuning along with rule explosion in fuzzy studied due to their application in many practical systems.
controller. Furthermore, the designed controller is tested for Many different control strategies are discussed for stabilization
different pendulum masses and the results show that as and tracking control of inverted pendulum such as LQR
compared with conventional PID controller, the proposed controller [8], pole placement controller [9], PID controller
controller gives better performance in achieving lesser [10], linear quadratic gaussian (LQG) controller [11], state
overshoot and settling time along with better robustness dependent riccati equation (SDRE) based controller [12],
properties. sliding mode controller [13] and fuzzy controller [14] etc. The
most robust control strategies are the sliding mode controller
Keywords: x-z Inverted pendulum, stabilization, ANFIS and fuzzy controller. The sliding mode controller has a
controller, robustness problem of discontinuity and chattering while fuzzy controllers
are difficult to tune and requires expert knowledge of system
I. INTRODUCTION to tune it. Also for a multi variable system problem of rule
From the last few decades, inverted pendulum has been explosion exists in fuzzy controllers. To resolve these
considered as the most popular milestone in the area of control problems in fuzzy controller, recently, the use of LQR based
theory [1]. Due to its inherent non-linearity, instability and ANFIS has been suggested [15-16] but robustness of the
under-actuation, it is frequently considered as a benchmark controller has not been addressed in the work.
problem in control theory. Moreover, the dynamics of inverted
This paper proposes a novel approach to design a robust LQR
pendulum resembles many real-time systems such as under-
based ANFIS (RLQR-ANFIS) controller, which is robust to
actuated robotic systems, rockets, vertical take-off and land
parametric uncertainties. The proposed controller is designed
(VTOL) aircrafts, segway, hoverboard, humanoid robots etc.
and simulated x-z inverted pendulum. Robustness of the
Due to its applications in teaching and research experiments, a
controller is validated by comparing the results of proposed
wide variety of inverted pendulum (IP) systems exist, such as x
controller with PID controller suggested by Wang [7] for
inverted pendulum, x-y inverted pendulum, x-z inverted
different pendulum masses.The work is organized in V
pendulum, acrobat, pendubot, inertia wheel pendulum and
sections. Section II gives the modelling of x-z inverted
furuta pendulum [2-4] etc.
pendulum. The designing of RLQR-ANFIS controller is
The x inverted pendulum (XIP) is the most popular inverted explained in Section III. The simulation results under different
pendulum, where cart can only move in x direction to control conditions are presented in Section IV and finally the paper is
the pendulum pivoted by a pin joint to the cart. It is a single concluded in section V.

978-1-5386-9346-9/19/$31.00 ©2019 IEEE


II. DYNAMIC MODELLING OF X-Z INVERTED Incorporating the parameters of x-z inverted pendulum (given
PENDULUM in Table 1) in Eq. (4) the state space model becomes:
The schematic diagram of x-z inverted pendulum is shown in
ª x º ª0 1 0 0 0 0º ªx º
Figure 1. In Figure 1, ℓ is the distance between cart hinge point « » «0  0 .98 0 »» «« x »»
to the centre of mass of the pendulum, M and m are the cart «x » « 0 0 0
and the pendulum mass respectively. Further Fx and Fz « z » «0 0 0 1 0 0» « z »
represents forces on the cart in x and z directions respectively. « » « »« » 
Angle θ is the angle made by the inverted pendulum with the « z » «0 0 0 0 0 0 » « z »
vertical axis. « T » «0 0 0 0 0 1» «T»
« » « »« »
¬« T ¼» ¬« 0 0 0 0 35 .93 0 ¼» ¬« T ¼»
ª 0 0 º
« 1 0 »»
«
« 0 0 » ª Fx º (5)
« »
« 0 0 .91 » «¬ Fz  10 . 78 »¼
« 0 0 »
« »
«¬  3 .33 0 »¼

TABLE 1: X-Z INVERTED PENDULUM PARAMETERS

M (kg) m l g (m/s2)
(kg) (m)
Fig. 1. Schematic diagram of x-z inverted pendulum
1 0.1 0.3 9.8
The Lagrange’s equations of motion for XZIP is given as [7]:
The above state space model is used for developing the robust
x  ml cosTT
( M  m)  ml sinTT 2 F
x
(1) LQR based ANFIS controller.

III. DESIGN OF ROBUST LQR BASED ANFIS


z  mlsinTT
(M  m)  mlcosTT 2  (M  m)g F
z
(2)
CONTROLLER
ANFIS is a combination of adaptive networks and fuzzy logic.
lT
 cos T
x  sin T
z  g sin T 0 (3)
ANFIS was first presented by Jang in 1993, which acts upon
by constructing a fuzzy inference system with suitable
Using Eq. (1), (2) and (3) the state space representation of the membership functions (MFs) to match a specified input-output
system is given as: dataset with minimum error tolerance. The basic procedure to
design the robust LQR based ANFIS controller is explained in
ª x º ª0 1 0 0 0 0º x
ª º the following sub-sections.
« m »
« » 0 » « x »
«x » «0 0 0 0
M
g
« » A. Generation of dataset
« z » «0 0 0 1 0 0» « z »
« » « » 
0 » « z »
To generate the dataset, an optimal LQR controller is designed
« z » «0 0 0 0 0
« » for the system. The objective of this controller is to minimize a
« T » «0 0 0 0 0 1» «T» cost function. To design an LQR controller, the system is
« « g (M  m ) »« »
» «0 0 » ¬« T ¼» represented in state space form as:
¬« T ¼» ¬
0 0 0
Ml ¼ z Az  Bu (6)
ª 0 0 º
« 1 » Where, z represents a state-vector, u as an input vector and
« M 0 » A, B, C, D are called as the state-weighing coefficient matrices.
« 0 0 » ªF º (4) The LQR cost function is given as:
« 1 »« x »
« 0 (M  m ) » ¬ Fz  g ( M  m ) ¼ 1
f (7)
« 0 »
2 ³0
«
0
»
J0 (z T Qz  u T Ru )dt
«¬  1 Ml 0 »¼

819
Here, Q is the state weighing matrix and R is the control cost B. Defining ANFIS Parameters
matrix. These are user defined and play a vital role in the
controller performance. The control input is given as: In this step, ANFIS parameters such as number and type of
membership functions, error tolerance, number of epochs and
u Ke K (z des  z) (8) learning method is specified. The number of membership
functions for each input variables are chosen as two while the
type of membership function chosen is bell shaped
Error e is a vector, z des is the desired state-vector and K is membership function. Hybrid learning method is used with an
the final optimal state feedback control matrix, which is given error tolerance of zero. Number of epochs (iterations) chosen
as: for each ANFIS training is 10.

C. ANFIS Training
K R 1BT P (9)
Using a robust dataset and given ANFIS parameters, ANFIS
Here, P is the solution to the continuous time algebraic Riccati training is done, which optimizes the parameters of fuzzy
equation: inference system to replicate the stipulated input-output dataset
with minimum error tolerance. The ANFIS training can be
PA  A T P  PBR 1B T P  Q 0 (10) done by using a MATLAB command “anfis”. A “.fis” file is
created after training, which is further used as a controller to
It can be seen that matrix K depends on A, B, Q, and R simulate the system response.
matrices, out of which, A and B are determined by the structure
and parameters of the system while Q and R are defined by IV. RESULTS AND DISCUSSIONS
user according to expected performance criterion. The matrix The control objective is to stabilize the pendulum at an
K can also be calculated directly by using a MATLAB unstable equilibrium position i.e. the upright position, while
command lqr: the cart is also supposed to move exactly by 1 m distance in x-,
y- and z- directions depending upon the type of the cart-
K lqr(A, B, Q, R ) (11)
pendulum system. The parameters of the inverted pendulum
chosen for simulation are given in Table 1.
After calculating LQR gain K, dataset is prepared for each
control input and the operating range of e in the form: To induce parametric variations, the pendulum mass is varied
within the bounded range of (0.1–0.5) kg. The results obtained
Dataset i [e T u i ] i 1,2,3......., p (12) using RLQR-ANFIS controller are compared with the
conventional PID controller for different pendulum masses.
Here ui represents the control input vector for ith actuator and p
the number of control inputs. As compared to XIP, the XZIP has one additional degree of
freedom (DOF), as the cart can move in x-z plane. This 3-DOF
Dataset for Robust Control: To make the controller robust to system is controlled with two actuators in x and z direction,
pendulum mass variations, the dataset is to be prepared for a with one degree of under-actuation. This system is more
bounded set of pendulum mass i.e., challenging to control as compared to the previous one, due to
m=(0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5) kg, and for each the impact of gravity as the cart moves in z-direction.
mass LQR gain K is calculated and thus u is calculated from it
and added to the dataset. The updated robust dataset for each To design a controller, LQR gains are computed for a bounded
control input is given as: set of inverted pendulum mass
m=(0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5) kg considering
LQR tuning parameters, Q=diag[5,1,5,1,1,10] and
ªe T u i0.1 º (13)
R=diag[1,1]. Further control input is calculated for an
« T »
«e u 0i.15 » operating range of XZIP as given in Table 2.

Robust datai= «e T u 0i.2 »


« » u >u1u 2 @T Ke (14)

«0 0»
«e T
¬ u i0.5 »¼ u >u1u 2 @T >F F  g(M  m)] @
x z
T (15)

0.1 0.15 0.2 0.5 Furthermore, two datasets, one of 5625 samples while the
Here u i , u i , u i ,....u i denotes input vector for ith
other of 225 samples are generated, which are used for training
actuator corresponding to pendulum mass of 0.1, 0.15,0.2 …. by ANFIS. Thus, two fuzzy inference system, one with 16
0.5 kg respectively. rules for controlling x position and pendulum angle while the

820
other with 4 rules for controlling z position are obtained. The
gravity compensation is provided in the controller by adding
g(M  m) term to the output of the lateral fuzzy inference
system. Furthermore, the obtained fuzzy inference systems are
implemented on XZIP. The results obtained are compared with
conventional PID controller [7] for different pendulum masses
as shown in Figures 2–6.

Fig. 4. Response of z for mass (m) in kg = a) 0.1; b) 0.3; c) 0.5


(solid line: RLQR-ANFIS controller and dashed line:
conventional PID controller)

Fig. 2. Response of for mass (m) in kg = a) 0.1; b) 0.3; c) 0.5


(solid line: RLQR-ANFIS controller and dashed line:
conventional PID controller)

Fig. 5. Response of input FX for mass (m) in kg = a) 0.1; b) 0.3; c)


0.5 (solid line: RLQR-ANFIS controller and dashed line:
Fig. 3. Response of x for mass (m) in kg = a) 0.1; b) 0.3; c) 0.5 (solid line:
RLQR-ANFIS controller and dashed line: conventional PID controller) conventional PID controller)

821
From Table 2 it can be revealed that even with large variations
in pendulum mass the performance of RLQR-ANFIS
controller is better than the conventional PID controller in
terms of the two performance parameters i.e. maximum
overshoot and settling time.

V. CONCLUSION
In this paper, a new robust LQR based ANFIS controller has
been designed for stabilization of the x-z inverted pendulum.
The performance of the designed controller has been compared
with conventional PID controller for different pendulum
masses and the simulation results have clearly shown that the
designed controller has outperformed the conventional PID
controller in achieving better performance and robustness to
variations in pendulum mass. Further, it has been observed that
on increasing pendulum mass, the conventional PID controller
failed to stabilize inverted pendulum while the RLQR-ANFIS
controller has insignificant impact on the performance of
system. The combination of LQR with ANFIS has solved the
problem of robustness in LQR controller. A further work can
be done on designing a LQR based ANFIS controller which is
Fig. 6. Response of input FZ for mass (m) in kg = a) 0.1; b) 0.3; c) robust to other parametric variations such as mass of cart,
0.5 (solid line: RLQR-ANFIS controller and dashed line: length of pendulum etc.
conventional PID controller)
ACKNOWLEDGMENT
A comparison between different performance parameters for
different pendulum masses is presented in Table2. The authors are grateful to the Thapar Institute of Engineering
and Technology (TIET), Patiala for providing the financial
Pendulu Performan Units RLQR- Convention Percenta support under seed money grant project (TU/DORSP/57/426,
m ce ANFIS al ge 28-03-2017) to perform this research.
Mass Parameters PID Reductio
(m) n REFERENCES
(%)
[1] Davison, E.J., Benchmark problems for control system design.
0.1 θmax Radian 0.0640 0.1789 64.23 IFAC Theory Committee, 1990.
xmax Meter 1.0481 1.6804 37.63 [2] J.Furuta, K., M. Yamakita, and S. Kobayashi, Swing-up control
zmax Meter 1.0091 1.3272 23.97 of inverted pendulum using pseudo state feedback. Proceedings
of the Institution of Mechanical Engineers, Part I: Journal of
Fx max Newton 0.9499 2.9320 67.60 Systems and Control Engineering, 1992. 206(4): p. 263-269.
Fz max Newton 13.0161 15.0021 13.24 [3] Yang, R., Y.-Y. Kuen, and Z. Li. Stabilization of a 2-DOF
Ts Second 6.4820 8.3829 22.68 spherical pendulum on xy table. in Control Applications, 2000.
Proceedings of the 2000 IEEE International Conference on.
0.3 θmax Radian 0.0672 0.2024 66.80
2000.
xmax Meter 1.0351 1.6991 39.08 [4] Jia-Jun, W. Stabilization and tracking control of xz inverted
zmax Meter 1.0240 1.3353 23.31 pendulum based on pid controllers. In Control Conference
Fx max Newton 1.1145 3.7431 70.23 (CCC), 2015 34th Chinese. 2015.
[5] Muskinja, N. and B. Tovornik, Swinging up and stabilization of
Fz max Newton 14.9761 15.8050 5.24 a real inverted pendulum. IEEE Transactions on Industrial
Ts Second 4.6198 5.6652 18.45 Electronics, 2006. 53(2): p. 631-639.
0.5 θmax Radian 0.0708 0.2323 69.52 [6] Wang, J.-J., Stabilization and tracking control of X–Z inverted
pendulum with sliding-mode control. ISA transactions, 2012.
xmax Meter 1.0206 1.7471 41.58
51(6): p. 763-770.
zmax Meter 1.0413 1.3481 22.76 [7] Wang, J.-J., Simulation studies of inverted pendulum based on
Fx max Newton 1.3016 4.8253 73.03 PID controllers. Simulation Modelling Practice and Theory,
Fz max Newton 16.9361 17.7528 4.60 2011. 19(1): p. 440-449.
[8] Kumar, E.V. and J. Jerome, Robust LQR controller design for
Ts Second 4.3547 4.6364 6.08 stabilizing and trajectory tracking of inverted pendulum.
Procedia Engineering, 2013. 64: p. 169-178.

822
[9] Kathpal, A. and A. Singla, SimMechanics Based Modeling, [13] Yiğit, İ., Model free sliding mode stabilizing control of a real
Simulation and Real Time Control of Rotary Inverted rotary inverted pendulum. Journal of Vibration and Control,
Pendulum, in 11th IEEE International Conference on Intelligent 2015: p. 1077546315598031.
Systems and Control (ISCO-2017)2016: Coimbatore, [14] Bui, H.-L., D.-T. Tran, and N.-L. Vu, Optimal fuzzy control of
Tamilnadu. p. 166-172. an inverted pendulum. Journal of vibration and control, 2012.
[10] Ghosh A, Krishnan TR, Subudhi B. Robust PID compensation 18(14): p. 2097-2110.
of an inverted cart-pendulum system: an experimental study. [15] Mohan, V. and N. Singh. Performance comparison of LQR and
IET Control Theory and Applications. 2012; 6:1145-1152. ANFIS controller for stabilizing double inverted pendulum
[11] Eide, R., P.M. Egelid, and H.R. Karimi, LQG control design for system. in Signal Processing, Computing and Control (ISPCC),
balancing an inverted pendulum mobile robot. Intelligent 2013 IEEE International Conference on. 2013. IEEE.
Control and Automation, 2011. 2(02): p. 160. [16] Kharola, A., A PID Based ANFIS & Fuzzy Control of Inverted
[12] Singh, N., J. Dubey, and G. Laddha, Control of pendulum on a Pendulum on Inclined Plane (IPIP), International Journal on
cart with state dependent riccati equations. Analysis, 1870. Smart Sensing and Intelligent Systems, Vol. 9, No. 2, June
2(4): p. 2008. 2016.

823

You might also like