LQR Based Type-2 Fuzzy Controller For Double Inverted Pendulum

DOI : 10.17577/IJERTV2IS60438

Text Only Version

LQR Based Type-2 Fuzzy Controller For Double Inverted Pendulum

Gaurav Malik*, M. J. Nigam

E & CE Department IIT Roorkee Roorkee, India

Abstract

The inverted pendulum system, which has been focused by control engineering, is among the most important and classical problems. While designing a fuzzy controller for such system, two main problems are controlled namely rule number explosion and uncertainty in the system. As remedy to these problems, a fusion function based on LQR control is applied before fuzzy controller that reduces number of inputs. The second problem uncertainty is taken care by type-2 fuzzy controller, as the degree of fuzziness is greater than conventional fuzzy controller. Therefore, both the schemes are combined to make the controller more efficient and robust. MATLAB simulation and comparison shows that the control effect is perfect.

Keywords- Fusion Function, Fuzzy Control, Double Inverted Pendulum (DIP), LQR Control, IT2FS, Uncertainty

1. Introduction

The inverted pendulum in control engineering is an important classical problem that reflects many crucial questions during its control process. This system is typically non-linear, complicated, high-ordered and highly uncertain. Here, we are using double inverted pendulum system, which has even more control targets that tests the controller on a higher level.

The advantage of using fuzzy logic bound system over classical control system is that they tend to have

smoother control, require little mathematical knowledge of model behavior, noise immunity and uncertainty handling. These use expert knowledge for obtaining results. Due to such characteristics, it has

become very popular in very short time. It is being used in vast area of research and applications that shows its versatility and power.

In general, we can say that uncertainty is caused by the lack of information i.e. incomplete, fragmentary, partially reliable, imprecise, vague and sometimes contradictory nature of information. Fuzzy reasoning allows us to handle this uncertainty. So, using type -1 fuzzy sets is a sensible option to use, when uncertainty is involved (Zadeh, 1975 [1]). However, using accurate membership function for something uncertain is not reasonable. So, to handle such uncertainties, type-2 fuzzy sets are used (Mendel, 2001 [2]). As we know that uncertainties cannot be separated from real systems, the research of novel methods to handle incomplete or less reliable information is of great interest (Mendel, 2001 [3]). This makes type-2 fuzzy logic controller as a good sensible choice.

It is not a trivial task to apply fuzzy control strategy to large-scale complex system. These require different and special approaches for modeling and control. An exponential increase in the number of control rules is observed with the increase in number of inputs. If we assume that we have t input variables and we have defined d fuzzy sets for each variable, then the total number of rules reaches to dt. This problem is referred as rule explosion problem.

Now, high number of controller input dimensions and excessive inference rule, reduces inference speed and correctness. So it becomes difficult to design and degrade controllers performance. The reduction of fuzzy controllers dimensions and number of fuzzy inference rules is of great research interest. To tackle this problem, Raju and Zhou [4, 5] used the idea of hierarchical structure in designing a fuzzy system, in

which the input variables are given to low dimensional fuzzy logic units (FLUs) and their outputs are fed as input variables to fuzzy logic units (FLUs) in next layer.

Joo [6] proposed a method where he considered the fuzzy rules as fuzzy rule vectors to convert the given multi input fuzzy system to two layered hierarchical fuzzy systems. In [7-10], using genetic algorithms, corr. parameters for the sensory fusion function method are found automatically. Fusion function can be achieved by many ways. In [11, 12], LQR gains are used to reduce the fuzzy controllers rule base and simultaneously importing LQR controllers features in the control action of a double inverted pendulum. Similarly, in [13] this idea was implemented to design a DSP chip based real-time motion control for rotary inverted pendulum system.

