Stabilization of Three Links Inverted Pendulum with Cart Based on Genetic LQR Approach

Stabilization of Three Links Inverted Pendulum with Cart Based on Genetic LQR Approach

Abdullah Ibrahim Abdullah Yazen Hudhaifa Shakir AlnemaMohammad A. Thanoon 

College of Electronics Engineering, Systems and Control Engineering, Ninevah University, Mosul 41001, Iraq

Corresponding Author Email: 
yazen.shakir@uoninevah.edu.iq
Page: 
125-130
|
DOI: 
https://doi.org/10.18280/jesa.550113
Received: 
30 November 2021
|
Revised: 
10 February 2022
|
Accepted: 
17 February 2022
|
Available online: 
28 February 2022
| Citation

© 2022 IIETA. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

This academic paper demonstrates the implementation of a Linear Quadratic Regulator (LQR) controller design for optimal controlling a three connected links in an inverted pendulum form that attached to a moving cart to realize the stability of making a pendulum in a straight vertical line via translation of the cart left and right. To maintain a triple link inverted pendulum (TLIP) vertical, genetic algorithm has been employed to adjust and tune the parameters of LQR, which are the weighting matrices Q and R instead of the approach of try and error. In this article, a hybrid control algorithm (GA-LQR) proposed to select the optimal values of weighting matrices to overcome LQR design difficulties, which gives the best transient response requirements such as percentage overshoot and steady state error. The triple link inverted pendulum is model mathematically modelled in MATLAB platform to simulate the actual system where the results from the simulation gives acceptable and adequate performance of LQR controller in making the system stable.

Keywords: 

GA_LQR, triple link inverted pendulum, stabilization of inverted pendulum

1. Introduction

The features that distinguish the triple inverted pendulum over other system can be summarized as follow: non-linearity extremely high, multi-variable parameters, high order instability.

This system is dynamics and similar to many actual systems such as legged robots, landing system automatically for aircrafts and many other applications in the industry sector [1]. Applying control techniques for the inverted pendulum via control theory is considered a challenging and not mush easy to perform.

Since it is highly unstable plus nonlinear system. This complexity increases directionally proportional with the number of links that constitutes the pendulum body [2]. In this research, a three inverted links pendulum carried via or mounted on a cart will be revealed to study and analysis the control theory that ensure making the pendulum straightforward. The TLIP scheme is SIMO system that means single input with multiple output.

This pendulum will be stabilized via a linear quadratic regulator which is shortly called (LQR) in continuous time domain. The main reason behind this work is to obtain improvement of the overall performance for transient and steady state responses of the cart TLIP [3]. A LQR controller that tuned via a genetic algorithm has been successfully executed for a cart triple link inverted pendulum system.

2. Mathematical Model

The best description for the mathematical model of the triple link inverted pendulum (TLIP) can be expressed via the Lagrange technique (equation) [4]. Three links with different lengths are together create the pendulum hinged from the bottom with a cart as shown below in Figure 1 where the external force or action denoted by u, x is measured by meters that represents displacement of cart. The Joints variables of the first, middle and last bars of the pendulum are θ1, θ2, θ3 respectively [5].

Figure 1. Schematic of cart with three links inverted pendulum

The state space equations are an appropriate approach to implement the modelling of the this inverted pendulum plant as shown below:

$\dot{X}=\mathrm{AX}+\mathrm{BU}$         (1)

$Y=C X+D U$          (2)

where,

The state variables as a vector is defined $X=\left[\begin{array}{llllll}x & \theta_{1} \theta_{2} & \theta_{3} & \dot{x} & \dot{\theta}_{1} \dot{\theta}_{2} & \dot{\theta}_{3}\end{array}\right]^{T}$.

Y: is a vector that contains the output matrix;

U: is the vector that contains inputs of the systems;

C: is the output matrix that selects required output;

D: is the feedforward matrix which is zero;

A: plant matrix which is square matrix.

$A=\left[\begin{array}{cccccccc}0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & -12.4928 & -2.0824 & 2.2956 & -5.1127 & 0.0075 & 0.0024 & -0.0053 \\ 0 & 67.1071 & 65.2564 & -71.9704 & 14.0176 & 0.0039 & -0.1948 & 0.1659 \\ 0 & 144.5482 & -394.2536 & 272.1049 & 5.2021 & -0.4334 & 1.1287 & -0.7492 \\ 0 & -300.4564 & 512.8310 & -258.9198 & -10.8077 & 0.6476 & -1.3621 & 0.826\end{array}\right]$

$B=\left[\begin{array}{lllllll}0 & 0 & 0 & 03.651 & -10.012 & -3.716 & 7.720\end{array}\right]^{T}$