In our work, an attempt for the reduction of inference engine for large scale system is made by using a LQR based fusion function and it is combined with a type 2 fuzzy controller system such that the uncertainties in the model are well handled. Finally, a comparison has been made between our controller and LQR fuzzy controller by Wang and Sheng [12]. Paper is organized as mathematical Formulation of double inverted pendulum system in section 2, theory behind and procedure involved in design of fusion function based on LQR in section 3,basic theory of Interval type-2 fuzzy logic in section 4. In section 5, type-2 fuzzy controller design is described and results found are given with discussion in section 6. Finally, the conclusion and future work is proposed in section 7.

2. Formulation of double inverted pendulum system

The double inverted pendulum is a device that is composed of a cart on which the pendulum is fixed through a mounted shaft and the cart moves along a guided rail [14]. To measure the cart position, a photoelectric coder is installed at one end of the rail. Rotor shafts connect cart to the pendulum as well as both pendulums to each other and photoelectric coders at the connections measure the angles of upper and lower pendulum. The pendulums can move right and left on horizontal guide rail around respective motor shaft thus to make the inverted pendulum

stable at the vertical position. The schematic diagram of DIP and the notations used with their values are given below.

 M (mp1, mp2 , mj ) Carts mass (that includes first pole, second pole, joint) 5.8 kg (1.5kg, 0.5 kg, 0.75kg) p1, p 2 The angle made by pole 1(2) and vertical direction (rad) Lp1 (lp1 ), Lp2 (lp2 ) Length of pendulum first (2 lp1 ) and length of second pendulum (2 lp 2 ), 1m, 1.5m G Centre of gravity 9.8 m/s2 F Force applied to cart
 M (mp1, mp2 , mj ) Carts mass (that includes first pole, second pole, joint) 5.8 kg (1.5kg, 0.5 kg, 0.75kg) p1, p 2 The angle made by pole 1(2) and vertical direction (rad) Lp1 (lp1 ), Lp2 (lp2 ) Length of pendulum first (2 lp1 ) and length of second pendulum (2 lp 2 ), 1m, 1.5m G Centre of gravity 9.8 m/s2 F Force applied to cart

Figure 1: DIP schematic diagram Table1 : DIP Parameters

Lagrange equations are used to derive the equations of motion of the above system

i

i

d dL dL Q dt dqi dqi

Where L = T V is a Lagrangian, Q is a generalized force vector that acts in generalized coordinates qs direction. It is not taken in account for the formulation of kinetic energy T and potential energy

V. Kinetic and potential energies of the system are given by the sum of all the energies of carts and pendulums.

T 1 (m m m m )x2 ( 2 m l 2 2m l 2

Inverted Pendulums are usually following

2 c p1 p 2 j

3 p1 1

p 2 1

pproximations are used:

2m l 2 )2 1 m l 2 2

p3 1 p1 6 p 2 p 2 p 2

• (mp1lp1

• 2mp 2lp1

cos( p1 p 2 ) 1, sin( p1 p 2 ), cos( p1 ) cos( p 2 ) 1,

sin( p1 ) p1, sin( p 2 ) p 2

2mp3lp1 )xp1 cos p1 mp 2lp 2 xp 2 cos p 2

Linearization is made at balance position; so we get

2m l l

cos(

)

the LTI state space model [] as:

p 2 p1 p 2

p1 p 2

p1 p 2

x

0 0 0 0 0 0 x 0

V mp1glp1 cos p1 2mp3 glp1 cos p1

p1

0 0 0 0 0 0

p1 0

0 0 0 0 0 0

p 2 0

m g(2l

cos

• l cos )

p 2 u(t)

p 2 p1

p1 p 2 p 2

x 0 0 0 0 0 0 x 1

Using the equations above the Lagrangian L of the

0 14.2545

4.0090 0 0 0

1.1818

p1

p1

system is given as

0

14.2545 21.1077 0 0 0

0.1818

L 1 (m m m m )x2 ( 2 m l 2 2m l 2

p 2

p 2

x

2 c p1 p 2 j

3 p1 1

p 2 1

0

2m l 2 )2 1 m l 2 2

• (m l

• 2m l

p1 0

p3 1

p1 6

p 2 p 2 p 2

p1 p1

p 2 p1

y(t) diag.1 1 1 1 1 1

p 2 0

u(t)

2mp3lp1 )xp1 cos p1 mp 2lp 2 xp 2 cos p 2

x

0

2m l l cos( ) m gl cos

0

p 2 p1 p 2

p1 p 2

p1 p 2

p1 p1 p1

p1

2mp3 glp1 cos p1 mp 2 g(2lp1 cos p1 lp 2 cos p 2 )

0

p 2

Now the Lagrangian is differentiated by and

to yield Lagrange equation as given below

Throughout the paper this linearised model of double inverted pendulum is used.

d dL dt dp1

• dL 0

d p1

3. Design of fusion function based on LQR

d dL dL

Since we are going to use LQR control technique

or explicitly:

dt dp 2

0

d p 2

features in our controller which is applicable to linear state space model, so we define the state-space equations for our system.

( 4 m l 2 4m l 2 2m l 2 )

• (m l

• 2m l

X (t) AX (t) Bu(t)

3 p1 p1

p 2 p1

j p1 p1

p1 p1

p 2 p1

X (t) CX (t) Du(t)

2mjlp1 )xcos p1 2mp 2lp1lp 2p 2 cos( p1 p 2 )

Performance index J is chosen as

2m l l

2 sin(

) (m l

2m l 1

p 2 p1 p 2 p 2

p1 p 2

p1 p1

p 2 p1

J =

( XT (t)QX (t) uT (t)Ru(t))dt

2mjlp1 )g sin p1 0 2 0

m l xcos

2m l l

cos(

)

where Q and R are chosen to be positive semi-

p 2 p 2

1 m l 2

p 2 p 2 p1 p 2 p1

• 2m l l 2 sin(

p1 p 2

)

definite matrices. They determine the matrix K of the

optimal control vector

3 p 2 p 2 p 2

p 2 p1 p 2 p1

p1 p 2

u(t) KX (t)

mp 2lp 2 g sin p 2 0

A more compact matrix form of the Lagrange equation for the DICP system is given below D( ) C( ,) G( ) Hu

The stationary point of the system is given by

(x,p1,p2 , x,p1,p2 , x) (0,0,0,0,0,0,0).

Now introducing a small deviation around the stationary point and expanding it using Taylor series; also, in the stable control process of the Double

Minimizing the performance index J, the elements of matrix K are found. Then

u(t) KX (t) R1BT PX (t)

is optimal for any initial X(0) state. Where P is the solution of algebraic Riccati equation (given below) and K is the linear optimal feedback matrix. AT P PA PBR1BT P Q 0

Here, we have chosen as

Q diag([10 60 80 0 0 0]) and R 1

After solving, we get

K [10 275.2453 515.650216.2044 22.1046 111.9285]

Now, using this K matrix, a fusion function F(X) is constructed as suggested by Wang and Zheng [11]. It is described as

in the problems of real world. Zadeh proposed these sets in 1975, they are fuzzy-fuzzy sets in which the

1 Kp1

Kp 2

Kpn

0 0 0

F ( X )

0 0 0

K K K

K

p1

p1

p 2

p 2

pn

pn

n n

Where,

K (K

i1

)2 (K )2

pi pj

pi pj

j1

After solving, it comes out to be

F( X ) 0.01939 0.5338 1 0 0 0

0 0 0 0.14477 0.19749 1

Then, input variables dimensions are reduced. The error (E) and error change (EC) may be obtained by F ( X ) as :

EC

EC

E F ( X ) X T

Figure 2: Rule base reduction methods compared with d 5.

membership grades are itself type-1 fuzzy sets. These sets express the degree of uncertainty and non- determinist truth with which an element belongs to the whole set.

Since, our fusion function reduces the number of

inputs for the fuzzy controller to two, namely, error

If f (u) 1, u J u , J u [0,1]

p p p

p p p

(E) and error change (EC). We can formulate the number of rules i.e. d2. The Table (2) below shows

An interval type-2 fuzzy set (IT2FS) A can be