$c=\left[\begin{array}{llllllll}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\end{array}\right]$

The following system, input and output matrices have been taken from the reference [5].

m0=2.4 kg

m1=1.323 kg    m2=1.389 kg    m3=0.8655 kg

L1=10402 m     L2=0.332 m      L3=0.72 m

I1=0.2449 m     I2=0.193 m     I3=0.3405 m

J1=.0119 Kgm2    J2=.0069e-3Kgm2         J3=.0291 Kgm2

f0=13.611 Nsm-1     f1=.0045 Nsm       f2=0.0045 Nsm

f3=0.0045 Nsm     Ks=9.722 NV       g=9.81 ms-2

Regarding C- Matrix gives four outputs out of eight states.

Which are (three Joints angles and linear distance of the cart).

3. LQR Controller

The feedback control system for all states compared with reference input for Triple Links Inverted Pendulum (TLIP) is illustrated in Figure 2. It is a controller with more than one variable, which can instantaneously regulate and control two or more parameters, which can be identified here as the linear horizontal distance of the cart and the joint angles of the links with respect to the vertical line at the same time. Let assume that the state equation of a given LTI system is: [6].

$\dot{x}=A x+B u, y=C x+D u$                 (3)

In addition, the quadratic cost function (performance index) is:

$J=\frac{1}{2} \int_{0}^{t_{f}}\left[X^{T}(t) Q(t) X(t)+U^{T}(t) R(t) U(t)\right] d t$              (4)

where, Q and R are positive definite matrices. For our paper we have incorporated degree of stability $\alpha$. All closed-loop poles are to the left of -$\alpha$ . Thus, we derive a new performance index cost function:

$J=\frac{1}{2} \int_{0}^{t_{f}}\left[e^{2 \alpha T}\left\{X^{T}(t) Q(t) X(t)+U^{T}(t) R(t) U(t)\right\}\right] d t$                (5)

In order to determine the best feedback control law u(t)=-Kx(t); to make the cost function (J) as minimum as possible, thus u(t) is named optimal control. From the optimal control theory, it can make Eq. (3) to be minimum by this control law as written below:

$u(t)=-R^{-1} B^{T} \lambda(t)$              (6)

We can compute the value of the $\lambda(\mathrm{t})$  from the follwoing relation:

$\lambda(\mathrm{t})=-\mathrm{p}(\mathrm{t}) \mathrm{X}(\mathrm{t})$          (7)

p(t) is the solution for what is called Riccati differential equation, so the dervative of this solution can be as:

$\dot{\mathrm{p}}(\mathrm{t})=-\mathrm{p}(\mathrm{t}) A-A^{T} \mathrm{p}(\mathrm{t})+\mathrm{p}(\mathrm{t}) B R^{-1} B^{T} \mathrm{p}(\mathrm{t})-Q$         (8)

$t_{f}:$ final time that the steady state of the systems.

A, B: are the system and input matirces respectively.

When $t_{f}$ goes to approximately infinity, p(t) tends to be a constant value matrix, and $\dot{\mathrm{p}}(\mathrm{t})=0$, thus

$\mathrm{p}(\mathrm{t}) A+A^{T} \mathrm{p}(\mathrm{t})-\mathrm{p}(\mathrm{t}) B R^{-1} B^{T} \mathrm{p}(\mathrm{t})+Q=0$          (9)

where, A, B, Q and R are already known, so the solver is p (t) which Riccati constant will be determined via Eq. (9).

This relation is called Algebraic Riccati equation which is in a matrix form. Consequently, it can obtain the state feedback vector:

$\mathrm{K}=-\mathrm{R}^{-1} B^{T} p$          (10)

This is giving an indication that the crucial concern is to choose the optimal values of Q and R matrices that leads to calculate best value of P in algebric Riccati equation, consequently the feedback gain K can be solved [7, 8].

As mention above in details for obtaining the feed-back gain K does not ensure or give guarantee that the obtained gain from the feedback signal can achieve to zero steady state error. when the input is a step for instance, it is very common the feedback transfer function H(s) of a closed loop system has unsatisfactory dc gains M, 0 < M < 1. The transfer function of a closed loop system is expressed as $H(s)=C(s I-(A-B K))^{-1} B$ where dc gain M can be obtained by $\left.H(s)\right|_{s=0}$ [9].

Figure 2. Feedback control system with full states for TIP

where the N as shown in Figure 2 is a pre-gain = 1/M which is unsatisfactory, however it is necessary to ensure steady state error to be zero when H(s)=0.

In Figure 2, the mathematical representation for the block diagram can be summarized as follow:

$K=\left[\begin{array}{llllllll}K_{1} & K_{2} & K_{3} & K_{4} & K_{5} & K_{6} & K_{7} & K_{8}\end{array}\right]$      (11)

feedback gain vector $u(t)=-K x(t)$       (12)

$x(t)=\left[x \theta_{1} \theta_{2} \theta_{3} \dot{x} \dot{\theta}_{1} \dot{\theta}_{2} \dot{\theta}_{3}\right]^{\prime}$      (13)

One of the key solutions to enhance the performance of the system through reducing the steady state error is to place a pre gain N as shown in Figure 3 which can be calculated as N=1/M. Thus, the full s.s equations can be expressed as follow [9]:

$\dot{x}=(A-B K) x+B u y=C x u=r-K x$      (14)

Figure 3. Feedback control system with pre gain N

4. Genetic Algorithm (GA)

Genetic algorithm is one of the classical optimization techniques which is shortly written GA. It is considered that one of the global adaptive searches for optimal values based on natural choice or selection. That leads to classify stages to three which are: Selection, Crossover and finally Mutation respectively. To apply these three operations gives new generations and individuals which can be the best compared with their parents [10].

This algorithm works via repeating itself many times to produce several or many generations and then stop when obtaining optimal solutions for the individuals for a certain problem. This can be illustrated graphically as shown in Figure 4 [11].

Figure 4. GA block diagram

The following points describe GA implementation process:

1. Define the population size.

2. Make a Selection to mate individuals.

3. Every two individuals mating to generate progeny.

4. Mutation.

5. Inserting external individuals into original population.

6. Is the criteria satisfied?

7. Searching is finished.

The approach of tuning the gains via genetic algorithm starts with the definition of the chromosome representation. Each individual chromosome represented in in real valued form as shown in Figure 5, it is segregated to nine different values that correspond to the weight matrices Q and R of the linear quadratic (LQR) to be tuned to realize acceptable and reasonable performance. The diagram as blocks of the genetic algorithm with LQR controller of the plant which is Triple inverted pendulum is consisted of the optimum feedback gain K is shown in Figure 6 [11].

Figure 5. Chromosome identification

Figure 6. Block diagram of GA-LQR controller for the Triple inverted pendulum

5. GA-LQR Controller

The main contribution in this paper is to employ the genetic algorithm to find the LQR controller parameters Q and R. The vector that represent the control parameters that will be tuned and optimal selected are (q11,q22,q33,q44, q55, q66,q77,q88,R) to obtain optimum response in the output for the system and give best settling time (ts), rise time (tr), maximum overshoot (%MP) and steady state error (ess).The proposed Fitness function for the optimization of parameters of GA-LQR controller is defined as:

$F=\left(1-e^{-0.5}\right)\left(M_{p}+e_{S S}\right)+e^{-0.5}\left(t_{s}-t_{r}\right)$      (15)

This fitness function designed by the authors and the contribution for this work to find best performance.

where, $M_{p}$ : Max. Overshoot, $t_{r}$ : Rise Timing, $t s$ : Settling time, $e_{S S}$ : error in steady state.

The genetic algorithm parameters chosen for the tuning purpose are shown in Table 1. The main reason of the GA_LQR is to find the optimal values of Q and R for LQR.

Table 1. GA parameters

Genetic Algo. Properties

Number or method

Population Size

50

Generations in max

200

Selection approach

Geometric Selection in a normalized manner

Possibility of Selection

0.05

Crossover type

scattering

Possibility of Crossover

0.2

Mutation Technique

Uniform

Mutation Probability

0.01

6. Simulation Results

A Triple inverted pendulum system is simulated using LQR controller based on genetic algorithm. The weight matrix of GA-LQR controller Q and R are:

$Q=\left[\begin{array}{cccccccc}750 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 2500 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 2500 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 2500 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0.00389395 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0.0059744 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0.00761559 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0.0162112\end{array}\right]$

$R=0.999998$

The optimal feedback gain matrix K is:

$K=\left[\begin{array}{c}27.3862 \\ -104.8944 \\ 54.8264 \\ 148.6146 \\ 3.7285 \\ -0.8572 \\ 18.8153 \\ 13.9137\end{array}\right]^{T}$

The closed Loop poles for the GA-LQR controller are:

$P=\left[\begin{array}{c}-3.1165+\mathrm{i} 26.7811 \\ -3.1165-\mathrm{i} 26.7811 \\ -18.8979+\mathrm{i} 15.8910 \\ -18.8979-\mathrm{i} 15.8910 \\ -7.1022+\mathrm{i} 5.0083 \\ -7.1022-\mathrm{i} 5.0083 \\ -0.7608 \\ -3.8504\end{array}\right]$

The dc gain $\mathrm{M}$ can be obtained by $\left.H(s)\right|_{s=0} H(s)=$ $C(s I-(A-B K))^{-1} B \mathrm{M}=0.036488 .$