1

1

characterized as:

the comparison of different rule reduction methods. Table 2: Comparison of different reduction methods

A

uJ [0,1]

pP p

(x,u)

pP

[uJ [0,1] u

p

p

]

]

1

1

x

 Methods used to reduce the no. of rules The t 1 no. of variables Even Odd Sensory fusion d t /2 d (t 1)/ 2 Hierarchical (t 1).d 2 Combinational ((t / 2) 1).d 2 (((t 1) / 2) 1).d LQR-fusion d 2
 Methods used to reduce the no. of rules The t 1 no. of variables Even Odd Sensory fusion d t /2 d (t 1)/ 2 Hierarchical (t 1).d 2 Combinational ((t / 2) 1).d 2 (((t 1) / 2) 1).d LQR-fusion d 2

Where the primary variable p, has domain P; the

secondary variable u U ; has domain J at each

p

p P ; J is called the primary membership of p

p

and the secondary grades of A

are all equal to 1.

Clearly, means

A : P {[u,v]: 0 u v 1}.

4. Interval type-2 fuzzy logic

The usage of type-2 fuzzy sets provides us the advantage of handling the uncertainty and inaccuracy

Union of all the primary membership conveys uncertainty about A , which is also known as footprint of uncertainty (FOU) of A . The shaded area (Mendal, 2000) which is bounded by an upper and lower membership function as shown in figure below:

FOU( A ) = pP Jp {( p,u) : p Jp [0,1]}

Here, the upper membership function (UMF) and lower membership function (LMF) of A are type-1

membership function as shown in Figure 3.

B ( y)

M

Bl ( y)

M p

*

( p ) *

A i

A i

P1

( p ) *

Gl ( y)

i1

i1 i1

i

Fl i

Fl i

This can be depicted by the figure (4) below:

Figure 3: FOU (grey area) for IT2FS [15]

1. Type-2 fuzzy reasoning

A fuzzy system with M rules, n input variables and 1 output variable is assumed where antecedent and consequent are taken as type-2 fuzzy sets.

R1 : if p is F1 and and p is F1 , then y is G1.

Figure 4: IT2 fuzzy reasoning [16]

2. Type-2 rule based fuzzy logic system IT2FLC design which is based in interval type-2 fuzzy system has the structure same as conventional

fuzzy logic controller, except that a type reducer

1

H : p1 is

C : y is y.

1

Ap1 and and

n

pn is

n

Apn .

block between inference engine and defuzzifier blocks is added. The type reducer block converts the

type-2 fuzzy set output of inference engine to type-1

The reasoning evaluation is given below: The lth rule relation is

1

1

n

n

1

1

Rl Fl p pFl Gl Fl Gl AlGl

The fact relation is

A A p…pA A … A

fuzzy set before applying it to defuzzifier block for getting crisp output.

It has four principle components as shown in figure.

1. Fuzzifier Modifies inputs (crisp values) into corresponding fuzzy values.

p p1

pn p1 pn

2. Inference System- obtains a type-2 fuzzy

p

p

Bl A oRl , Generalized, fuzzy reasoning

output by applying fuzzy reasoning.

l ( y)

B ApoR

l ( y) P Ap ( p) Al Gl ( p, y)

3. Defuzzifier/ Type Reducer- defuzzifier modifies the output to crisp values while the

p

p

l ( y) l ( y)

( p ) l ( p ) l ( y), l ( y)

type reducer reduces a type-2 fuzzy set into

B G

where

i1

Api i

Fi i

B B

corresponding type-1 fuzzy set.

4. Knowledge Base- contains a rule base (set

Bl

* AP1 ( pi )* Fl ( pi )* Gl ( y)

p

i1

i

of fuzzy rules) and a database (set of

membership functions).

Bl

Bl

*

*

p

AP ( pi )*

AP ( pi )*

Fl ( pi ) *

Fl ( pi ) *

Gl ( y)

Gl ( y)

i1 1 i

Aggregation

M

M

p

B ( y)

i1

Bl ( y)

i1

Bl ( y)

i1

Api ( pi )

B ( y), B ( y)

Fl i

Fl i

Where ,

B ( y)

M

Bl ( y)

M p

*

A ( pi ) *

P

P

( p ) *

Gl ( y)

i1

i1 i1 1 i

Figure 5: IT2 FLC (Basic block schematics) [17]

5. Type-2 fuzzy controller design

The logic universe i.e., actual range of fuzzy controller input variables depends on controlled objects. Here, the basic universe of input variables, E and EC , is changed into fuzzy universe using quantization. Increase in the number of fuzzy sets, improves control accuracy but results in slower reasoning speed due to increased calculation. For design of type-2 fuzzy controller seven sets are

defined in fuzzy universe [ 30, 30] for error E ,

error change EC and control output u. These sets are described with linguistic variables NL (Negative Large), NM (Negative Medium), NS (Negative Small), Z (Zero), PS (Positive Small), PM (Positive Medium) and PL (Positive Large). The membership function describing fuzzy sets are shown in figure below:

Figure 6: Membership functions used in Type-1 FLC

Figure 7: Membership functions used in Type-2 FLC

The rule base for the type-1 and type-2 fuzzy controller is given below in the Table (3). As depicted from Table (3), a total of 49 rules are formulated to control the double inverted pendulum.

Table 3: Rule base for fuzzy controllers

The fuzzy control surface is shown below:

Figure 8: Non-linear control surface of FLCs

The schematic diagram of double inverted pendulum system with LQR based type-2 fuzzy controller in SIMULINK is shown in Figure (9) below. The block named as constant in the upper left corner gives the final position of the cart which can be changed.

Figure 9: Simulink diagram of DIP with LQR based type-2 FLC

1. Results

The design of the DIP system and LQR based Type-2 Fuzzy controller is tested in MATLABs Simulink environment [16]. The pendulum angles are measured as the deviation from vertical upright

position. There are scaling factors KE , KEC , KD

and

Ku . The factors are properly chosen to ensure proper working of the controller.

The plot given below shows the cart position, upper

and lower pendulum angles of double inverted pendulum under the initial states

x, p1, p2 ,p1,p2 0.1,0.1,0.1,0,0,0. under ideal

condition i.e. no external disturbance. It is noticed that the performance is exactly similar to LQR controller. Therefore, the fusion function just reduces the input dimensions of the controller and the controller part is modified form of LQR gain.

Figure 10: Simulation result of DIP with LQR based type-2 FLC

Next experiment compares the two fuzzy controllers

i.e. type-1 and type-2 fuzzy controllers, setup under ideal environment i.e. no external disturbance. Figure

(11) depicts less damping and lower overshoot , in case of IT2FLC.

Figure 11: Simulation results comparison of fuzzy controllers without disturbance for (a) position (b) angle of lower pendulum (c) angle of upper pendulum

In our last experiment, a disturbing force of 10N is applied to the cart at time t= 10sec, comparative results of the fuzzy controllers are shown in the fig. (12). Again, Type-2 fuzzy controller gives a better result; as the transients are little lower comparatively.

Figure 12: Simulation results comparison of fuzzy controllers with disturbance for (a) position (b) angle of lower pendulum (c) angle of upper pendulum

All the results indicate that the controller works successfully and efficiently as position of cart and both the angles of double inverted pendulum become stable well in time (approximately 4 seconds).

2. Conclusion and future work

For real time uncertain system, using a type -2 FLC obtained lower overshoot and better settling times. It can be concluded here that type-2 FLC could be a better choice for real world systems as uncertainty is an inherent part of the system and is not easy to estimate. To encounter the rule explosion problem, a fusion function based on LQR gain was successfully used in order to reduce the large fuzzy rule base of Type-2 fuzzy controller. This was applied to an approximate linear model and the results clearly show that this method has great performance, ability to resist disturbance and effective handling of model uncertainties.

REFERENCES