Boundary conditions or the upper and lower limits that the iteration and optimization techinques occure:

Lower boundary = [700; 2500; 2500; 2500; 0; 0; 0; 0; 0.8];

Upper boundary = [750; 3000; 3000; 3000; 0.1; 0.1; 0.1; 0.1; 1];

The value of pre gain N to improve the performance of the steady state error is equal to $N=\frac{1}{M}=\frac{1}{0.036488}=27.405861$.

N=(1/max(y(:,1))); (scaling factor).

Figure 7 illustrates the response for step input signal that represent three angles with cart position via using GA-LQR Controller.

The curve of the convergence part for each gain values for diagonal Q matrix and R plotted to give an idea how the genetic algorithm fluctuated to its final value as shown in Figure 8.

The time response specifications for the system under consideration equipped with the proposed controller are given in Table 2.

Figure 7. Step response of cart position using GA_LQR controller

Figure 8. Illustration of genetic algorithm converging through generations

Table 2. Performance characteristics for cart position and link angles

GA-LQR specifications

x

$\theta_{1}$

$\theta_{2}$

$\theta_{3}$

Settling Timets (Sec)

5.890

5.223

5.6628

5.7268

Rise Timetr (Sec)

2.7155

$1.55 \times 10^{-15}$

$1.642 \times 10^{-14}$

NaN

7. Conclusion

Dealing with multivariable, dynamic and unstable system is attracting control researchers to apply optimal control techniques to improve output response. Triple inverted pendulum is one of these systems that can be optimally controlled to stabilize their inverted links to be align in a vertical line. In this article, a combination of genetic algorithm with Linear quadratic controller approaches are successfully applied with reasonable results.

According to the findings, it can be concluded that the control scheme has been employed to balancing the three inverted links with the cart's position of the linearized system.

  References

[1] Atay, F.M. (1999). Balancing the inverted pendulum using position feedback. Applied Mathematics Letters, 12(5): 51-56. https://doi.org/10.1016/S0893-9659(99)00056-7

[2] Furut, K., Ochiai, T., Ono, N. (1984). Attitude control of a triple inverted pendulum. International Journal of Control, 39(6): 1351-1365. https://doi.org/10.1080/00207178408933251

[3] Aribowo, A.G., Nazaruddin, Y.Y., Joelianto, E., Sutarto, H.Y. (2007). Stabilization of Rotary Double Inverted Pendulum using robust gain-scheduling control. In SICE Annual Conference 2007, pp. 507-514. https://doi.org/10.1109/SICE.2007.4421037

[4] Yaren, T., Kizir, S. (2018). Stabilization control of triple pendulum on a cart. In 2018 6th International Conference on Control Engineering & Information Technology (CEIT), pp. 1-6. https://doi.org/10.1109/CEIT.2018.8751818

[5] Sehgal, S., Tiwari, S. (2012). LQR control for stabilizing triple link inverted pendulum system. In 2012 2nd International Conference on Power, Control and Embedded Systems, pp. 1-5. https://doi.org/10.1109/ICPCES.2012.6508052

[6] Hu, L.Y., Liu, G.P., Liu, X.P. (2010). Linear quadratic optimal algorithm for inverted pendulum system simulation and real-time control. Mechanical Design and Manufacturing, 47(1): 89-91.

[7] Xiong, X., Wan, Z. (2010). The simulation of double inverted pendulum control based on particle swarm optimization LQR algorithm. In 2010 IEEE International Conference on Software Engineering and Service Sciences, pp. 253-256. https://doi.org/10.1109/ICSESS.2010.5552427

[8] Barya, K., Tiwari, S., Jha, R. (2010). Comparison of LQR and robust controllers for stabilizing inverted pendulum system. In 2010 International Conference on Communication Control and Computing Technologies, pp. 300-304. https://doi.org/10.1109/ICCCCT.2010.5670570

[9] Siradjuddin, I., Setiawan, B., Fahmi, A., Amalia, Z., Rohadi, E. (2017). State space control using LQR method for a cart-inverted pendulum linearised model. International Journal of Mechanical and Mechatronics Engineering, 17(1): 119-126.

[10] Oliveira, P.S., Barros, L.S., Júnior, L.D.Q.S. (2010). Genetic algorithm applied to state feedback control design. In 2010 IEEE/PES Transmission and Distribution Conference and Exposition: Latin America (T&D-LA), pp. 480-485. https://doi.org/10.1109/TDC-LA.2010.5762925

[11] Magaji, N., Hamza, M.F., Dan-Isa, A. (2012). Comparison of GA and LQR tuning of static VAR compensator for damping oscillations. International Journal of Advances in Engineering & Technology, 2(1): 594.