1. L. A. Zadeh, The Concept of a Linguistic Variable and Its Application to Approximate Reasoning1, Information Sciences, vol. 8, 1975, pp. 199-249.

2. N. N. Karnik and J. M. Mendel, Operations on Type-2 Fuzzy Sets, Fuzzy Sets and Systems, vol. 122, pp. 327-348, 2001.

3. J. M. Mendel, Uncertain Rule-Based Fuzzy Logic Systems: Introduction and New Directions, Prentice-Hall, Upper-Saddle River, NJ, 2001.

4. Raju, G. V. S., J. Zhou and R. A. Kisner, Hierarchical fuzzycontrol, Int.J. Contr., vol. 54, no. 5, 1991, pp. 1201-1216.

5. Raju, G. V. S. and Jun Zhou, Adaptive Hierarchical Fuzzy Controller, IEEE trans. on systems, man and cybernetics, vol. 23, no. 4, Jul. Aug.1993, pp. 973-980 .

6. Moon G. Joo, A method of converting conventional fuzzy logic system to 2 layered hierarchical fuzzy system, The IEEE International Conference on Fuzzy Systems, vol. 2, 2003, pp.1357-1362.

7. Ledeneva, Y., Automatic Estimation of Parameters to Reduce Rule Base of Fuzzy Control Complex Systems, Master thesis, INAOE Mexico, 2003.

8. Ledeneva, Y., Reyes Garcia, C. A., Automatic Estimation of Fusion Method Parameters to Reduce Rule Base of Fuzzy Control Complex Systems, In: Gelbukh A., et al. (Eds.): MICAI 2006, Springer-Verlag Berlin Heidelberg, LNAI 4293, pp. 146-155.

9. Ledeneva, Y., Reyes Garcia, C. A., Automatic Estimation of Parameters for the Hierarchical Reduction of Rules of Complex Fuzzy Controllers, In: Proceedings of ICINCO, France, 2007a, pp. 398401.

10. Ledeneva, Y., Reyes Garcia, C.A., Gelbukh,

1. and Garcia Hernandez, R.A., Genetic Optimization of the Parameters of Fuzzy Control Complex Systems, In: Torres S. et al (Eds.): CORE 2007, Research in Computing Science ISSN: 1870-4069, 2007, pp. 3748.

11. Lin Wang, Shifu Zheng, Xinping Wang and Liping Fan, Fuzzy Control of Double Inverted Pendulum Based on Information Fusion, IEEE International Conference on Intelligent Control and Information, Aug. 2010, pp. 327331.

12. Wang Luhao, Sheng Zhanshi, LQR-Fuzzy Control for Double Inverted Pendulum, IEEE Conference on Digital Manufacturing & Automation, vol.1, 2010, pp. 900-903.

13. Zheng Fang, Naixu Song and Liangyong Wang, Design and Implementation of a Novel Fuzzy Controller with DSP for Rotary Inverted Pendulum, IEEE Chinese Control and Decision Conference (CCDC), june 2009, pp. 6122-6127.

14. Shi, X., Zhang, Z., et al., Modeling and Application of a Double Inverted Pendulum, Journal of Hebei University of Technology, vol. 30(5), 2001, pp. 4851.

15. Oscar Castillo, Patricia Melin, Type-2 Fuzzy Logic: Theory and Applications Studies in Fuzziness and Soft Computing, springer verlag, Volume 223, 2008 ISBN 978-3-540-76283-6,pp.42-80, 128,144-155.

16. J. Morales, O. Castillo, J. Soria, Stability on Type-1 and Type-2 Fuzzy Logic Systems, springer-verlag, Soft Computing for Hybrid Intel. Systems, vol.154, 2008, pp. 29-51.

17. Yazmin Maldonado, Oscar Castillo and Patricia Melin, Optimal Design of Type-2 Fuzzy Controllers with a Multiple Objective Genetic Algorithm for FPGA Implementation, IEEE, 2011.

18. The Mathworks, Using Matlab version 7.10.0, The Mathworks, R2010a.