## Sliding Mode Control Using MATLAB

Sliding mode techniques are one approach to solving control problems and are ...... where the cart mass is M, the pendulum mass is m and the pendulum ...... [6] S.S. Ge, C.C. Hang, T.H. Lee, T. Zhang, Stable Adaptive Neural Network Control,.

Sliding Mode Control Using MATLAB

Sliding Mode Control Using MATLAB

Jinkun Liu Beihang University, Beijing, China

Sliding mode control MATLAB simulation basic theory and design method In the formulation of any control problem, there will typically be discrepancies between the actual plant and the mathematical model developed for controller design. This mismatch may be due to unmodelled dynamics, variation in system parameters or the approximation of complex plant behavior by a straightforward model. The engineer must ensure that the resulting controller has the ability to produce the required performance levels in practice despite such plant /model mismatches. This has led to intense interest in the development of robust control methods that seek to solve this problem. One particular approach to robust controller design is the sliding mode control methodology. One of the most intriguing aspects of sliding mode is the discontinuous nature of the control action, whose primary function of each of the feedback channels is to switch between two distinctively different system structures (or components) such that a new type of system motion, called the sliding mode, exists in a manifold. This peculiar system characteristic is claimed to result in superb system performance, which includes insensitivity to parameter variations, and complete rejection of disturbances. Sliding mode control is a particular type of variable structure control. In sliding mode control, the control system is designed to drive and then constrain the system state to lie within a neighborhood of the switching function. There are two main advantages to this approach. Firstly, the dynamic behavior of the system may be tailored by the particular choice of switching function. Secondly, the closed-loop response becomes totally insensitive to a particular class of uncertainty. The latter invariance property clearly makes the methodology an appropriate candidate for robust control. In addition, the ability to specify performance directly makes sliding mode control attractive from a design perspective. The sliding mode design approach consists of two components. The first involves the design of a switching function so that the sliding motion satisfies design specifications. The second is concerned with the selection of a control law that will make the switching function attractive to the system state. Note that this control law is not necessarily discontinuous. The chattering phenomenon is generally perceived as motion that oscillates about the sliding manifold. There are two possible mechanisms that produce such a motion. Firstly, in the absence of switching nonidealities such as delays, i.e., the switching device is switching ideally at an infinite frequency, the presence of parasitic dynamics in series with the plant causes a small amplitude high-frequency oscillation to appear in the neighborhood of the

xi

xii

Sliding mode control MATLAB simulation basic theory and design method

sliding manifold. These parasitic dynamics represent the fast actuator and sensor dynamics. Secondly, the switching nonidealities alone can cause such high-frequency oscillations. In this book, we aim to accomplish these objectives: G G

G G

Provide reasonable methods of the chattering phenomenon alleviating. Offer a catalogue of implementable robust sliding mode control design solutions for engineering applications. Provide advanced sliding mode controller design methods and their stability analysis. For each sliding mode control algorithm, we offer its simulation example and Matlab program.

This book provides the reader with a thorough grounding in sliding mode controller design. From this basis, more advanced theoretical results are developed. Typical sliding mode controller design is emphasized using Matlab simulation. In this book, concrete case studies, which present the results of sliding mode controller implementations, are used to illustrate the successful practical application of the theory. The book is structured as follows. Chapter 1, Basic sliding mode control principle and design, introduces the concept of sliding mode control and illustrates the attendant features of robustness and performance specification using a straightforward example and graphical exposition. Several typical sliding mode controllers for continuous system are introduced, and concrete stability analysis, simulation examples and Matlab programs are given. In Chapter 2, Sliding mode control with high performance, firstly an adaptive sliding mode control is introduced for mechanical systems with tanh function; to avoid a control input value that is too big, a projection algorithm is used. Secondly, the problem of tracking control with prescribed performance guarantees is considered, the error evolution within prescribed performance bounds in both problems of regulation and tracking. In Chapter 3, Sliding mode control based on a state observer, several kinds of state observer such as high gain observer, K observer, high gain differentiator, robust observer and separation theorem are introduced, and based on the different observer, sliding mode controller is designed. In Chapter 4, Sliding mode control based on disturbance and a delayed observer, an exponential disturbance observer, delayed output observer for linear system and delayed output observer for nonlinear system are introduced, and closed system stability and convergence are analyzed. In Chapter 5, Sliding mode control based on LMI, several kinds of sliding mode controller based on LMI technology are introduced, closed system stability and convergence are analyzed, and simulation examples are given.

Sliding mode control MATLAB simulation basic theory and design method

In Chapter 6, Sliding mode control based on the RBF neural network, firstly, a simple adaptive sliding mode control based on RBF is introduced, then an adaptive sliding mode control based on RBF compensation is discussed. Sliding mode control based on RBF neural network with minimum parameter learning method is introduced, and finally, a sliding mode controller based on RBF with MPL is introduced. In Chapter 7, Sliding mode control based on a fuzzy system, firstly, sliding mode control based on the fuzzy system approximation is introduced. Then, based on the fuzzy system with minimum parameter learning method, a sliding mode controller based on fuzzy system is designed. In Chapter 8, Sliding mode control of a class of underactuated systems, considering several kinds of underactuated system, sliding mode controllers are designed, and the Lyapunov function and the Hurwitz method are used to analyze closed system stability. In Chapter 9, Sliding mode control for underactuated system with decoupling algorithm, a general decoupling algorithm for underactuated system is introduced. With this decoupling algorithm, sliding mode control is designed, and the Lyapunov function and the Hurwitz method are used to analyze closed system stability. All the control algorithms are described separately and classified by chapter name; all the programs can be run successfully in MATLAB and can be downloaded via http://shi.buaa. edu.cn/liujinkun. If you have questions about algorithms and simulation programs, please contact the author at [email protected]uaa.edu.cn.

xiii

Chapter

1

Basic sliding mode control principle and design Sliding mode techniques are one approach to solving control problems and are an area of increasing interest. This book provides the reader with classical sliding mode control design examples, based on [1] and [2]. Variable Structure Control (VSC) with Sliding Mode Control (SMC) was first proposed and elaborated in early 1950s in the Soviet Union by Emelyanov and several coresearchers such as Utkins and Itkis [3]. During the last decades significant interest on VSC and SMC have been generated in the control research community. SMC has been applied including nonlinear system, multiinput multioutput (MIMO) systems, discrete-time models, large-scale and infinite-dimension systems, and stochastic systems. The most eminent feature of SMC is it is completely insensitive to parametric uncertainty and external disturbances during sliding mode [4]. Essentially, VSC utilizes a high-speed switching control law to drive the nonlinear plant’s state trajectory onto a specified and user-chosen surface in the state space, which is called the sliding or switching surface, and to maintain the plant’s state trajectory on this surface for all subsequent time. This surface is called the switching surface because if the state trajectory of the plant is “above” the surface, a control path has one gain and a different gain if the trajectory drops “below” the surface. During the process, the control system’s structure varies from one to another, thus earning the name VSC. To emphasize the important role of the sliding mode, the control is also called SMC [5]. In SMC, the system is designed to drive and then constrain the system state to lie within a neighborhood of the switching function. Its two main advantages are (1) the dynamic behavior of the system may be tailored

Sliding Mode Control Using MATLAB. DOI: http://dx.doi.org/10.1016/B978-0-12-802575-8.00001-1 Copyright © 2017 Tsinghua University Press Limited. Published by Elsevier Inc. All rights reserved.

1

2

CHAPTER 1 Basic sliding mode control principle and design

by the particular choice of switching function, and (2) the closed-loop response becomes totally insensitive to a particular class of uncertainty. Also, the ability to specify performance directly makes SMC attractive from the design perspective. Trajectory of a system can be stabilized by a sliding mode controller. After the initial reaching phase, the system states “slides” along the line s 5 0. The particular s 5 0 surface is chosen because it has desirable reduced-order dynamics when constrained to it. In this case, the s 5 cx1 1 x_1 ; c . 0. Surface corresponds to the first-order LTI system x_1 52cx1 , which has an exponentially stable origin. There are two steps in the SMC design. The first step is designing a sliding surface so that the plant restricted to the sliding surface has a desired system response. This means the state variables of the plant dynamics are constrained to satisfy another set of equations which define the so-called switching surface. The second step is constructing a switched feedback gains necessary to drive the plant’s state trajectory to the sliding surface. These constructions are built on the generalized Lyapunov stability theory. Now we give a simple sliding mode controller design example as follows.

1.1 A SIMPLE SLIDING MODE CONTROLLER DESIGN Consider a plant as € 5 uðtÞ 1 dðtÞ; J θðtÞ

ð1:1Þ

€ is the angle signal, uðtÞ is the control where J is the inertia moment, θðtÞ   input, dðtÞ is the disturbance and dðtÞ # η. Design the sliding mode function as sðtÞ 5 ceðtÞ 1 eðtÞ _

ð1:2Þ

where c must satisfy Hurwitz condition, c.0. The tracking error and its derivative value is _ 2 θ_ d ðtÞ _ 5 θðtÞ eðtÞ 5 θðtÞ 2 θd ðtÞ; eðtÞ

where θd ðtÞ is the ideal position signal. _ 5 0, and we From Eq. (1.2), we can see that if sðtÞ 5 0, then ceðtÞ 1 eðtÞ can get eðtÞ 5 eð0Þexpð2ctÞ. That is, when t-N, position tracking

1.1 A Simple Sliding Mode Controller Design 3

error and speed tracking error will tend to zero exponentially with c value. From Eq. (1.2), we have 1 € 2 θ€ d ðtÞ 5 ceðtÞ _ 1 eðtÞ € 5 ceðtÞ _ 1 θðtÞ _ 1 ðu 1 dðtÞÞ 2 θ€ d ðtÞ s_ðtÞ 5 ceðtÞ J

ð1:3Þ

and   1 s_s 5 s ce_ 1 ðu 1 dðtÞÞ 2 θ€ d : J

To guarantee s_s , 0, design the sliding mode controller as   1 uðtÞ 5 J 2ce_ 1 θ€ d 2 ðks 1 ηsgnsÞ J

ð1:4Þ

Define the Lyapunov function as 1 V 5 s2 : 2

We obtain   1 1 1 1 V_ 5 s_s 5 s 2ks 2 ηsgns 1 dðtÞ 5 ð2 ks2 2 ηjsj 1 sdðtÞÞ #2 ks2 : J J J J

Then we have V_ #2 2J kV. Use Lemma 1.3, choose α 5 2J k and f 5 0; we can obtain VðtÞ # e2Jkðt2t0 Þ Vðt0 Þ 2

If k is a positive constant value, VðtÞ will tend to zero exponentially with k value. In control law (1.4), the switch term ηsgns is a robust term, which is used to overcome dðtÞ. However, lager value of η may cause chattering of control input, how to eliminate the chattering is an important problem in SMC theory. Now we give a simulation example to explain, consider the plant as € 5 uðtÞ 1 dðtÞ; J θðtÞ

_ 5 0. where J 5 2; dðtÞ 5 sint, the initial states are θð0Þ 5 0; θð0Þ Choose the position ideal signal θd 5 1:0, use controller (1.4), choose c 5 10, η 5 1:1, and set k 5 0 and k 5 10, respectively. The results are shown in Figs. 1.11.6.

CHAPTER 1 Basic sliding mode control principle and design

1.4

1.2

Step response

1

0.8

0.6

0.4

0.2

0

0

5

10

15 time(s)

20

25

30

15

20

25

30

■ FIGURE 1.1 Position tracking with k 5 10.

120

100

80 Control input

4

60

40

20

0

–20 0

5

10

time(s)

■ FIGURE 1.2 Control input with k 5 10.

1.1 A Simple Sliding Mode Controller Design 5

10

8

de

6

4

2

0

–2 –1

–0.8

–0.6

–0.4

–0.2

0

0.2

0.4

e

■ FIGURE 1.3 Phase trajectory with k 5 10.

1.4

1.2

Step response

1

0.8

0.6

0.4

0.2

0

0

5

10

■ FIGURE 1.4 Position tracking with k 5 0.

15 time(s)

20

25

30

CHAPTER 1 Basic sliding mode control principle and design

1.5

1

Control input

0.5

0

–0.5

–1

–1.5

0

5

10

15 time(s)

20

25

30

■ FIGURE 1.5 Control input with k 5 0.

10

8

6

de

6

4

2

0

–2 –1

–0.8

–0.6

–0.4

–0.2 e

■ FIGURE 1.6 Phase trajectory with k 5 0.

0

0.2

0.4

1.1 A Simple Sliding Mode Controller Design 7

From the results, we can see that the gain k plays an important part, and the control chattering is caused by the term ηsgns. 1. Simulink main program: chap1_1sim.mdl

2. Controller: chap1_1ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 3;

8

CHAPTER 1 Basic sliding mode control principle and design

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 []; function sys 5 mdlOutputs(t,x,u) J 5 2; thd 5 u(1); th 5 u(2); dth 5 u(3); e 5 th 2 thd; de 5 dth; c 5 10; s 5 c*e 1 de; xite 5 1.1; k 5 0; %k 5 10; ut 5 J*(2 c*dth 2 1/J*(k*s 1 xite*sign(s))); sys(1) 5 ut;

3. Plant: chap1_1plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0;

1.2 Parameters Design of Sliding Mode Function

sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0,0]; str 5 []; ts 5 [0 0]; function sys 5 mdlDerivatives(t,x,u) J 5 2; dt 5 sin(t); ut 5 u(1); sys(1) 5 x(2); sys(2) 5 1/J*(ut 1 dt); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2);

4. Plot program: chap1_1plot.m close all; figure(1); plot(t,y(:,1),'r',t,y(:,2),'k:','linewidth',2); xlabel(‘time(s)');ylabel(‘Step response'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel(‘time(s)');ylabel(‘Control input'); c 5 10; figure(3); e 5 y(:,2) 2 y(:,1); de 5 y(:,3); plot(e,de,'r',e, 2 c'.*e,'k','linewidth',2); xlabel('e');ylabel('de');

1.2 PARAMETERS DESIGN OF SLIDING MODE FUNCTION For a nonlinear system x_ 5 f ðxÞ 1 gðxÞu 1 d; xARn ; uAR;

ð1:5Þ

a sliding variable can be designed as sðxÞ 5 CT x 5

n X i51

ci xi 5

n21 X

ci xi 1 xn ;

ð1:6Þ

i51

where x is a state vector, xi 5 xin21 ; i 5 1; . . .; n and C 5 ½c1 . . . cn21 1T .

9

10

CHAPTER 1 Basic sliding mode control principle and design

If sðxÞ-0, to guarantee xi -0, parameters c1 ; c2 ; . . .; cn21 should be selected so that the polynomial pn21 1 cn21 pn22 1 . . . c2 p 1 c1 is Hurwitz, where p is Laplace operator. For example, n 5 2; sðxÞ 5 c1 x1 1 x2 , to guarantee the polynomial p 1 c1 Hurwitz, the eigenvalue of p 1 c1 5 0 should has negative real part, i.e., c1 . 0. For another example, n 5 3; sðxÞ 5 c1 x1 1 c2 x2 1 x3 , to guarantee the polynomial p2 1 c2 p 1 c1 Hurwitz, the eigenvalue of p2 1 c2 p 1 c1 5 0 should has negative real part. For λ . 0 in ðp1λÞ2 5 0, we can get p2 1 2λp 1 λ2 5 0. Therefore, we have c2 5 2λ; c1 5 λ2 .

1.3 SLIDING MODE CONTROL BASED ON REACHING LAW Sliding mode based on reaching law include reaching phase and sliding phase. The reaching phase drive system to stable manifold, the sliding phase drive system slide to equilibrium. The idea of sliding mode can be described as Fig. 1.7.

x2

Sliding manifold

x1

■ FIGURE 1.7 The idea of sliding mode.

1.3 Sliding Mode Control Based on Reaching Law

Four kind of classical reaching laws are given as follows [6]: 1. Reaching law with constant rate s_ 5 2εsgns;

ε . 0;

ð1:7Þ

where ε represents a constant rate. This law forces the switching variable to reach the switching manifold s at a constant rate ε. The merit of this reaching law is its simplicity. But, as will be shown later, if ε is too small, the reaching time will be too long. On the other hand, too large ε will cause severe chattering. 2. Exponential reaching law s_ 5 2εsgns 2ks

ε . 0; k . 0;

ð1:8Þ

where s_ 5 2 ks is an exponential term, and its solution is s 5 sð0Þe2kt . Clearly, by adding the proportional rate term 2ks, the state is forced to approach the switching manifolds faster when s is larger. If we use exponential reaching law to design SMC controller, define the Lyapunov function as V 5 12 s2 , then we can get V_ # 2εjsj 2 ks2 5 2 2k V 2 εjsj # 2 2k V. Using Lemma 1.1 to solve the equation V_ # 2 2k V, set α 5 2k ; f 5 0; we can get VðtÞ # e22ðt2t0 Þ Vðt0 Þ: k

If k is positive constant value, VðtÞ will tend to zero exponentially with k value. In the exponential reaching law, to guarantee faster convergence speed, especially when s is near to zero, the term s_52εsgnðsÞ is used. Moreover, to reduce chattering, we should design a bigger value of k and use a smaller value of ε. 3. Reaching law with power rate s_ 5 2 kjsjα sgns

k . 0; 1 . α . 0:

ð1:9Þ

This reaching law increases the reaching speed when the state is far away from the switching manifold, but reduces the rate when the state is near the manifold. The result is a fast reaching and low chattering reaching mode. 4. General reaching law s_ 5 2εsgns 2f ðsÞ

ε . 0;

ð1:10Þ

where f ð0Þ 5 0, and when s 6¼ 0; sf ðsÞ . 0. Obviously, the above four reaching laws can satisfy the sliding mode arrived condition s_s , 0.

11

12

CHAPTER 1 Basic sliding mode control principle and design

1.4 ROBUST SLIDING MODE CONTROL BASED ON REACHING LAW 1.4.1 System description The plant is € 5 f ðx; tÞ 1 buðtÞ 1 dðtÞ; xðtÞ

ð1:11Þ

where f ðx; tÞ and b are known and b . 0; dðtÞ; dðtÞ is unknown disturbance, dðtÞ # D.

1.4.2 Controller design The sliding mode function is _ sðtÞ 5 ceðtÞ 1 eðtÞ;

ð1:12Þ

where c must satisfy the Hurwitz condition, c . 0. The tracking error and its derivative value is _ 5 x_d 2 x_1 ; e 5 xd 2 x1 ; eðtÞ

where x1 5 x; xd is ideal position signal. Therefore, we have _ 1 eðtÞ € 5 cðx_d 2 x_1 Þ 1 ðx€d 2 xÞ € s_ 5 ceðtÞ : 5 cðx_d 2 x_1 Þ 1 ðx€d 2 f 2 bu 2 dÞ

ð1:13Þ

Adopting the exponential reaching law, we have s_ 5 2 εsgns 2 ks

ε . 0; k . 0:

ð1:14Þ

From Eqs. (1.13) and (1.14), we have cðx_d 2 x_1 Þ 1 ðx€d 2 f 2 bu 2 dÞ 5 2 εsgns 2 ks:

If we design the sliding mode controller as 1 uðtÞ 5 ðεsgns 1 ks 1 cðx_d 2 x_1 Þ 1 x€d 2 f 2 dÞ: b

ð1:15Þ

Obviously, all quantities on the right-hand side of (1.15) are known except the disturbance d, which is unknown. Thus control law (1.15) cannot be realized. Design the sliding mode controller as uðtÞ 5

1 ðεsgns 1 ks 1 cðx_d 2 x_1 Þ 1 x€d 2 f 1 DsgnsÞ: b

ð1:16Þ

Substituting Eq. (1.16) into Eq. (1.13) and simplifying the result, we have s_ðtÞ 5 2 εsgns 2 ks 2 Dsgns 2 d:

ð1:17Þ

1.4 Robust Sliding Mode Control Based on Reaching Law

We then get s_sðtÞ 5 sð2εsgns 2 ks 2 Dsgns 2 dÞ 5 2 ks2 2 εjsj 2 Djsj 2 ds:

Define the Lyapunov function as V 5 12 s2 , then we can get V_ 5 s_sðtÞ 5 2 ks2 2 εjsj 2 Djsj 2 ds # 2 2kV:

Using Lemma 1.3, we have VðtÞ # e22kt Vð0Þ:

We can see that the sliding mode function sðtÞ will tend to zero exponentially with k value.

1.4.3 Simulation example Consider the plant as € 5 f ðx; tÞ 1 buðtÞ 1 dðtÞ; xðtÞ

_ b 5 133 and dðtÞ 5 10sinðπtÞ. where f 5 225x; Choose the ideal position signal xd 5 sint, set the initial states as  20:15 20:15 , use controller (1.16), set c 5 15; ε 5 0:5; k 5 10; D 5 10:1, the results can be seen in Figs 1.81.10.

Position tracking

2 Ideal position signal Position tracking

1

0

–1

0

5

10

15

time(s)

Speed tracking

4 Ideal speed signal Speed tracking

2

0

–2

0

5

10 time(s)

■ FIGURE 1.8 Position and Speed tracking.

15

13

14

CHAPTER 1 Basic sliding mode control principle and design

0.5 0.4

Control input

0.3 0.2 0.1 0 –0.1 –0.2 –0.3

0

5

10

15

time(s) ■ FIGURE 1.9 Control input.

1.5 1 0.5

de

0 –0.5 –1 –1.5 –2 –2.5 –0.02 ■ FIGURE 1.10 Phase trajectory.

0

0.02

0.04

0.06

0.08 e

0.1

0.12

0.14

0.16

0.18

1.4 Robust Sliding Mode Control Based on Reaching Law

1. Simulink main program: chap1_2sim.mdl

2. Controller: chap1_2ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes);

15

16

CHAPTER 1 Basic sliding mode control principle and design

x0 5 []; str 5 []; ts 5 []; function sys 5 mdlOutputs(t,x,u) xd 5 u(1); dxd 5 cos(t); ddxd 5 2 sin(t); x1 5 u(2); dx1 5 u(3); c 5 15; e 5 xd 2 x1; de 5 dxd 2 dx1; s 5 c*e 1 de; fx 5 2 25*dx1;b 5 133; D 5 10.1; epc 5 0.5;k 5 10; ut 5 1/b*(epc*sign(s) 1 k*s 1 c*de 1 ddxd 2 fx 1 D*sign(s)); sys(1) 5 ut; sys(2) 5 e; sys(3) 5 de;

3. Plant: chap1_2plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 1;

1.5 Sliding Mode Control Based on a Quasi-sliding Mode

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [2 0.15 2 0.15]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) sys(1) 5 x(2); sys(2) 5 2 25*x(2) 1 133*u 1 10*sin(pi*t); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2);

4. Plot: chap1_2plot.m close all; figure(1); subplot(211); plot(t,y(:,1),'k',t,y(:,2),'r:','linewidth',2); legend('Ideal position signal','Position tracking'); xlabel('time(s)');ylabel('Position tracking'); subplot(212); plot(t,cos(t),'k',t,y(:,3),'r:','linewidth',2); legend('Ideal speed signal','Speed tracking'); xlabel('time(s)');ylabel('Speed tracking'); figure(2); plot(t,u(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('Control input'); c 5 15; figure(3); plot(e,de,'k',e, 2 c'.*e,'r','linewidth',2); xlabel('e');ylabel('de');

1.5 SLIDING MODE CONTROL BASED ON A QUASI-SLIDING MODE Consider the plant as € 5 f ðx; tÞ 1 buðtÞ 1 dðtÞ: xðtÞ

ð1:18Þ

Use controller (1.16) in Section 1.4 as follows: 1 uðtÞ 5 ðεsgns 1 ks 1 cðx_d 2 x_1 Þ 1 x€d 2 f 1 DsgnsÞ; b

ð1:19Þ

17

18

CHAPTER 1 Basic sliding mode control principle and design

where   f ðx; tÞ and b are known and b . 0; dðtÞ is unknown disturbance, dðtÞ # D. In sliding mode controller, due to the switch term εsgns, the chattering can be caused, especially for a large disturbance, which will damage to system components such as actuators. One way to alleviate the chattering is to use quasi-sliding mode method, which can make the state stay in a certain range at W neighborhood. Often we name W as the boundary layer. Instead of the sign function, in continuous system, there are commonly two methods for quasi-sliding mode design. 1. Saturation function 8 s.Δ > > T 1 k1 5 3 > > > > < 3k1 3 : 1 2 1 k2 5 3 > T T > > > > > 3 3 > 1 : 1 k3 1 2 k1 1 k2 5 1 T3 T T

We can then obtain 8 > > k1 5 3 2 > > > > > < k2 5 3 2 > > > > > > > : k3 5 1 2

3 T 3k1 3 2 2 T T

:

ð3:19Þ

1 3 3 2 2 k1 2 k2 3 T T T

3.2.3 Sliding mode control based on a K observer The control object is that x1 tracking xd , x2 tracking x_d by using x1 only. Define e 5 x1 2 x1d , and design sliding mode function as € s 5 c1 e 1 c2 e_ 1 e;

where c1 and c2 must designed so that c1 1 c2 σ 1 σ2 5 0 is Hurwitz.

63

64

CHAPTER 3 Sliding mode control based on a state observer

Define αðxÞ 5 2

1 3 3 x1 2 2 x2 2 x3 , and design sliding mode controller as T3 T T 1 x1d Þ; uðtÞ 5 ð2c1 e^_ 2 c2 e^€ 2 αð^xÞ 2 η^s 1___ b

ð3:20Þ

€^ αð^xÞ 5 2 1 x^1 2 3 x^2 2 3 x^3 . where e^ 5 x^1 2 x1d , s^ 5 c1 e^ 1 c2 e_^ 1 e, T3 T2 T Then s_ 5 c1 e_ 1 c2 e€ 1___ e 5 c1 e_ 1 c2 e€ 1 x_3 2___ x1d x1d 5 c1 e_ 1 c2 e€ 1 αðxÞ 1 bu 2___ ; x1d 2___ 5 c1 e_ 1 c2 e€ 1 αðxÞ 2 c1 e^_ 2 c2 e^€ 2 αð^xÞ 2 η^s 1___ x1d 5 2 η^s 1 vð~xÞ 1 αðxÞ 2 αð^xÞ

^€ where vð~xÞ 5 c1 e_ 1 c2 e€ 2 c1 e^_ 2 c2 e. Design the Lyapunov function as V 5

1 2 s , then 2

V_ 5 s_s 5 2 ηs^s 1 sðvð~xÞ 1 αðxÞ 2 αð^xÞÞ 5 2 ηsðs 2 s~Þ 1 sðvð~xÞ 1 αðxÞ 2 αð^xÞÞ 5 2 ηs2 1 sðη~s 1 vð~xÞ 1 αðxÞ 2 αð^xÞÞ ; 1 5 2 ηs2 1 sf ð~xÞ # 2 ηs2 1 ðs2 1 f ð~xÞ2 Þ 2 5 2 ðη 2 0:5Þs2 1 0:5f ð~xÞ2 5 2 η1 V 1 0:5f ð~xÞ2

where η1 5 2η 2 1 . 0, s~ 5 s 2 s^, f ð~xÞ 5 η~s 1 vð~xÞ 1 αðxÞ 2 αð^xÞ. Since e 2 e^ 5 x~1 , e_ 2 e^_ 5 x~2 , e€ 2 e^€ 5 x~3 , then s~ 5 s 2 s^ 5 c1 x~1 1 c2 x~2 1 x~3 ~ 5 c1 e_ 1 c2 e€ 2 c1 e^_ 2 c2 e^€ 5 c1 x~2 1 c2 x~3 vðxÞ 1 3 3 1 3 3 x1 2 2 x2 2 x3 1 3 x^1 1 2 x^2 1 x^3 T3 T T T T T 1 3 3 5 2 3 x~1 2 2 x~2 2 x~3 T T T

^ 52 αðxÞ 2 αðxÞ

and  1 f ð~xÞ 5 η~s 1 vð~xÞ 1 αðxÞ 2 αð^xÞ 5 ηc1 2 3 x~1 T   3 3 1 ηc2 2 2 1 c1 x~2 1 η 2 1 c2 x~3 : T T

From Eq. (3.18), we can obtain V_ # 2 η1 V 1 0:5f ð~xÞ2 # 2 η1 V 1 χðdÞexpð2 σ0 ðt 2 t0 ÞÞ;

where χðdÞ is a K-class function of jj~xðt0 Þjj.

3.2 Sliding Mode Control Based on the K Observer for a High Order System

Using Lemma 1.3, the solution of V_ # 2η1 V 1 χðdÞexpð2 σ0 ðt 2 t0 ÞÞ is VðtÞ # expð2 η1 ðt 2 t0 ÞÞVðt0 Þ 1 χðdÞ

ðt

expð2 η1 ðt 2 τÞÞexpð2 σ0 ðτ 2 t0 ÞÞdτ ðt 5 expð2 η1 ðt 2 t0 ÞÞVðt0 Þ 1 χðdÞexpð2 η1 t 1 σ0 t0 Þ expðη1 τÞexpð2 σ0 τÞdτ t0

t0

χðdÞ expð2 η1 t 1 σ0 t0 Þexpððη1 2 σ0 ÞτÞjtt0 5 expð2 η1 ðt 2 t0 ÞÞVðt0 Þ 1 η1 2 σ0 χðdÞ 5 expð2 η1 ðt 2 t0 ÞÞVðt0 Þ 1 expð2 η1 t 1 σ0 t0 Þðexpððη1 2 σ0 ÞtÞ η1 2 σ0 2 expðη1 2 σ0 Þt0 Þ χðdÞ 5 expð2 η1 ðt 2 t0 ÞÞVðt0 Þ 1 ðexpð2 σ0 ðt 2 t0 ÞÞ 2 expð2 η1 ðt 2 t0 ÞÞÞ η1 2 σ0

Therefore, VðtÞ converge to zero exponentially as t-N, and the convergence precision is related to η1 and η.

3.2.4 Simulation example

  For plant (3.12), K 5 0:2, T 5 18:5, the initial states are 0:5 0 0 , and the ideal signal is sint.  T Using observers (3.15) and (3.16), k 5 k1 k2 k3 is designed by Eq. (3.19), and using observer (3.20), η 5 0:50, c1 5 c2 5 5, simulation results are shown in Figs. 3.43.6.

thd and y

2

dthd and dy

–2

ddthd and ddy

ideal position position tracking

0

0

2

4

6

8

10 12 Time(s)

14

16

18

20

2 ideal speed speed tracking

0 –2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

10 ideal acceleration acceleration tracking

0 –10

0

2

4

6

8

10 12 Time(s)

■ FIGURE 3.4 Position, speed, and acceleration tracking.

14

16

18

20

:

65

x3 and its estimate

x2 and its estimate

x1 and its estimate

CHAPTER 3 Sliding mode control based on a state observer

2 ideal x1 estimation of x1

0 –2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

5 ideal x2 estimation of x2

0 –5

0

2

4

6

8

10 12 Time(s)

14

16

18

20

10 ideal x3 estimation of x3

0 –10

0

2

4

6

8

10 12 Time(s)

14

16

18

20

■ FIGURE 3.5 Estimation of position, speed, and acceleration signal.

1.5

x 106

1 0.5

Control input

66

0 –0.5 –1 –1.5 –2 –2.5

0

2

4

■ FIGURE 3.6 Control input.

6

8

10 Time(s)

12

14

16

18

20

3.2 Sliding Mode Control Based on the K Observer for a High Order System

Simulation Programs:

1. Simulink main program: chap3_2sim.mdl

2. S function of Controller: chap3_2ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {1,2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 0; 5 0; 5 1; 5 4;

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0

5 [];

67

68

CHAPTER 3 Sliding mode control based on a state observer

str 5 []; ts

5 [];

function sys 5 mdlOutputs(t,x,u) c1 5 5; c2 5 5; yd 5 u(1); dyd 5 cos(t); ddyd 5 2 sin(t); dddyd 5 2 cos(t); x1 5 u(2); x2 5 u(3); x3 5 u(4); e 5 x1 2 yd; de 5 x2 2 dyd; dde 5 x3 2 ddyd; s 5 c1*e 1 c2*de 1 dde; v 5 2 dddyd 1 c1*de 1 c2*dde; T 5 18.5;K 5 0.2; b 5 K/(T^3); alfa 5 2 1/(T^3)*x1 2 3/(T^2)*x2 2 3/T*x3; xite 5 0.50; ut 5 2 1/b*(v 1 alfa 1 xite*s); sys(1) 5 ut;

3. S function of observer: chap3_2kobv.m function [sys,x0,str,ts] 5 obv(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes;

3.2 Sliding Mode Control Based on the K Observer for a High Order System

5 6;

sizes.NumContStates

5 0;

sizes.NumDiscStates

5 3;

sizes.NumOutputs sizes.NumInputs

5 4;

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0

5 [0;0;0;0;0;0];

str 5 []; ts

5 [0 0];

function sys 5 mdlDerivatives(t,x,u) w 5 [x(1) x(2) x(3)]'; v 5 [x(4) x(5) x(6)]'; x1 5 u(1); ut 5 u(4); T 5 18.5;K 5 0.20; A 5 [0 1 0; 0 0 1; 2 1/T^3 2 3/T^2 2 3/T]; k1 5 30 2 3/T; k2 5 300 2 3*k1/T 2 3/T^2; k3 5 1000 2 1/T^3 2 3/T^2*k1 2 3/T*k2; k 5 [k1 k2 k3]'; c 5 [1 0 0]; A0 5 A 2 k*c; e4 5 [0 0 1]'; dw 5 A0*w 1 k*x1; dv 5 A0*v 1 e4*ut; sys(1) 5 dw(1); sys(2) 5 dw(2); sys(3) 5 dw(3); sys(4) 5 dv(1); sys(5) 5 dv(2); sys(6) 5 dv(3); function sys 5 mdlOutputs(t,x,u) T 5 18.5;K 5 0.20; b 5 K/T^3; w 5 [x(1) x(2) x(3)]'; v 5 [x(4) x(5) x(6)]';

69

70

CHAPTER 3 Sliding mode control based on a state observer

xp 5 w 1 b*v; sys(1) 5 xp(1); sys(2) 5 xp(2); sys(3) 5 xp(3);

4. S function of plant: chap3_2plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; 5 3;

sizes.NumContStates

5 0;

sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 3; 5 1;

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0.5,0,0]; str 5 []; ts 5 [ 2 1 0]; function sys 5 mdlDerivatives(t,x,u) T 5 18.5; K 5 0.20; sys(1) 5 x(2); sys(2) 5 x(3); sys(3) 5 2 1/(T^3)*x(1) 2 3/(T^2)*x(2) 2 3/T*x(3) 1 K/(T^3) *u(1); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

3.3 Sliding Mode Control Based on a High Gain Differentiator

5. Plot program: chap3_2plot.m close all; figure(1); subplot(311); plot(t,y(:,1),'k',t,y(:,2),'r:','linewidth',2); xlabel('time(s)');ylabel('thd and y'); legend('ideal position','position tracking'); subplot(312); plot(t,cos(t),'k',t,y(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('dthd and dy'); legend('ideal speed','speed tracking'); subplot(313); plot(t, 2 sin(t),'k',t,y(:,4),'r:','linewidth',2); xlabel('time(s)');ylabel('ddthd and ddy'); legend('ideal acceleration','acceleration tracking'); figure(2); subplot(311); plot(t,y(:,2),'k',t,y1(:,1),'r:','linewidth',2); xlabel('time(s)');ylabel('x1 and its estimate'); legend('ideal x1','estimation of x1'); subplot(312); plot(t,y(:,3),'k',t,y1(:,2),'r:','linewidth',2); xlabel('time(s)');ylabel('x2 and its estimate'); legend('ideal x2','estimation of x2'); subplot(313); plot(t,y(:,4),'k',t,y1(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('x3 and its estimate'); legend('ideal x3','estimation of x3'); figure(3); plot(t,ut(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('Control input');

3.3 SLIDING MODE CONTROL BASED ON A HIGH GAIN DIFFERENTIATOR 3.3.1 System description Consider a plant as GðsÞ 5

K ; ðTs11Þ3

ð3:21Þ

71

72

CHAPTER 3 Sliding mode control based on a state observer

where K is gain and T is time constant. Eq. (3.21) can be expressed as x_ ðtÞ 5 AxðtÞ 1 HuðtÞ;

2

 where x 5 x1  H5 0 0

x2

K T3

x3

T

T

0 6 , A 5 4 01 2 3 T

1 0 3 2 2 T

ð3:22Þ

3

0 1 7 3 5, 2 T

.

Eq. (3.22) can also be written as x_1 5 x2 ; x_2 5 x3 x_3 5 αðxÞ 1 bu

where αðxÞ 5 2

ð3:23Þ

1 3 3 K x1 2 2 x2 2 x3 , b 5 3 . T3 T T T

The control goal is as t-N, x1 -x1d , x_1 -x_1d , x€ 1 -x€ 1d . For the model in Eq. (3.23), the design sliding mode function is € s 5 c1 e 1 c2 e_ 1 e;

ð3:24Þ

where c1 . 0, c2 . 0, e 5 x1 2 x1d .

3.3.2 Traditional sliding mode control s_ 5 c1 e_ 1 c2 e€ 1___ e 5 c1 e_ 1 c2 e€ 1___ x1 2___ x1d : x1d 5 c1 e_ 1 c2 e€ 1 αðxÞ 1 bu 2___

Design the traditional sliding mode controller as uðtÞ 5

1 ð2 c1 e_ 2 c2 e€ 2 αðxÞ 2 ηsgns 1___ x1d Þ; b

ð3:25Þ

where η . 0. 1 2 s , then V_ 5 s_s 5 2 ηjsj # 0. 2 From Eq. (3.25), we know that a speed signal and acceleration signal are needed in the controller, which is difficult in practical engineering. The Lyapunov function is V 5

3.3.3 High gain differentiator design Three rank differentiator with a high gain can be designed as [3,4]

3.3 Sliding Mode Control Based on a High Gain Differentiator

k1 ðx^1 2 x1 ðtÞÞ ε k2 x^_ 2 5 x^3 2 2 ðx^1 2 x1 ðtÞÞ ; ε k3 x^_ 3 5 2 3 ðx^1 2 x1 ðtÞÞ ε x^_ 1 5 x^2 2

ð3:26Þ

where k1 , k2 , and k3 are positive values and ε{1. k1 k2 k2 Define h1 5 , h2 5 2 and h3 5 3 ; we then have ε ε ε x_~ 1 5 x~2 2 h1 x~1 x_~ 2 5 x~3 2 h2 x~1 ; x_~ 3 5 2 h3 x~1

where x~ 5 x 2 x^ .

2

3 2 3 2h1 1 0 x~1 Eq. (3.27) can be written as x_~ 5 A~x, A 5 4 2h2 0 1 5, x~ 5 4 x~2 5. If 2h3 0 0 x~3 we design A as Hurwitz, we can get the convergence of x~ as jj~xðtÞjj # ϕ0 jj~xðt0 Þjje2σ0 ðt2t0 Þ ;

ð3:27Þ

where ϕ0 and σ0 are positive constants. Eq. (3.27) indicates that the convergence precision of jj~xðtÞjj is related to σ0 . Consider σ0 is related to the minimum eigenvalue of A; the smaller the ε value is, the bigger the hi value is, then the smaller the minimum eigenvalue of A is, the bigger the σ0 value is. Therefore, the convergence of jj~xðtÞjj depends on ε, and a high gain observer will improve the convergence precision of jj~xðtÞjj greatly. To guarantee A to be Hurwitz, the characteristic equation of x_~ 5 A~x is 2 3 λ 1 h1 21 0 jλI 2 Aj 5 4 h2 λ 21 5 5 0, i.e., λ3 1 h1 λ2 1 h2 λ 1 h3 5 0. 0 λ h3 Consider ε{1, if we choose ðλ1100Þ3 5 0, i.e., λ3 1 300λ2 1 30; 000λ 1 1; 000; 000 5 0, consider λ3 1 h1 λ2 1 h2 λ 1 h3 5 0, we can design h1 5 300, h2 5 30; 000, h3 5 1; 000; 000, i.e., k1 5 εh1 , k2 5 ε2 h2 , k3 5 ε3 h3 .

3.3.4 Sliding mode control based on a high gain differentiator Using a high gain differentiator, the sliding mode controller can be designed as 1 ^ 2 η^s 1___ uðtÞ 5 ð2 c1 e^_ 2 c2 e^€ 2 αðxÞ x1d Þ; b

ð3:28Þ

73

74

CHAPTER 3 Sliding mode control based on a state observer

€^ where e^ 5 x^1 2 x1d and s^ 5 c1 e^ 1 c2 e_^ 1 e. Then s_ 5 c1 e_ 1 c2 e€ 1___ e 5 c1 e_ 1 c2 e€ 1 x_3 2___ x1d x1d 5 c1 e_ 1 c2 e€ 1 αðxÞ 1 bu 2___ ; x1d 2___ 5 c1 e_ 1 c2 e€ 1 αðxÞ 2 c1 e^_ 2 c2 e^€ 2 αð^xÞ 2 η^s 1___ x1d 5 2 η^s 1 vð~xÞ 1 αðxÞ 2 αð^xÞ

^€ where vð~xÞ 5 c1 e_ 1 c2 e€ 2 c1 e^_ 2 c2 e. Design the Lyapunov function as V 5

1 2 s , then 2

V_ 5 s_s 5 2 ηs^s 1 sðvð~xÞ 1 αðxÞ 2 αð^xÞÞ 5 2 ηsðs 2 s~Þ 1 sðvð~xÞ 1 αðxÞ 2 αð^xÞÞ 5 2 ηs2 1 sðη~s 1 vð~xÞ 1 αðxÞ 2 αð^xÞÞ ; 1 2 2 2 2 5 2 ηs 1 sf ð~xÞ # 2 ηs 1 ðs 1 f ð~xÞ Þ 2 5 2 ðη 2 0:5Þs2 1 0:5f ð~xÞ2 5 2 η1 V 1 0:5f ð~xÞ2

where η1 5 2η 2 1 . 0, 1 αðxÞ 2 αð^xÞ.

x~ 5 x 2 x^ ,

s~ 5 s 2 s^,

f ð~xÞ 5 η~s 1 vð~xÞ

Since e 2 e^ 5 x~1 , e_ 2 e^_ 5 x~2 , e€ 2 e^€ 5 x~3 , then s~ 5 s 2 s^ 5 c1 x~1 1 c2 x~2 1 x~3 ~ 5 c1 e_ 1 c2 e€ 2 c1 e^_ 2 c2 e^€ 5 c1 x~2 1 c2 x~3 vðxÞ 1 3 3 1 3 3 x1 2 2 x2 2 x3 1 3 x^1 1 2 x^2 1 x^3 T3 T T T T T ; 1 3 3 5 2 3 x~1 2 2 x~2 2 x~3 T T T

^ 52 αðxÞ 2 αðxÞ

then   1 3 f ð~xÞ 5 η~s 1 vð~xÞ 1 αðxÞ 2 αð^xÞ 5 ηc1 2 3 x~1 1 ηc2 2 2 1 c1 x~2 T T  3 1 η 2 1 c2 x~3 : T

Consider jj~xðtÞjj # ϕ0 jj~xðt0 Þjje2σ0 ðt2t0 Þ ; we can obtain V_ # 2 η1 V 1 0:5f ð~xÞ2 # 2 η1 V 1 χðdÞe2σ0 ðt2t0 Þ ;

where χðdÞ is a K-class function of jj~xðt0 Þjj. Using Lemma 1.3, the solution of V_ # 2 η1 V 1 χðdÞe2σ0 ðt2t0 Þ is

3.3 Sliding Mode Control Based on a High Gain Differentiator

VðtÞ # e2η1 ðt2t0 Þ Vðt0 Þ 1 χðdÞ

ðt

e2η1 ðt2τÞ e2σ0 ðτ2t0 Þ dτ ðt 5 e2η1 ðt2t0 Þ Vðt0 Þ 1 χðdÞe2η1 t1σ0 t0 eη1 τ e2σ0 τ dτ t0

t0

χðdÞ 2η1 t1σ0 t0 ðη1 2σ0 Þτ t ; 5e Vðt0 Þ 1 e e jt0 η1 2 σ0 χðdÞ 2η1 t1σ0 t0 ðη1 2σ0 Þt 5 e2η1 ðt2t0 Þ Vðt0 Þ 1 e ðe 2 eðη1 2σ0 Þt0 Þ η1 2 σ0 χðdÞ ðe2σ0 ðt2t0 Þ 2 e2η1 ðt2t0 Þ Þ 5 e2η1 ðt2t0 Þ Vðt0 Þ 1 η1 2 σ0 2η1 ðt2t0 Þ

i.e., lim VðtÞ # 0:

t-N

Therefore, VðtÞ converge to zero exponentially as t-N, and the convergence precision is related to η1 and η.

3.3.5 Simulation example

 For plant (3.21), K 5 0:2, T 5 18:5, and initial states are 0 0 ideal position signal is sint.

 0 . The

Using differentiator (3.26), ε 5 0:01, h1 5 3, h2 5 3, h3 5 1 is designed, and using controller (3.28), η 5 0:50, c1 5 c2 5 5, simulation results are shown in Figs. 3.73.9.

thd and y

2

dthd and dy

–2

ddthd and ddy

ideal position position tracking

0

0

2

4

6

8

10 12 Time(s)

14

16

18

20

2 ideal speed speed tracking

0 –2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

2 ideal acceleration acceleration tracking

0 –2

0

2

4

6

8

10 12 Time(s)

■ FIGURE 3.7 Position, speed, and acceleration tracking.

14

16

18

20

75

x3 and its estimate

x2 and its estimate

x1 and its estimate

CHAPTER 3 Sliding mode control based on a state observer

2 ideal x1 estimation of x1

0 –2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

2 ideal x2 estimation of x2

0 –2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

2 ideal x3 estimation of x3

0 –2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

■ FIGURE 3.8 Position, speed, and acceleration estimation.

3

x 105

2.5 2

Control input

76

1.5 1 0.5 0 –0.5 –1

0

2

4

■ FIGURE 3.9 Control input.

6

8

10 Time(s)

12

14

16

18

20

3.3 Sliding Mode Control Based on a High Gain Differentiator

Simulation Programs:

1. Simulink main program: chap3_3sim.mdl

2. S function of Controller: chap3_3ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {1,2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates

5 0;

sizes.NumDiscStates

5 0;

sizes.NumOutputs sizes.NumInputs

5 1; 5 4;

sizes.DirFeedthrough 5 1;

77

78

CHAPTER 3 Sliding mode control based on a state observer

sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0

5 [];

str 5 []; ts

5 [];

function sys 5 mdlOutputs(t,x,u) c1 5 5; c2 5 5; yd 5 u(1); dyd 5 cos(t); ddyd 5 2 sin(t); dddyd 5 2 cos(t); x1 5 u(2); x2 5 u(3); x3 5 u(4); e 5 x1 2 yd; de 5 x2 2 dyd; dde 5 x3 2 ddyd; s 5 c1*e 1 c2*de 1 dde; v 5 2 dddyd 1 c1*de 1 c2*dde; T 5 18.5;K 5 0.2; b 5 K/(T^3); alfa 5 2 1/(T^3)*x1 2 3/(T^2)*x2 2 3/T*x3; xite 5 0.50; ut 5 2 1/b*(v 1 alfa 1 xite*s); sys(1) 5 ut;

3. S function of observer: chap3_3td.m function [sys,x0,str,ts] 5 Differentiator(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 [];

3.3 Sliding Mode Control Based on a High Gain Differentiator

otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 3; 5 0; 5 3; 5 1;

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0

5 [0 0 0];

str 5 []; ts

5 [0 0];

function sys 5 mdlDerivatives(t,x,u) vt 5 u(1); epc 5 0.01; h1 5 300;h2 5 30000;h3 5 1000000; sys(1) 5 x(2) 2 h1*(x(1) 2 vt);%Kahlil TD sys(2) 5 x(3) 2 h2*(x(1) 2 vt); sys(3) 5 2 h3*(x(1) 2 vt); function sys 5 mdlOutputs(t,x,u) sys 5 x;

4. S function of plant: chap3_3plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes;

79

80

CHAPTER 3 Sliding mode control based on a state observer

5 3;

sizes.NumContStates

5 0;

sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 3; 5 1;

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0,0,0]; str 5 []; ts 5 [ 2 1 0]; function sys 5 mdlDerivatives(t,x,u) T 5 18.5; K 5 0.20; sys(1) 5 x(2); sys(2) 5 x(3); sys(3) 5 2 1/(T^3)*x(1) 2 3/(T^2)*x(2) 2 3/T*x(3) 1 K/(T^3) *u(1);%% 1 0.1*sin(t); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

5. Plot program: chap3_3plot.m close all; figure(1); subplot(311); plot(t,y(:,1),'k',t,y(:,2),'r:','linewidth',2); xlabel('time(s)');ylabel('thd and y'); legend('ideal position','position tracking'); subplot(312); plot(t,cos(t),'k',t,y(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('dthd and dy'); legend('ideal speed','speed tracking'); subplot(313); plot(t, 2 sin(t),'k',t,y(:,4),'r:','linewidth',2); xlabel('time(s)');ylabel('ddthd and ddy'); legend('ideal acceleration','acceleration tracking'); figure(2); subplot(311); plot(t,y(:,2),'k',t,y1(:,1),'r:','linewidth',2);

3.4 Robust State Observer Design for a Flexible Manipulator

xlabel('time(s)');ylabel('x1 and its estimate'); legend('ideal x1','estimation of x1'); subplot(312); plot(t,y(:,3),'k',t,y1(:,2),'r:','linewidth',2); xlabel('time(s)');ylabel('x2 and its estimate'); legend('ideal x2','estimation of x2'); subplot(313); plot(t,y(:,4),'k',t,y1(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('x3 and its estimate'); legend('ideal x3','estimation of x3'); figure(3); plot(t,ut(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('Control input');

3.4 ROBUST STATE OBSERVER DESIGN FOR A FLEXIBLE MANIPULATOR The flexible-joint robot has been a typical and challenging plant for control strategy research because of the highly coupled and nonlinear nature of its dynamic behavior. Compared with the rigid-joint robot, the flexible-joint robot system is far more complex. However, taking joint flexibility into account has a great effect on performance improvement [5,6]. For a real FJ robot system, physical parameters are generally unknown and some states cannot be measured. Considering parametric uncertainties and the reduction of measurement requirement, the observer design for flexible-joint robots is extremely difficult.

3.4.1 Problem statement The dynamic model of a single-link FJ robot can be described as 

I q€ 1 Kðq 2 qm Þ 1 Mglsinq 5 0 ; J q€ m 2 Kðq 2 qm Þ 5 u

ð3:29Þ

where q and qm are the angular positions of the link and the motor shaft, respectively, I and J denote the link inertia and rotor inertia, respectively, K represents the joint flexibility, M, g, and l denote the link mass, gravity constant and the distance to the joint from the mass-centre, respectively, and u is the motor torque.

81

82

CHAPTER 3 Sliding mode control based on a state observer

_ x3 5 qm , and x4 5 q_m Define the state space variables as x1 5 q, x2 5 q, and the single-link FJ robot system in state space is easily described as follows: 8 x_1 5 x2 > > > > < x_2 5 a1 x3 1 f1 ðx1 Þ 1 Δ1 ðtÞ x_3 5 x4 ; > > > x_4 5 a2 u 1 f2 ðx1 ; x3 Þ 1 Δ2 ðtÞ > : y 5 x1

where

a1 5

K , I

f1 ðx1 Þ 5 2

Mgl K sinx1 2 x1 , I I

ð3:30Þ

a2 5 1=J,

f2 ðx1 ; x3 Þ

K ðx1 2 x3 Þ, Δ1 ðtÞ and Δ2 ðtÞ are uncertain parts, jΔ1 ðtÞj # ρ1 , J jΔ2 ðtÞj # ρ2 . 5

3.4.2 Robust observer design From paper [7], a robust observer is designed with the following two parts: firstly, a dynamic observer equation is designed as 8 λ_ 5 λ2 1 l1 ðx1 2 λ1 Þ 1 D1 ðx1 2 λ1 Þ > > < _1 λ2 5 a1 x3 1 f1 ðx1 Þ 1 D2 ðx1 2 λ1 Þ ; _ > > λ3 5 λ4 1 l2 ðx3 2 λ3 Þ 1 D3 ðx3 2 λ3 Þ : _λ4 5 a2 u 1 f2 ðx1 ; x3 Þ 1 D4 ðx3 2 λ3 Þ

ð3:31Þ

where l1 , l2 , D1 , D2 , D3 , and D4 are positive value to be designed. Then the states estimation can be obtained as 8 x^1 5 λ1 > > < x^2 5 λ2 1 l1 ðx1 2 λ1 Þ ; x^3 5 λ3 > > : x^4 5 λ4 1 l2 ðx3 2 λ3 Þ

ð3:32Þ

where x^i is the estimation state. Define the estimation state error x~i 5 xi 2 x^i

ð3:33Þ

From Eqs. (3.31) and (3.33), we have x_^ 1 5 λ2 1 l1 ðx1 2 λ1 Þ 1 D1 ðx1 2 λ1 Þ 5 x^2 1 D1 x~1 x_^ 2 5 a1 x3 1 f1 ðx1 Þ 1 D2 ðx1 2 λ1 Þ 1 l1 ðx2 2 x^2 2 D1 x~1 Þ 5 a1 x3 1 f1 ðx1 Þ 1 l1 x~2 1 ðD2 2 l1 D1 Þx~1 : _x^ 3 5 λ4 1 l2 ðx3 2 λ3 Þ 1 D3 ðx3 2 λ3 Þ 5 x^4 1 D3 x~3 x_^ 4 5 a2 u 1 f2 ðx1 ; x3 Þ 1 D4 ðx3 2 λ3 Þ 1 l2 ðx4 2 x^4 2 D3 x~3 Þ 5 a2 u 1 f2 ðx1 ; x3 Þ 1 l2 x~4 1 ðD4 2 l2 D3 Þx~3

ð3:34Þ

3.4 Robust State Observer Design for a Flexible Manipulator

Define D2 5 D2 2 l1 D1 , D4 5 D4 2 l2 D3 , then 8 > x_^ 5 x^2 1 D1 x~1 > < _1 x^ 2 5 a1 x3 1 f1 ðx1 Þ 1 l1 x~2 1 D2 x~1 : > x_^ 5 x^4 1 D3 x~3 > : _3 x^ 4 5 a2 u 1 f2 ðx1 ; x3 Þ 1 l2 x~4 1 D4 x~3

ð3:35Þ

3.4.3 Observer analysis Design the Lyapunov function as V5

4 1X x~2 : 2 i51 i

We then have V_ 5 x~1 ðx2 2 x^2 2 D1 x~1 Þ 1 x~2 ðΔ1 2 l1 x~2 2 D2 x~1 Þ 1 x~3 ðx4 2 x^4 2 D3 x~3 Þ 1 x~4 ðΔ2 2 l2 x~4 2 D4 x~3 Þ

:

5 ð1 2 D2 Þx~1 x~2 1 ð1 2 D4 Þx~3 x~4 2 D1 x~21 2 l1 x~22 2 D3 x~23 2 l2 x~24 1 Δ1 x~2 1 Δ2 x~4

Set D2 5 D4 5 1

ð3:36Þ

x~2j ρ2 \$ ρi jx~j j \$ Δi x~j , we have From i 1 2 2

x~2 x~2 ρ2 ρ2 V_ # 2 D1 x~21 2 l1 x~22 2 D3 x~23 2 l2 x~24 1 1 1 2 1 2 1 4  2  2 2 2 2  : 1 2 1 ρ ρ2 2 2 5 2 D1 x~1 1 D3 x~3 1 l1 2 x~2 1 l2 2 x~24 1 1 1 2 2 2 2 2

If we set r as l1 \$

1 1 r; 2

l2 \$

1 1 r; 2

D1 \$ r;

D3 \$ r;

where r is a positive value to be designed, then   1 1 D1 x~21 1 D3 x~23 1 l1 2 x~22 1 l2 2 x~24 \$ rðx~21 1 x23 1 x~22 1 x~24 Þ: 2 2

Therefore ρ2 ρ2 V_ # 2 rðx~21 1 x23 1 x~22 1 x~24 Þ 1 1 1 2 5 2 2rV 1 Q; 2 2

where Q 5

ρ21 ρ2 1 2. 2 2

ð3:37Þ

83

84

CHAPTER 3 Sliding mode control based on a state observer

Using Lemma 1.3, the solution of V_ # 22rV 1 Q is VðtÞ # e22rðt2t0 Þ Vðt0 Þ 1 Qe22rt

ðt t0

e2rτ dτ 5 e22rðt2t0 Þ Vðt0 Þ 1

Qe22rt 2rt ðe 2 e2rt0 Þ 2r

Q 5 e22rðt2t0 Þ Vðt0 Þ 1 ð1 2 e22rðt2t0 Þ Þ 2r

;

i.e., VðtÞ #

 Q Q 22rðt2t0 Þ : 1 Vðt0 Þ 2 e 2r 2r

Obviously, all the signals in the system are globally bounded, and lim VðtÞ #

t-N

Q : 2r

From the above, we can see the convergence precision is determined by the upper bound of Δ1, Δ2 and the initial error value of the observer. By taking any large size of r, the observation error can be arbitrarily small. ρ2 ρ2 Moreover, if Δ1 ðtÞ 5 0, Δ2 ðtÞ 5 0, we have Q 5 1 1 2 5 0, then 2 2 V_ # 2 2rV, i.e., VðtÞ # e22rðt2t0 Þ Vðt0 Þ:

At this point, the observer is exponentially convergent.

3.4.4 Simulation example Consider the plant (3.29), the physical parameters which are only used for plant construction are chosen as I 5 1, J 5 1, K 5 40 and Mgl 5 5, Δ1 5 sint and Δ2 5 cost are assumed.  T The initial states for the plant are set as xð0Þ 5 0:1 0 0:05 0 , and  T the initial states for the observer are set as λð0Þ 5 0 0 0 0 . Using observers (3.31) and (3.32), choose r 5 100, according to Eqs. (3.36) and (3.37), set l1 5 101, l2 5 101, D2 5 D4 5 1:0 and D1 5 D3 5 101. Simulation results are shown in Figs. 3.10 and 3.11.

3.4 Robust State Observer Design for a Flexible Manipulator

x1

100 x1 x1p

0 –100 0

5

10

15 t

20

25

30

x2

5 x2 x2p

0 –5

0

5

10

15 t

20

25

30

x3

100 x3 x3p

0 –100 0

5

10

15 t

20

25

30

x4

10 x4 x4p

0 –10

0

5

10

15 t

20

25

30

x4-x4p

x3-x3p

x2-x2p

x1-x1p

■ FIGURE 3.10 States estimation.

0.1 0 –0.1

0

5

10

15 t

20

25

30

0

5

10

15 t

20

25

30

0

5

10

15 t

20

25

30

0

5

10

15 t

20

25

30

5 0 –5

0.05 0 –0.05

2 0 –2

■ FIGURE 3.11 States estimation error.

85

86

CHAPTER 3 Sliding mode control based on a state observer

Simulink programs

1. Simulink main program: chap3_4sim.mdl

2. S function for observer: chap3_4obv.m function [sys,x0,str,ts] 5 obv(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 4; 5 0; 5 4; 5 3;

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1;

3.4 Robust State Observer Design for a Flexible Manipulator

sys 5 simsizes(sizes); x0

5 [0;0;0;0];

str 5 []; ts

5 [0 0];

function sys 5 mdlDerivatives(t,x,u) I 5 1.0;J 5 1.0;Mgl 5 5.0;K 5 40; r 5 100; l1 5 101;l2 5 101; D1 5 101;D3 5 101; D2 5 1;D4 5 1; D2_bar 5 D2 1 l1*D1; D4_bar 5 D4 1 l2*D3; ut 5 u(1); x1 5 u(2); x3 5 u(3); a1 5 K/I;a2 5 1/J; f1 5 2 Mgl/I*sin(x1) 2 K/I*x1; f2 5 K/J*(x1 2 x3); sys(1) 5 x(2) 1 l1*(x1 2 x(1)) 1 D1*(x1 2 x(1)); sys(2) 5 a1*x3 1 f1 1 D2_bar*(x1 2 x(1)); sys(3) 5 x(4) 1 l2*(x3 2 x(3)) 1 D3*(x3 2 x(3)); sys(4) 5 a2*ut 1 f2 1 D4_bar*(x3 2 x(3)); function sys 5 mdlOutputs(t,x,u) l1 5 101;l2 5 101; ut 5 u(1); x1 5 u(2); x3 5 u(3); sys(1) 5 x(1); sys(2) 5 x(2) 1 l1*(x1 2 x(1)); sys(3) 5 x(3); sys(4) 5 x(4) 1 l2*(x3 2 x(3));

3. S function for plant: chap3_4plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u);

87

88

CHAPTER 3 Sliding mode control based on a state observer

case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; 5 4;

sizes.NumContStates

5 0;

sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 4; 5 1;

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0

5 [0.1;0;0.05;0];

str 5 []; ts

5 [0 0];

function sys 5 mdlDerivatives(t,x,u) I 5 1.0;J 5 1.0;Mgl 5 5.0;K 5 40; a1 5 K/I; f1 5 2 Mgl/I*sin(x(1)) 2 K/I*x(1); a2 5 1/J; f2 5 K/J*(x(1) 2 x(3)); delta1 5 sin(t); delta2 5 cos(t); ut 5 u(1); sys(1) 5 x(2); sys(2) 5 a1*x(3) 1 f1 1 delta1; sys(3) 5 x(4); sys(4) 5 a2*ut 1 f2 1 delta2; function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

4. Plot program: chap3_4plot.m close all; figure(1);

3.5 Sliding Mode Control for Flexible Manipulator Based on a Robust State Observer

subplot(411); plot(t,xp(:,1),'b',t,x(:,1),'r:','linewidth',2); xlabel('t');ylabel('x_1'); legend('x1','x1p'); subplot(412); plot(t,xp(:,2),'b',t,x(:,2),'r:','linewidth',2); xlabel('t');ylabel('x_2'); legend('x2','x2p'); subplot(413); plot(t,xp(:,3),'b',t,x(:,3),'r:','linewidth',2); xlabel('t');ylabel('x_3'); legend('x3','x3p'); subplot(414); plot(t,xp(:,4),'b',t,x(:,4),'r:','linewidth',2); xlabel('t');ylabel('x_4'); legend('x4','x4p'); figure(2); subplot(411); plot(t,x(:,1) 2 xp(:,1),'r','linewidth',2); xlabel('t');ylabel('x_1 2 x1p'); subplot(412); plot(t,x(:,2) 2 xp(:,2),'r','linewidth',2); xlabel('t');ylabel('x_2 2 x2p'); subplot(413); plot(t,x(:,3) 2 xp(:,3),'r','linewidth',2); xlabel('t');ylabel('x_3 2 x3p'); subplot(414); plot(t,x(:,4) 2 xp(:,4),'r','linewidth',2); xlabel('t');ylabel('x_4 2 x4p');

3.5 SLIDING MODE CONTROL FOR FLEXIBLE MANIPULATOR BASED ON A ROBUST STATE OBSERVER Consider system (3.30) and choose Δ1 ðtÞ 5 Δ2 ðtÞ 5 0; we have 8 x_1 5 x2 > > > > < x_2 5 a1 x3 1 f1 ðx1 Þ x_3 5 x4 ; > > > x_4 5 a2 u 1 f2 ðx1 ; x3 Þ > : y 5 x1

ð3:38Þ

89

90

CHAPTER 3 Sliding mode control based on a state observer

where a1 5

K Mgl K 1 , f1 ðx1 Þ 5 2 sinx1 2 x1 , a2 5 and f2 ðx1 ; x3 Þ 5 I I I J

K ðx1 2 x3 Þ, u is control input. J

From Eq. (3.31), we have a robust state observer as follows: 8 > λ_ 5 λ2 1 l1 ðx1 2 λ1 Þ 1 D1 ðx1 2 λ1 Þ > < _1 λ2 5 a1 x3 1 f1 ðx1 Þ 1 D2 ðx1 2 λ1 Þ > λ_ 5 λ4 1 l2 ðx3 2 λ3 Þ 1 D3 ðx3 2 λ3 Þ > : _3 λ4 5 a2 u 1 f2 ðx1 ; x3 Þ 1 D4 ðx3 2 λ3 Þ

ð3:39Þ

8 x^1 5 λ1 > > < x^2 5 λ2 1 l1 ðx1 2 λ1 Þ ^ 5 λ3 x > > : 3 x^4 5 λ4 1 l2 ðx3 2 λ3 Þ

ð3:40Þ

and

4 1X Design the Lyapunov function of the observer as Vo 5 x~2 , from 2 i51 i section 3.4; if Δ1 ðtÞ 5 Δ2 ðtÞ 5 0, we have Q 5 0, and

Vo ðtÞ # e22rðt2t0 Þ Vo ðt0 Þ

At this point, the observer is exponentially convergent.

3.5.1 Sliding mode controller design The control task is x1 -xd and x2 -x_d , to simplify the expression, we use f1 to replace f1 ðx1 Þ, and use f2 to replace f1 ðx1 ; x3 Þ. The error state equation can be expressed as e1 5 x1 2 xd e2 5 e_1 5 x2 2 x_d : e3 5 e€ 1 5 x_2 2 x€ d 5 a1 x3 1 f1 2 x€ d e4 5___ e1 5 a1 x_3 1 f_1 2___ xd 5 a1 x4 1 f_1 2___ xd

Define e^1 5 x^1 2 xd e^2 5 x^2 2 x_d e^3 5 a1 x^3 1 f^1 2 x€ d : e^4 5 a1 x^4 1 f^_1 2___ xd

We then have e~1 5 e1 2 e^1 5 x~1 e~2 5 e2 2 e^2 5 x~2 e~3 5 e3 2 e^3 5 a1 x~3 1 f1 2 f^1 : e~4 5 e4 2 e^4 5 a1 x~4 1 f_1 2 f^_1

ð3:41Þ

3.5 Sliding Mode Control for Flexible Manipulator Based on a Robust State Observer

The sliding mode function is designed as s 5 c1 e1 1 c2 e2 1 c3 e3 1 e4 ;

ð3:42Þ

where ci . 0 must be designed to be Hurwitz, i 5 1; 2; 3. Then s~ 5 c1 e~1 1 c2 e~2 1 c3 e~3 1 e~4 5 c1 x~1 1 c2 x~2 1 c3 ða1 x~3 1 f1 2 f^1 Þ 1 a1 x~4 1 f_1 2 f^_1 :

Design the sliding mode controller as u52

1 h c1 ðx^2 2 x_d Þ 1 c2 ða1 x^3 1 f^1 2 x€ d Þ a1 a2 i xd Þ 1 a1 f^2 1 f^€1 2____ x d 1 η^s ; 1 c3 ða1 x^4 1 f^_1 2___

ð3:43Þ

where η . 0. Then s_ 5 c1 e_1 1 c2 e_2 1 c3 e_3 1 e_4 5 c1 ðx2 2 x_d Þ 1 c2 ða1 x3 1 f1 2 x€ d Þ 1 c3 ða1 x4 1 f_1 2__x_d Þ 1 a1 ða2 u 1 f2 Þ 1 f€1 2___x_ d 5 c1 ðx2 2 x_d Þ 1 c2 ða1 x3 1 f1 2 x€ d Þ 1 c3 ða1 x4 1 f_1 2__x_d Þ 2 ½c1 ðx^2 2 x_d Þ 1 c2 ða1 x^3 1 f^1 2 x€ d Þ 1 c3 ða1 x^4 1 f^_1 2__x_d Þ 1 a1 f^2 1 f^€ 1 2___x_ d 1 η^s 1 a1 f2 1 f€1 2___x_ d

:

5 c1 x~2 1 c2 a1 x~3 1 c3 a1 x~4 1 c2 ðf1 2 f^1 Þ 1 c3 ðf_1 2 f^_1 Þ 1 a ðf 2 f^ Þ 1 ðf€ 2 f^€ Þ 2 ηðs 2 s~Þ 1 2

2

1

1

Design the Lyapunov function for the controller as Vc 5

1 2 s : 2

Then V_ c 5 s_s 5 s½c1 x~2 1 c2 a1 x~3 1 c3 a1 x~4 1 c2 ðf1 2 f^1 Þ 1 c3 ðf_1 2 f^_1 Þ 1 a ðf 2 f^ Þ 1 ðf€ 2 f^€ Þ 2 ηðs 2 s~Þ 1 2

2

1

1

5 2 ηs 1 ηsðc1 x~1 1 c2 x~2 1 c3 ða1 x~3 1 f1 2 f^1 Þ 1 a1 x~4 1 f_1 2 f^_1 Þ 1 s½c x~ 1 c a x~ 1 c a x~ 1 c ðf 2 f^ Þ 1 c ðf_ 2 f^_ Þ 2

1 2

2 1 3

3 1 4

2 1

1

3

1

1

1 a1 ðf2 2 f^2 Þ 1 ðf€1 2 f^€ 1 Þ 5 2 ηs2 1 s½ηc1 x~1 1 ðηc2 1 c1 Þx~2 1 ðηc3 a1 1 c2 a1 Þx~3 1 ðηa1 1 c3 a1 Þx~4 1 ðηc3 1 c2 Þðf1 2 f^1 Þ 1 ðη 1 c3 Þðf_1 2 f^_1 Þ 1 a1 ðf2 2 f^2 Þ 1 ðf€1 2 f^€ 1 Þ 1 1 5 2 ηs2 1 sχð~xÞ # 2 ηs2 1 s2 1 χ2 ð~xÞ 2 2  1 1 2 1 2 2 η s 1 χ ð~xÞ 5 ð1 2 2ηÞVc 1 χ2 ð~xÞ 5 2 2 2

;

91

92

CHAPTER 3 Sliding mode control based on a state observer

where χð~xÞ 5 ½ηc1 x~1 1 ðηc2 1 c1 Þx~2 1 ðηc3 a1 1 c2 a1 Þx~3 1 ðηa1 1 c3 a1 Þ x~4 : 1 ðηc3 1 c2 Þðf1 2 f^1 Þ 1 ðη 1 c3 Þðf_1 2 f^_1 Þ 1 a1 ðf2 2 f^2 Þ 1 ðf€1 2 f^€ 1 Þ

From the observer analysis, we have if t-N, x~1 , x~2 , x~3 , x~4 converge to Mgl K 1 sinx1 2 x1 , a2 5 and zero exponentially. Consider f1 ðx1 Þ 5 2 I I J K f2 ðx1 ; x3 Þ 5 ðx1 2 x3 Þ, then f1 2 f^1 , f_1 2 f^_1 , f2 2 f^2 , f€1 2 f^€1 will also J converge to zero exponentially, therefore, χð~xÞ and χ2 ð~xÞ will also converge to zero exponentially. For the closed system, design the Lyapunov function as V 5 Vo 1 Vc :

ð3:44Þ

Then 1 V_ 5 V_ o 1 V_ c # 2 2rVo 2 ð2η 2 1ÞVc 1 χ2 ð~xÞ # 2 η1 V 1 χðdÞe2σ0 ðt2t0 Þ ; 2

where η1 5 f2r; ð2η21Þgmax , χðdÞ is a K 2 class function of jj~xðt0 Þjj, σ0 . 0. Using Lemma 1.3, the solution of V_ # 2 η1 V 1 χðdÞe2σ0 ðt2t0 Þ is VðtÞ # e2η1 ðt2t0 Þ Vðt0 Þ 1 χðdÞ

ðt

e2η1 ðt2τÞ e2σ0 ðτ2t0 Þ dτ

t0

5 e2η1 ðt2t0 Þ Vðt0 Þ 1 χðdÞe2η1 t1σ0 t0

ðt

eη1 τ e2σ0 τ dτ

t0

χðdÞ 2η1 t1σ0 t0 ðη1 2σ0 Þτ t ; e e jt0 η1 2 σ0 χðdÞ 2η1 t1σ0 t0 ðη1 2σ0 Þt 5 e2η1 ðt2t0 Þ Vðt0 Þ 1 e ðe 2 eðη1 2σ0 Þt0 Þ η1 2 σ0 χðdÞ ðe2σ0 ðt2t0 Þ 2 e2η1 ðt2t0 Þ Þ 5 e2η1 ðt2t0 Þ Vðt0 Þ 1 η1 2 σ0

5 e2η1 ðt2t0 Þ Vðt0 Þ 1

ð3:45Þ

i.e., lim VðtÞ # 0:

t-N

Since VðtÞ \$ 0, then if t-N, we have VðtÞ 5 0 and VðtÞ converge to zero exponentially, and convergence precision depends on η1 , i.e., η and r.  T If s 5 0, we have e4 5 2 c1 e1 2 c2 e2 2 c3 e3 . Define E1 5 e1 e2 e3 , then we have E_ 1 5 AE1 . If we design c1 ; c2 ; c3 to make A be Hurwitz,  T then t-N,E1 5 e1 e2 e3 -0.

3.5 Sliding Mode Control for Flexible Manipulator Based on a Robust State Observer

To design A as Hurwitz, we need the roots of   2λ   jA 2 λI j 5  0   2c1

1 2λ 2c2

      2c3 2 λ  0 1

5 λ ð2 c3 2 λÞ 2 c1 2 c2 λ 5 2 λ3 2 c3 λ2 2 c2 λ 2 c1 5 0 2

to be negative. From ðλ110Þ3 5 0, we have λ3 1 30λ2 1 300λ 1 1000 5 0, then we can choose c1 5 1000, c2 5 300 and c3 5 30.

3.5.2 Simulation example Consider the plant (3.38), the physical parameters which are only used for plant construction are chosen as I 5 1, J 5 1, K 5 40, and Mgl 5 5.  T The initial states for the plant are set as xð0Þ 5 0:2 0 0 0 , and  T the initial states for the observer are set as λð0Þ 5 0 0 0 0 . Define the ideal signal as xd 5 sint, use observers (3.39) and (3.40), choose r 5 100, according to Eqs. (3.36) and (3.37), set l1 5 101, l2 5 101, D2 5 D4 5 1:0 and D1 5 D3 5 101. Use controller (3.43), choose c1 5 1000, c2 5 300, c3 5 30, and η 5 1:5. Simulation results are shown in Figs. 3.12 and 3.13.

Angle tracking

1 x1 x1d

0

–1

–2

0

2

4

6

8

10 Time(s)

12

14

16

18

20

Angle speed tracking

1 x2 dxd

0.5 0 –0.5 –1

0

2

4

6

8

■ FIGURE 3.12 Angle and angle speed tracking.

10 Time(s)

12

14

16

18

20

93

CHAPTER 3 Sliding mode control based on a state observer

x1

1 x1 x1p

0 –1

0

5

10 t

15

20

x2

2 x2 x2p

0 –2

0

5

10 t

15

20

x3

2 x3 x3p

0 –2

0

5

10 t

15

20

2 x4

94

x4 x4p

0 –2

0

5

10 t

■ FIGURE 3.13 States estimation.

Simulink programs

1. Simulink main program: chap3_5sim.mdl

15

20

3.5 Sliding Mode Control for Flexible Manipulator Based on a Robust State Observer

2. S function of controller: chap3_5ctrl.m function [sys,x0,str,ts] 5 controller(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 0; 5 0; 5 1; 5 5;

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0

5 [];

str 5 []; ts

5 [0 0];

function sys 5 mdlOutputs(t,x,u) I 5 1.0;J 5 1.0;Mgl 5 5.0;K 5 40; a1 5 K/I;a2 5 1/J; xd 5 u(1); dxd 5 cos(t); ddxd 5 2 sin(t); dddxd 5 2 cos(t); ddddxd 5 sin(t); x1p 5 u(2); x2p 5 u(3); x3p 5 u(4); x4p 5 u(5); f1p 5 2 1/I*Mgl*sin(x1p) 2 K/I*x1p; dx2p 5 a1*x3p 1 f1p; df1p 5 2 1/I*Mgl*cos(x1p)*x2p 2 K/I*x2p;

95

96

CHAPTER 3 Sliding mode control based on a state observer

ddf1p 5 2 1/I*Mgl*( 2 sin(x1p)*x2p^2 1 cos(x1p)*dx2p) 2 K/I*dx2p; f2p 5 1/J*K*(x1p 2 x3p); c1 5 1000;c2 5 300;c3 5 30; e1p 5 x1p 2 xd; e2p 5 x2p 2 dxd; e3p 5 a1*x3p 1 f1p 2 ddxd; e4p 5 a1*x4p 1 df1p 2 dddxd; sp 5 c1*e1p 1 c2*e2p 1 c3*e3p 1 e4p; xite 5 1.50; ut 5 2 1/(a1*a2)*(c1*(x2p 2 dxd) 1 c2* (a1*x3p 1 f1p 2 ddxd) 1 c3*(a1*x4p 1 df1p 2 dddxd) 1 a1*f2p 1 ddf1p 2 ddddxd 1 xite*sp); sys(1) 5 ut;

3. S function for observer: chap3_5obv.m function [sys,x0,str,ts] 5 obv(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 4; 5 0; 5 4; 5 3;

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0

5 [0;0;0;0];

3.5 Sliding Mode Control for Flexible Manipulator Based on a Robust State Observer

str 5 []; ts

5 [0 0];

function sys 5 mdlDerivatives(t,x,u) I 5 1.0;J 5 1.0;Mgl 5 5.0;K 5 40; r 5 100; l1 5 101;l2 5 101; D1 5 101;D3 5 101; D2 5 1;D4 5 1; D2_bar 5 D2 1 l1*D1; D4_bar 5 D4 1 l2*D3; ut 5 u(1); x1 5 u(2); x3 5 u(3); a1 5 K/I;a2 5 1/J; f1 5 2 Mgl/I*sin(x1) 2 K/I*x1; f2 5 K/J*(x1 2 x3); sys(1) 5 x(2) 1 l1*(x1 2 x(1)) 1 D1*(x1 2 x(1)); sys(2) 5 a1*x3 1 f1 1 D2_bar*(x1 2 x(1)); sys(3) 5 x(4) 1 l2*(x3 2 x(3)) 1 D3*(x3 2 x(3)); sys(4) 5 a2*ut 1 f2 1 D4_bar*(x3 2 x(3)); function sys 5 mdlOutputs(t,x,u) l1 5 101;l2 5 101; ut 5 u(1); x1 5 u(2); x3 5 u(3); sys(1) 5 x(1); sys(2) 5 x(2) 1 l1*(x1 2 x(1)); sys(3) 5 x(3); sys(4) 5 x(4) 1 l2*(x3 2 x(3));

4. S function for plant: chap3_5plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u);

97

98

CHAPTER 3 Sliding mode control based on a state observer

case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates

5 4;

sizes.NumDiscStates

5 0;

sizes.NumOutputs sizes.NumInputs

5 4; 5 1;

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0

5 [0.2;0;0;0];

str 5 []; ts

5 [0 0];

function sys 5 mdlDerivatives(t,x,u) I 5 1.0;J 5 1.0;Mgl 5 5.0;K 5 40; ut 5 u(1); sys(1) 5 x(2); sys(2) 5 2 (1/I)*(Mgl*sin(x(1)) 1 K*(x(1) 2 x(3))); sys(3) 5 x(4); sys(4) 5 (1/J)*(ut 1 K*(x(1) 2 x(3))); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

5. Plot program: chap3_5plot.m close all; figure(1); subplot(211); plot(t,sin(t),t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('angle tracking'); legend('x1','x1d'); subplot(212); plot(t,cos(t),t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('angle speed tracking'); legend('x2','dxd');

3.6 Sliding Mode Control with a High Gain Observer Based on Separation Principle

figure(2); subplot(411); plot(t,xp(:,1),'b',t,x(:,1),'r:','linewidth',2); xlabel('t');ylabel('x_1'); legend('x1','x1p'); subplot(412); plot(t,xp(:,2),'b',t,x(:,2),'r:','linewidth',2); xlabel('t');ylabel('x_2'); legend('x2','x2p'); subplot(413); plot(t,xp(:,3),'b',t,x(:,3),'r:','linewidth',2); xlabel('t');ylabel('x_3'); legend('x3','x3p'); subplot(414); plot(t,xp(:,4),'b',t,x(:,4),'r:','linewidth',2); xlabel('t');ylabel('x_4'); legend('x4','x4p'); figure(3); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('ut');

3.6 SLIDING MODE CONTROL WITH A HIGH GAIN OBSERVER BASED ON SEPARATION PRINCIPLE 3.6.1 Separation principle For a nonlinear system as x_ 5 Ax 1 BΦðy; uÞ ; y 5 Cx

ð3:46Þ

the controller is designed as ϑ_ 5 Γðϑ; xÞ : u 5 γðϑ; xÞ

ð3:47Þ

System (3.46) and controller (3.47) constitute a closed loop system. Three assumptions are given as follows [8,9]: Assumption 1: Closed loop control system is asymptotically stable; Assumption 2: Φðy; uÞ meet local Lipschitz conditions, and Φð0; 0Þ 5 0; Assumption 3: Γðϑ; xÞ and γðϑ; xÞ meet local Lipschitz conditions, and near the equilibrium point, Γð0; 0Þ 5 0, γð0; 0Þ 5 0.

99

100

CHAPTER 3 Sliding mode control based on a state observer

Under the above three assumptions, for the closed loop system, H.K. Khalil etc. [8,9] proposed the following separation theorem: According to the closed loop system composed of Eqs. (3.46) and (3.47), if assumptions 13 are satisfied, then there exists a small enough ε . 0, a high gain observer based closed loop system is asymptotically stable near the equilibrium point. In the actual applications, we can design closed loop control system based on a high gain observer according to the following three steps: in the first step, design the state feedback controller to guarantee the asymptotic stability of the closed loop system; in the second step, design a high gain observer; and in the third step, in the controller, use the estimation value instead of state values. The closed loop control system is asymptotically stable. The separation theorem provides the convenience for the stability analysis of closed loop systems. However, the deficiency of the above three assumptions is more stringent, and the applications of the theorem are restricted to a certain extent.

3.6.2 Problem statement The stabilization problem of the inverted pendulum system is a typical problem in the study of nonlinear control. Consider the dynamic system of a single one link inverted pendulum as θ€ 5

mðm 1 MÞgl ml θ2 u; 2 ðM 1 mÞI 1 Mml ðM 1 mÞI 1 Mml2

ð3:48Þ

where the cart mass is M, the pendulum mass is m and the pendulum 1 1 angle is θ, I 5 mL2 , l 5 L. 12 2 The control task to realize the stabilization control of swing angle θ and _ i.e., to realize θ-0 and θ-0 _ swing angle speed θ, by controller design.

3.6.3 High gain observer design _ we then have Define x1 5 θ and x2 5 θ;

x_1 5 x2 ; x_2 5 t1 x1 1 t2 u

where t1 5

mðm 1 MÞgl ml and t2 5 2 . ðM 1 mÞI 1 Mml2 ðM 1 mÞI 1 Mml2

ð3:49Þ

3.6 Sliding Mode Control with a High Gain Observer Based on Separation Principle

The output is yðtÞ 5 θ, then Eq. (3.49) becomes

 where x 5 x1 Φ 5 t1 x1 1 t2 u.

x2

T

x_ 5 Ax 1 BΦðy; uÞ ; y 5 Cx 

,

0 0

A5

1 , 0

  0 B5 , 1

ð3:50Þ

  C5 1 0 ,

For Eq. (3.50), high gain observer can be designed as 2α 3

x_^ 5 A^x 1 BΦðy; uÞ 1 Lðy 2 Cx^ Þ;

ð3:51Þ

1

6 η 7 where L 5 4 α2 5, η is a very small positive value. η2 Define x~ 5 x^ 2 x, combining Eq. (3.51) with x_ 5 Ax 1 BΦðy; uÞ, we have x_~ 5 ðA 2 LCÞ~x, then the stability conditions of the observer is to guarantee ðA 2 LCÞ as Hurwitz. Then  A 5 A 2 LC 5



1

0 1 6 η 2 4 α2 0 0 η2

3 2 α 1  2 0  7 1 0 6 η 5 4 α2 5 0 0 0 2 2 η

3 1 0

7 5:

The characteristic equation of A is  α1     λ 1 η λI 2 A 5  α 2   η2

  21  α1 α2  λ 1 2 5 0:  5 λ2 1  η η λ 

From ðλ1kÞ2 5 0, we have λ2 1 2kλ 1 k2 5 0, k . 0, then we can design α1 5 2k; η

In the observer, we can choose k 5

α2 5 k2 : η2

k0 , then α1 5 2k0 , α2 5 k02 . η

3.6.4 Sliding mode controller design and analysis For Eq. (3.49), design the sliding mode function as s 5 cx1 1 x2 ;

where c is Hurwitz and c . 0. We design the Lyapunov function as 1 V 5 s2 ; 2

101

102

CHAPTER 3 Sliding mode control based on a state observer

then s_ðtÞ 5 cx2 1 x_2 5 cx2 1 t1 x1 1 t2 u:

To guarantee s_s , 0, design the sliding mode controller as uðtÞ 5

1 ð2cx2 2 t1 x1 2 ηsÞ: t2

ð3:52Þ

In the controller, the item ηs is used instead of ηsgnðsÞ, so that u meets the Lipschitz condition. Then s_ðtÞ 5 2 ηs, and V_ 5 s_s 5 2 ηs2 5 2 2ηV # 0:

Then we have VðtÞ 5 e2ηðtÞ Vð0Þ:

Obviously, by using control law (3.51), the closed loop system is exponentially convergent. The closed loop system can be analyzed as follows: 1. The closed loop system composed of control law (3.51) satisfies the asymptotic stability condition, which satisfies Assumption 1; 2. From Φ 5 t1 x1 1 t2 u, we know Φðy; uÞ meet Lipschitz, and Φð0; 0Þ 5 0, which satisfies Assumption 2; 3. We have no adaptive law in the design, so Γðϑ; xÞ 5 0, consider controller (3.52) as γðϑ; xÞ, we get γð0; 0Þ 5 0, which satisfies Assumption 3. In the controller design, we can use the observation values x^1 and x^2 to replace the actual values x1 and x2 , and the measurement of angular velocity is not needed.

3.6.5 Simulation example Consider the plant as (3.48), and choose M 5 1, m 5 0:10, L 5 0:50. The _ 5 0. initial states are set as θð0Þ 5 2108; θð0Þ   Using controller (3.52) and observer (3.51), set c 5 10, x^ 5 0 0 , and choose η 5 0:10, k0 5 1. Simulation results are given in Figs. 3.14 and 3.15.

3.6 Sliding Mode Control with a High Gain Observer Based on Separation Principle

0.2 th thp

Angle

0.1 0 –0.1 –0.2

0

2

4

6

8

10 12 Time/(s)

14

16

18

20

Angle speed

1 dth dthp

0.5

0

–0.5

0

2

4

6

8

10 12 Time/(s)

14

16

18

20

14

16

18

20

■ FIGURE 3.14 Observation and response of angle and angle speed.

2 1 0

ut

–1 –2 –3 –4 –5 –6

0

2

4

■ FIGURE 3.15 Control input.

6

8

10 12 Time/(s)

103

104

CHAPTER 3 Sliding mode control based on a state observer

Matlab programs:

1. Simulink main program: chap3_6sim.mdl

2. S function of controller: chap3_6ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 0; 5 0; 5 1; 5 2;

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes);

3.6 Sliding Mode Control with a High Gain Observer Based on Separation Principle

x0

5 [];

str 5 []; ts

5 [0 0];

function sys 5 mdlOutputs(t,x,u) g 5 9.8;M 5 1.0;m 5 0.1;L 5 0.5; I 5 1/12*m*L^2; l 5 1/2*L; t1 5 m*(M 1 m)*g*l/[(M 1 m)*I 1 M*m*l^2]; t2 5 2 m*l/[(M 1 m)*I 1 M*m*l^2]; x1 5 u(1); %th x2 5 u(2); %dth c 5 10; xite 5 5.0; s 5 c*x1 1 x2; ut 5 1/t2*( 2 c*x2 2 t1*x1 2 xite*s); sys(1) 5 ut;

3. S function of observer: chap3_6obv.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; 5 2;

sizes.NumContStates

5 0;

sizes.NumDiscStates sizes.NumOutputs sizes.NumInputs

5 2; 5 3;

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes);

105

106

CHAPTER 3 Sliding mode control based on a state observer

x0 5 [0;0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) g 5 9.8;M 5 1.0;m 5 0.1;L 5 0.5; I 5 1/12*m*L^2; l 5 1/2*L; t1 5 m*(M 1 m)*g*l/[(M 1 m)*I 1 M*m*l^2]; t2 5 2 m*l/[(M 1 m)*I 1 M*m*l^2]; ut 5 u(1); th 5 u(2); y 5 th; A 5 [0 1; 0 0]; B 5 [0;1]; C 5 [1 0]; Fai 5 t1*th 1 t2*ut; k0 5 1; alpha1 5 2*k0; alpha2 5 k0^2; xite 5 0.10; L 5 [alpha1/xite; alpha2/(xite^2)]; dx 5 A*x 1 B*Fai 1 L*(y 2 C*x); sys(1) 5 dx(1); sys(2) 5 dx(2); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2);

4. S function of plant: chap3_6plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u);

3.6 Sliding Mode Control with a High Gain Observer Based on Separation Principle

case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates

5 2;

sizes.NumDiscStates

5 0; 5 2;

sizes.NumOutputs sizes.NumInputs

5 1;

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0

5 [ 2 10/57.3,0];

str 5 []; ts

5 [0 0];

function sys 5 mdlDerivatives(t,x,u) g 5 9.8;M 5 1.0;m 5 0.1;L 5 0.5; I 5 1/12*m*L^2; l 5 1/2*L; t1 5 m*(M 1 m)*g*l/[(M 1 m)*I 1 M*m*l^2]; t2 5 2 m*l/[(M 1 m)*I 1 M*m*l^2]; ut 5 u(1); sys(1) 5 x(2); sys(2) 5 t1*x(1) 1 t2*ut;

%ddth

function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1);

%th

sys(2) 5 x(2); 5. Plot program: chap3_6plot.m close all; figure(1); subplot(211); plot(t,x(:,1),'r',t,xp(:,1)',' 2 .k','linewidth',2); legend('th','thp');xlabel('time/(s)');ylabel('angle'); subplot(212); plot(t,x(:,2),'r',t,xp(:,2)',' 2 .k','linewidth',2); legend('dth','dthp');xlabel('time/(s)');ylabel('angle speed');

107

108

CHAPTER 3 Sliding mode control based on a state observer

figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time/(s)');ylabel('ut');

REFERENCES [1] J. Liu, X. Wang, Advanced Sliding Mode Control for Mechanical Systems Design, Analysis and Matlab Simulation, Tsinghua & Springer Press, Beijing, 2011. [2] I. Kanellakopoulos, P.V. Kokotovic, A.S. Morse. Adaptive output-feedback control of a class of nonlinear systems. Proceedings of the 30th IEEE Conference on Decision and Control, Brighton, 1991: 10821087. [3] X. Wang, J. Liu, K.-Y. Cai, Tracking control for a velocity-sensorless VTOL aircraft with delayed outputs, Automatica 45 (2009) 28762882. [4] A.N. Atassi, H.K. Khalil, Separation results for the stabilization of nonlinear systems using different high-gain observer designs, Syst. Control Lett. 39 (3) (2000) 183191. [5] F. Ghorbel, J.Y. Hung, M.W. Spong, Adaptive control of flexible-joint manipulators, Control Syst. Mag. 9 (7) (1989) 913. [6] A.C. Huang, Y.C. Chen, Adaptive sliding control for single-link flexible-joint robot with mismatched uncertainties, IEEE Trans. Control Syst. Technol. 12 (5) (2004) 770775. [7] S.J. Yoo, J.B. Park, Y.H. Choi, Output feedback dynamic surface control of flexible-joint robots, Int. J. Control Autom. Syst. 6 (2) (2008) 223233. [8] A.N. Atassi, H.K. Khalil, A separation principle for the stabilization of a class of nonlinear systems, IEEE Trans. Autom. Control 44 (9) (1999) 16721687. [9] H.K. Khalil. High-gain observers in nonlinear feedback control, International Conference on Control, Automation and Systems 2008, 1417 October 2008 in COEX, Seoul, Korea.

Chapter

4

Sliding mode control based on disturbance and a delayed observer Disturbance observer has been used in robotic manipulator control for a long time. In general, the main objective of the use of disturbance observer is to deduce external unknown or uncertain disturbance torques without the use of an additional sensor. In sliding mode control, by using disturbance observer, switch gain can be smaller, thus chattering phenomenon can be decreased greatly. In practical engineering, measurement signal is often delayed, which can decrease the control performance. In this chapter, two kinds of delayed output observer are introduced, and based on the observer, sliding mode controllers are designed. In Section 4.1, based on an exponential disturbance observer, a sliding mode controller is designed, closed system stability is analyzed and an example is given. In Section 4.2, consider a measurement delayed linear system, a delayed output observer is introduced, closed system stability is analyzed and exponential convergence is realized, and an example is given. In Section 4.3, consider a measurement delayed nonlinear system, a delayed output observer is introduced, closed system stability is analyzed and asymptotical convergence is realized, and an example is given.

4.1 SLIDING MODE CONTROL BASED ON EXPONENTIAL DISTURBANCE OBSERVER 4.1.1 System description Consider a linear system as J θ€ 1 bθ_ 5 u 1 d;

ð4:1Þ

where J is moment of inertia, b is damping coefficient, u is control input, θ_ and θ€ are angle and angle speed, respectively, d is disturbance, J . 0, b . 0. Sliding Mode Control Using MATLAB. DOI: http://dx.doi.org/10.1016/B978-0-12-802575-8.00004-7 Copyright © 2017 Tsinghua University Press Limited. Published by Elsevier Inc. All rights reserved.

109

110

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

4.1.2 Disturbance observer design with convergence exponentially From Eq. (4.1), we have d 5 J θ€ 1 bθ_ 2 u:

ð4:2Þ

A disturbance observer can be designed as _ ^ 5 2 K d^ 1 Kd 5 2 K d^ 1 KðJ θ€ 1 bθ_ 2 uÞ; d^ 5 Kðd 2 dÞ

ð4:3Þ

where K . 0. Consider disturbance vary slowly in the control system, we can assume ^ then d_ 5 0 [1,2]. Define d~ 5 d 2 d,   _ d_~ 5 2 d^ 5 2 K d 2 d^ 5 2 K d~

i.e., d_~ 1 K d~ 5 0:

ð4:4Þ

Obviously, d will converge to d^ exponentially. For observer (4.3), angle acceleration signal is needed, which is difficult to measure in practical engineering. Now we introduced a new disturbance observer as follows.   _ Define d^ 5 K d 2 d^ and auxiliary parameter as [2] _ z 5 d^ 2 KJ θ:

ð4:5Þ

    _ € since d_^ 5 K d 2 d^ 5 K J θ€ 1 bθ_ 2 u 2 K d, ^ then Then z_ 5 d^ 2 KJ θ,     ^ z_ 5 K J θ€ 1 bθ_ 2 u 2 K d^ 2 KJ θ€ 5 K bθ_ 2 u 2 K d:

Without angle acceleration signal, disturbance observer can be designed as (

  z_ 5 K bθ_ 2 u 2 K d^ d^ 5 z 1 KJ θ_

;

then       z_ 5 K bθ_ 2 T 2 K z 1 KJ θ_ 5 K bθ_ 2 T 2 KJ θ_ 2 Kz:

In practical engineering, we always consider d_ 5 0 [2], then _ _ € d_~ 5 d_ 2 d^ 5 2 d^ 5 2 z_ 2 KJ θ:

ð4:6Þ

4.1 Sliding Mode Control Based on Exponential Disturbance Observer

Substituting the z_ item into the above, then

    d_~ 5 2 K bθ_ 2 T 2 KJ θ_ 2 Kz 2 KJ θ€       5 2K bθ_ 2 T 2 KJ θ_ 1 Kz 2 KJ θ€ 5 K z 1 KJ θ_ 2 K J θ€ 1 bθ_ 2 T     5 K d^ 2 K J θ€ 1 bθ_ 2 T 5 K d^ 2 d 5 2 K d~

and d_~ 1 K d~ 5 0:

The solution is ~ 5 dðt ~ 0 Þe2Kt : dðtÞ

    Obviously, estimation d^ converge to d exponentially, and d~ð0Þ 5 d~max .

4.1.3 Sliding mode control In sliding mode control, to eliminate control chattering, we can design the controller with d^ instead of d. _ θ_ d . The control goal is θ-θd , θFor Eq. (4.1), design the sliding mode function as _ s 5 ce 1 e;

ð4:7Þ

where c . 0, e 5 θd 2 θ.  1 Since θ€ 5 2bθ_ 1 u 1 d , then J

 1 e€ 5 θ€ d 2 θ€ 5 θ€ d 2 2bθ_ 1 u 1 d J

and  1 b 1 1 s_ 5 ce_ 1 e€ 5 ce_ 1 θ€ d 2 2bθ_ 1 u 1 d 5 ce_ 1 θ€ d 1 θ_ 2 u 2 d: J J J J

Design the controller as

  b 1 uðtÞ 5 J ce_ 1 θ€ d 1 θ_ 2 d^ 1 k0 s 1 ηsgns ; J J

where k0 . 0. Then

  b b 1 1 s_ 5 ce_ 1 θ€ d 1 θ_ 2 ce_ 1 θ€ d 1 θ_ 2 d^ 1 k0 s 1 ηsgns 2 d J J J J : 1^ 1 1~ 5 d 2 k0 s 2 ηsgns 2 d 5 2 k0 s 2 ηsgns 2 d J J J

The Lyapunov function for the closed system is V5

1 2 1 ~2 s 1 d ; 2 2

ð4:8Þ

111

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

then

  1 1~ 2 2 V_ 5 s_s 1 d~d_~ 5 s 2k0 s 2 ηsgns 2 d~ 2 K d~ 5 2 k0 s2 2 ηjsj 2 ds 2 K d~ ; J J

1  where η \$ d~max . J      ~ Consider d ð0Þ 5 d~

max

, we have η \$

1  ~  dð0Þ , then J

  1 1 2 2 V_ # 2 k0 s2 2 K d~ # 2 k1 s2 1 d~ 5 2 k1 V; 2 2

where k1 5 2minfk0 ; K g. Using Lemma 1.3, the solution of V_ # 2 k1 V is VðtÞ # e2k1 ðt2t0 Þ Vðt0 Þ:

The sliding mode function will converge to zero exponentially.

4.1.4 Simulation example

1 and Consider a plant as θ€ 5 2 25θ_ 1 133ðu 1 dÞ, then we have J 5 133 25 . We assume dðtÞ 5 2 5, and ideal angle signal as θd 5 sint, use b5 133 controller (4.8) with disturbance observer (4.6), choose c 5 10, K 5 50, η 5 5:0, and use the saturation function instead of the switch function, set Δ 5 0:05, the simulation results are shown in Figs. 4.14.3. 1 ideal angle x1

x1 tracking

0.5 0 –0.5 –1 –1.5

0

2

4

6

8

10

Time(s) 5 x2 tracking

112

ideal angle speed x2

0

–5

–10 0

2

4

6 Time(s)

■ FIGURE 4.1 Angle and angle speed tracking.

8

10

4.1 Sliding Mode Control Based on Exponential Disturbance Observer

dt and its estimation

0

–2

–4

–6 error between dt and its estimation

dt dt estiamtion

0

1

2

3

4

5 Time(s)

6

7

8

9

10

–6 0

1

2

3

4

5 Time(s)

6

7

8

9

10

1

2

3

4

5 Time(s)

6

7

8

9

10

2 0 –2 –4

■ FIGURE 4.2 Disturbance estimation.

6

5

Control input

4

3

2

1

0

■ FIGURE 4.3 Control input.

0

113

114

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

Simulation programs:

(1) Main Simulink: chap4_1sim.mdl

(2) S function for controller: chap4_1ctrl.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {1,2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 5; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [];

4.1 Sliding Mode Control Based on Exponential Disturbance Observer

str 5 []; ts 5 [ 2 1 0]; function sys 5 mdlOutputs(t,x,u) J 5 1/133; b 5 25/133; thd 5 u(1); dthd 5 cos(t); ddthd 5 2sin(t); th 5 u(2); dth 5 u(3); dp 5 u(5); e 5 thd 2 th; de 5 dthd 2 dth; c 5 10; xite 5 5.0; s 5 c*e 1 de; %Saturated function delta 5 0.05; kk 5 1/delta; if abs(s) . delta sats 5 sign(s); else sats 5 kk*s; end k0 5 10; %ut 5 J*(c*de 1 ddthd 1 b/J*dth 2 1/J*dp 1 k0*s 1 xite * sign (s)); ut 5 J*(c*de 1 ddthd 1 b/J*dth 21/J*dp 1 k0*s 1 xite*sats); sys(1) 5 ut;

(3) S function for high gain observer: chap4_1obv.m function [sys,x0,str,ts] 5 NDO(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u);

115

116

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 1; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) K 5 50; J 5 1/133; b 5 25/133; ut 5 u(1); dth 5 u(3); z 5 x(1); dp 5 z 1 K*J*dth; dz 5 K*(b*dth-ut)-K*dp; sys(1) 5 dz; function sys 5 mdlOutputs(t,x,u) K 5 50; J 5 1/133; dth 5 u(3); z 5 x(1); dp 5 z 1 K*J*dth; sys(1) 5 dp;

(4) S function for plant: chap4_1plant.m function [sys,x0,str,ts] 5 NDO_plant (t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes;

4.1 Sliding Mode Control Based on Exponential Disturbance Observer

case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.1,0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); dt 5 2 5; %dt 5 0.05*sin(t); sys(1) 5 x(2); sys(2) 5 2 25*x(2) 1 133*(ut 1 dt); function sys 5 mdlOutputs(t,x,u) dt 5 2 5; %dt 5 0.05*sin(t); sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 dt;

(5) Plot program: chap4_1plot.m close all; figure(1); subplot(211); plot(t,sin(t),'r',t,x(:,1),' 2 .b','linewidth',2); xlabel('time(s)');ylabel('x1 tracking'); legend('ideal angle','x1');

117

118

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

subplot(212); plot(t,cos(t),'r',t,x(:,2),' 2 .b','linewidth',2); xlabel('time(s)');ylabel('x2 tracking'); legend('ideal angle speed','x2'); figure(2); subplot(211); plot(t,x(:,3),'r',t,dp(:,1),' 2 .b','linewidth',2); xlabel('time(s)');ylabel('dt and its estimation'); legend('dt','dt estiamtion'); subplot(212); plot(t,x(:,3) 2 dp(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('error between dt and its estimation'); figure(3); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('Control input');

4.2 SLIDING MODE CONTROL BASED ON DELAYED OUTPUT OBSERVER 4.2.1 System description Consider a plant as GðsÞ 5

k : s2 1 as 1 b

ð4:9Þ

Eq. (4.9) can be written as θ€ 5 2 aθ_ 2 bθ 1 kuðtÞ;

ð4:10Þ

where θðtÞ is the angle signal and uðtÞ is the control input.

T Define the output as z 5 θ θ_ , then Eq. (4.10) can be expressed as where A 5

0 2b

z_ðtÞ 5 AzðtÞ 1 HuðtÞ;

1 , H5 0 2a

k

T

ð4:11Þ

.

Assuming Δ is the time delay brought from measurement delay, the measured output is yðtÞ 5 θðt 2 ΔÞ: _

ð4:12Þ

^_ _ as t-N. The goals of the observer are that θ ðtÞ-θðtÞ and θðtÞθðtÞ

4.2 Sliding Mode Control Based on Delayed Output Observer

4.2.2 Delayed output observer design Theorem 4.1: [3,4]: Consider a linear system x_ ðtÞ 5 AxðtÞ 1 Bxðt 2 ΔÞ:

ð4:13Þ

The stability of the above system can be guaranteed only if characteristic roots’ real parts of sI 2 A 2 Be2Δs 5 0

ð4:14Þ

are negative, then xðtÞ tend to zero exponentially. h iT For system (4.11), define z^ 5 θ^ θ^_ and design the output delay observer as

_ _ z ðtÞ 5 Az ðtÞ 1 HuðtÞ 1 K yðtÞ 2 C z ðt 2 ΔÞ ;

_ _

_

_

where z ðt 2 ΔÞ is delay of z ðtÞ, C 5

ð4:15Þ

1 0 . 0 1

From Eq. (4.11) to Eq. (4.15), we have _ 5 AδðtÞ 2 KCδðt 2 ΔÞ δðtÞ

ð4:16Þ

where δðtÞ 5 zðtÞ 2 z^ðtÞ. According to Theorem 4.1, we can firstly choose K for Eq. (4.16), and the exponential convergence of δðtÞ can be realized only if characteristic roots’ real parts of sI 2 A 1 KCe2Δs 5 0

ð4:17Þ

are in negative half part. In simulation, we design K by experience firstly, then use Matlab function “fsolve” to solve the roots of Eq. (4.17), if all the roots are in negative half part, then K can be validated.

4.2.3 Sliding mode control design

_ θ_ d . Design the sliding mode function The control task is θ-θd and θas _ s 5 ce 1 e;

where c . 0, e 5 θd 2 θ.

ð4:18Þ

119

120

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

Design the sliding mode controller uðtÞ 5

 1 € θ d 1 aθ^_ 1 bθ^ 1 η^s 1 ce_^ ; k

ð4:19Þ

^ s^ 5 ce^ 1 e. ^_ where η . 0, e^ 5 θd 2 θ, The Lyapunov function is designed as 1 V 5 s2 : 2

Since e€ 5 θ€ d 2 θ€ 5 θ€ d 1 aθ_ 1 bθ 2 ku s_ 5 ce_ 1 e€ 5 ce_ 1 θ€ d 1 aθ_ 1 bθ 2 ku;

then   s_ 5 ce_ 1 θ€ d 1 aθ_ 1 bθ 2 θ€ d 1 aθ^_ 1 bθ^ 1 η^s 1 ce_^ 5 ce~_ 1 aθ~_ 1 bθ~ 2 η^s 5 2 ηs 1 η~s 1 ce~_ 1 aθ~_ 1 bθ~     ; 5 2 ηs 1 η 2cθ~ 2 θ~_ 1 c 2 θ~_ 1 aθ~_ 1 bθ~     5 2 ηs 1 η 2cθ~ 2 θ_~ 1 c 2 θ~_ 1 aθ~_ 1 bθ~ 5 2 ηs 1 ðb 2 ηcÞθ~ 1 ða 2 η 2 cÞθ~_

^_ ^ θ~ 5 θ 2 θ, θ~_ 5 θ_ 2 θ, ~_ s~ 5 s 2 s^ 5 ce~ 1 e~_ 5 2 cθ~ 2 θ. where

~ e~ 5 e 2 e^ 5 2 θ 1 θ^ 5 2 θ,

~_ e~_ 5 2 θ,

Then   V_ 5 2 ηs2 1 s ðb 2 ηcÞθ~ 1 ða 2 η 2 cÞθ~_ 5 2 ηs2 1 k1 sθ~ 1 k2 sθ~_

;

where k1 5 b 2 ηc, k2 5 a 2 η 2 c. 2 1 1 1 1 2 Since k1 sθ~ # s2 1 k12 θ~ , k2 sθ~_ # s2 1 k22 θ~_ , then 2 2 2 2 2 2 1 1 1 1 1 1 2 2 V_ # 2 ηs2 1 s2 1 k12 θ~ 1 s2 1 k22 θ~_ 5 2 ðη 2 1Þs2 1 k12 θ~ 1 k22 θ~_ ; 2 2 2 2 2 2

where η . 1. ~_ using Theorem 4.1, we Consider exponential convergence of θ~ and θ, 2 1 1 2 have k12 θ~ 1 k22 θ~_ # χðdÞe2σ0 ðt2t0 Þ , then 2 2 V_ # 2 η1 V 1 χðdÞe2σ0 ðt2t0 Þ #2 η1 V 1 ε0 ;

4.2 Sliding Mode Control Based on Delayed Output Observer

where σ0 . 0, η1 5 2ðη 2 1Þ . 0, χðdÞ is K class function of :~zðt0 Þ:,

T z 5 θ θ_ , ε0 5 χðdÞe2σ0 ðt2t0 Þ is a constant value related to :~zðt0 Þ:. Using Lemma 1.3, the solution of V_ # 2 η1 V 1 ε0 is VðtÞ # e2η1 ðt2t0 Þ Vðt0 Þ 1 ε0 e2η1 t

ðt

eη1 τ dτ 5 e2η1 ðt2t0 Þ Vðt0 Þ 1

t0

2η1 ðt2t0 Þ

5e

 ε0  Vðt0 Þ 1 1 2 e2η1 ðt2t0 Þ η1

ε0 e2η1 t η1 t ðe 2 eη1 t0 Þ η1

;

i.e., lim VðtÞ #

t-N

1 ε0 : η1

Then VðtÞ will tend to zero exponentially.

4.2.4 Simulation example Consider a plant as GðsÞ 5

1 ; s2 1 10s 1 1

i.e., θ€ 5 210θ_ 2 θ 1 uðtÞ:

Let Δ 5 3:0, in the observer, set K 5 ½0:1 0:1, the solution of Eq. (4.17) is s 5 2 0:3661, according to Theorem 4.1, the stability of the observer can be guaranteed. Let the input be uðtÞ 5 sint, and set the initial states as ½0:20 0, use _ delayed output observer (4.15), set z ðt 2 ΔÞ 5 ½0 0T , the simulation results are shown in Figs. 4.4 and 4.5. Use controller (4.19) and set c 5 10, k 5 1 and η 5 15. The simulation results are shown in Figs. 4.6 and 4.7. Simulation Programs:

1. K Validation of delayed output observer (1) Main program of K design: design_K.m close all; x0 5 0; options 5 foptions; options(1) 5 1; x 5 fsolve('fun_x',x0,options)

121

122

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

x1 and its estimate

0.6 ideal signal estimation signal

0.4 0.2 0 –0.2

0

5

10

15 Time(s)

20

25

30

x2 and its estimate

0.2 ideal signal estimation signal

0.1 0 –0.1 –0.2

0

5

10

15 Time(s)

20

25

30

_ and their estimation. ■ FIGURE 4.4 θðtÞ, θðtÞ 0.35 ideal signal delayed signal

0.3

x1 and its delayed value

0.25 0.2 0.15 0.1 0.05 0 –0.05 –0.1

0

5

10

15 Time(s)

20

25

■ FIGURE 4.5 Ideal θðtÞ and its delay output yðtÞ.

(2) Sub program of K design: fun_x.m function F 5 fun(x) tol 5 3; k1 5 0.1;k2 5 0.1;

30

4.2 Sliding Mode Control Based on Delayed Output Observer

thd and y

2 ideal position signal position tracking signal

1

0

–1

0

10

20

30

40

50 60 Time(s)

70

80

90

100

dthd and dy

1 ideal speed signal speed tracking signal

0

–1

–2

0

10

20

30

40

50 60 Time(s)

70

80

90

100

■ FIGURE 4.6 Angle tracking and angle speed tracking.

x1 and its estimate

2 ideal signal x1 estimation signal x1

1

0

–1

0

10

20

30

40

50 60 Time(s)

70

80

90

100

x2 and its estimate

1 ideal signal x2 estimation signal x2

0

–1

–2

0

10

20

30

_ ■ FIGURE 4.7 Ideal value and estimation value of θðtÞ and θðtÞ.

40

50 60 Time(s)

70

80

90

100

123

124

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

K 5 [k1,k2]'; C 5 [1,0]; A 5 [0 1; 2 1 2 10]; F 5 det(x*eye(2) 2 A 1 K*C*exp( 2 tol*x));

2. Programs for delayed output observer (1) Main program: chap4_2sim.mdl

(2) S function of plant: chap4_2plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end

4.2 Sliding Mode Control Based on Delayed Output Observer

function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0.2 0]; str 5 []; ts 5 [ 2 1 0]; function sys 5 mdlDerivatives(t,x,u) sys(1) 5 x(2); sys(2) 5 2 10*x(2) 2 x(1) 1 u(1); function sys 5 mdlOutputs(t,x,u) th 5 x(1);w 5 x(2); sys(1) 5 th; sys(2) 5 w;

(3) S function of observer: chap4_2obv.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1;

125

126

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

sys 5 simsizes(sizes); x0 5 [0 0]; str 5 []; ts 5 [-1 0]; function sys 5 mdlDerivatives(t,x,u) tol 5 3; th_tol 5 u(1); yp 5 th_tol; ut 5 u(2); z_tol 5 [u(3);u(4)]; thp 5 x(1);wp 5 x(2); %%%%%%%%%%%%%%%%%%% A 5 [0 1; 2 1 2 10]; C 5 [1 0]; H 5 [0;1]; k1 5 0.1;k2 5 0.1; %Verify by design_K.m z 5 [thp wp]'; %%%%%%%%%%%%%%%%%% K 5 [k1 k2]'; dz 5 A*z 1 H*ut 1 K*(yp 2 C*z_tol); for i 5 1:2 sys(i) 5 dz(i); end function sys 5 mdlOutputs(t,x,u) thp 5 x(1);wp 5 x(2); sys(1) 5 thp; sys(2) 5 wp;

(4) Plot program: chap4_2plot.m close all; figure(1); subplot(211); plot(t,p(:,1),'k',t,p(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('x1 and its estimate'); legend('ideal signal','estimation signal'); subplot(212); plot(t,p(:,2),'k',t,p(:,4),'r:','linewidth',2);

4.2 Sliding Mode Control Based on Delayed Output Observer

xlabel('time(s)');ylabel('x2 and its estimate'); legend('ideal signal','estimation signal'); figure(2); subplot(211); plot(t,p(:,1)-p(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('error of x1 and its estimate'); subplot(212); plot(t,p(:,2)-p(:,4),'r','linewidth',2); xlabel('time(s)');ylabel('error of x2 and its estimate'); figure(3); plot(t,p1(:,1),'k',t,p1(:,2),'r:','linewidth',2); xlabel('time(s)');ylabel('x1 and its delayed value'); legend('ideal signal','delayed signal');

3. Programs for sliding mode control system (1) Main program: chap4_3sim.mdl

127

128

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

(2) S function of controller: chap4_3ctrl.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {1,2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [ 2 1 0]; function sys 5 mdlOutputs(t,x,u) tol 5 3; thd 5 sin(t); wd 5 cos(t); ddthd 5 2 sin(t); thp 5 u(2); wp 5 u(3); e1p 5 thd 2 thp; e2p 5 wd 2 wp; k 5 1;a 5 10;b 5 1; c 5 10; xite 5 15; sp 5 c*e1p 1 e2p; ut 5 1/k*(ddthd 1 a*wp 1 b*thp 1 xite*sp 1 c*e2p); sys(1) 5 ut;

4.2 Sliding Mode Control Based on Delayed Output Observer

(3) S function of plant: chap4_3plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0.2 0]; str 5 []; ts 5 [ 21 0]; function sys 5 mdlDerivatives(t,x,u) sys(1) 5 x(2); sys(2) 5 210*x(2) 2 x(1) 1 u(1); function sys 5 mdlOutputs(t,x,u) th 5 x(1);w 5 x(2); sys(1) 5 th; sys(2) 5 w;

(4) S function of observer: chap4_3obv.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u);

129

130

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0 0]; str 5 []; ts 5 [ 2 1 0]; function sys 5 mdlDerivatives(t,x,u) tol 5 3; th_tol 5 u(1); yp 5 th_tol; ut 5 u(2); z_tol 5 [u(3);u(4)]; thp 5 x(1);wp 5 x(2); %%%%%%%%%%%%%%%%%%% A 5 [0 1; 2 1 2 10]; C 5 [1 0]; H 5 [0;1]; k1 5 0.1;k2 5 0.1; %Verify by design_K.m z 5 [thp wp]'; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% K 5 [k1 k2]'; dz 5 A*z 1 H*ut 1 K*(yp 2 C*z_tol); for i 5 1:2 sys(i) 5 dz(i); end

4.2 Sliding Mode Control Based on Delayed Output Observer

function sys 5 mdlOutputs(t,x,u) thp 5 x(1);wp 5 x(2); sys(1) 5 thp; sys(2) 5 wp;

(5) plot program: chap4_3plot.m close all; figure(1); plot(t,y(:,1),'k',t,y(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('thd and y'); legend('ideal position signal','delayed position signal'); figure(2); subplot(211); plot(t,y1(:,1),'k',t,y1(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('x1 and its estimate'); legend('ideal signal x1','estimation signal x1'); subplot(212); plot(t,y1(:,2),'k',t,y1(:,4),'r:','linewidth',2); xlabel('time(s)');ylabel('x2 and its estimate'); legend('ideal signal x2','estimation signal x2'); figure(3); subplot(211); plot(t,y(:,1),'k',t,y(:,2),'r:','linewidth',2); xlabel('time(s)');ylabel('thd and y'); legend('ideal position signal','position tracking signal'); subplot(212); plot(t,cos(t),'k',t,y(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('dthd and dy'); legend('ideal speed signal','speed tracking signal'); figure(4); subplot(211); plot(t,y(:,1) 2 y(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('error between thd and y'); legend('position tracking error'); subplot(212); plot(t,cos(t) 2 y(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('error between dthd and dy'); legend('speed tracking error');

131

132

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

figure(5); plot(t,ut(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('Control input');

4.3 SLIDING MODE CONTROL BASED ON A TIME VARYING DELAYED OUTPUT OBSERVER 4.3.1 System description Consider a nonlinear system as x_ ðtÞ 5 AxðtÞ 1 Mðx; t; uÞ;

ð4:20Þ

T

where x 5 x1 x2 , x1 is position signal, uðtÞ is control input,

T 0 1 A5 , Mðx; t; uÞ 5 Bχðx; t; uÞ, and B 5 0 1 . 0 0 Assumption 1: Mðx; t; uÞ is Lipschitz; Assumption 2: δðtÞ is time varying value, δðtÞA½0; Δ. The delayed measurement signal is yðtÞ 5 x1 ðt 2 δÞ 5 Cxðt 2 δðtÞÞ;

ð4:21Þ

where δðtÞ is delayed time and C 5 1 0 .

The observer goals are x^1 ðtÞ-x1 ðtÞ and x^2 ðtÞ-x2 ðtÞ as t-N.

4.3.2 Delayed output observer design Theorem 4.2: [5]: for system (4.20), x1 ðt 2 δÞ is measurement signal with delay, delayed output observer can be designed as ^ t; uÞ 1 KðyðtÞ 2 C^xðt 2 δÞÞ: x_^ ðtÞ 5 A^xðtÞ 1 Mðx;

For a second nonlinear system, the observer can be expressed as x_^1 5 x^2 1 k1 ðx1 ðt 2 δÞ 2 x^1 ðt 2 δÞÞ

^ t; uÞ 1 k2 ðx1 ðt 2 δÞ 2 x^1 ðt 2 δÞÞ x_^2 5 χðx; ð4:22Þ

where x^ ðt 2 δÞ is the delayed signal of x^ ðtÞ, K 5 ½k1 k2 T , K must be designed to satisfy A 2 KC is Hurwitz. Then the estimation error will converge to zero asymptotically as t-N, x^1 ðtÞ-x1 ðtÞ, x^2 ðtÞ-x2 ðtÞ. The proof and analysis of the are given in paper [5].

4.3 Sliding Mode Control Based on a Time Varying Delayed Output Observer

4.3.3 K design based on Hurwitz Since A 5 A 2 KC 5

0 1 k 0 1 k 2 1 2 1 ½10 5 k2 0 0 0 0 k2

2k1 0 5 0 2k2

1 ; 0

the characteristic equation of A is     λI 2 A 5  λ 1 k1  2k2

 1  5 λ2 1 k1 λ 1 k2 5 0: λ

From ðλ1kÞ2 5 0, we have λ2 1 2kλ 1 k2 5 0. If we design k . 0, A can be Hurwitz, then we can design k1 5 2k; k2 5 k2 :

ð4:23Þ

4.3.4 Simulation example Consider dynamic equation of one link manipulator as 1 1 x€ 5 2 ðd x_ 1 mgl cosxÞ 1 u; I I

i.e., x_1 5 x2

d mgl 1 ; cosx1 1 u x_2 5 2 x2 2 I I I

where x1 and x2 are angle signal and speed signal, u is control input, g 5 9:8 m=s2 , m 5 1, l 5 0:25, d 5 2:0. The above equation can be expressed as x_ ðtÞ 5 AxðtÞ 1 Mðx; t; uÞ;

T where x 5 x1 x2 , x1 is position signal, uðtÞ is control input,

T 0 1 and χðx; t; uÞ 5 A5 , Mðx; t; uÞ 5 Bχðx; t; uÞ, B 5 0 1 0 0 T d mgl 1 cosx1 1 u . 0 2 x2 2 I I I Obviously, M(x,t,u) is Lipschitz. Delayed time is set as Δ 5 1:0 with

T δðtÞA½0; 1:0. In observer (4.22), choose k 5 1, K 5 2 1 , and set

T x^ ðt 2 δÞ 5 0 0 . Use input as uðtÞ 5 sint, the initial states of the plant are set as ½0:500T . The simulation results are shown in Figs. 4.84.10.

133

134

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

0.5 x1 x1 estimation measured x1

0

x1

–0.5

–1

–1.5

–2

0

2

4

6

8

10 Time/s

12

14

16

18

20

■ FIGURE 4.8 Ideal signal, estimation signal, and delayed signal.

Estimation error of x1

1

0.5

0

–0.5

0

2

4

6

8

10 Time/s

12

14

16

18

20

0

2

4

6

8

10 Time/s

12

14

16

18

20

Estimation error of x2

0.4 0.2 0 –0.2 –0.4

■ FIGURE 4.9 Position and speed estimation error.

4.3 Sliding Mode Control Based on a Time Varying Delayed Output Observer

Varying measurement delay time

0.65 0.6 0.55 0.5 0.45 0.4 0.35 0.3 0

2

4

6

8

10 Time/s

12

■ FIGURE 4.10 Time varying measurement delay. Simulation programs:

(1) S function for delayed signal: chap4_4delta.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 0; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [];

14

16

18

20

135

136

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

str 5 []; ts 5 [ 21 0]; function sys 5 mdlOutputs(t,x,u) sys(1) 5 delta(t);

(2) Delayed signal generation function: delta.m function [tout] 5 tolt(tin) if tin , 5 1.0 tout 5 0.40; elseif tin , 5 3.0 tout 5 0.70; elseif tin , 5 5.0 tout 5 0.60; elseif tin , 5 7.0 tout 5 0.40; elseif tin , 5 9.0 tout 5 0.70; elseif tin , 5 10.0 tout 5 0.30; else tout 5 0.50; end tout 5 tout;

(3) Main program: chap4_4sim.mdl

4.3 Sliding Mode Control Based on a Time Varying Delayed Output Observer

(4) S function of plant: chap4_4plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.5 0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) g 5 9.8;m 5 1;l 5 0.25;d 5 2.0; I 5 4/3*m*l^2; sys(1) 5 x(2); sys(2) 5 1/I*( 2 d*x(2) 2 m*g*l*cos(x(1))) 1 1/I*u; function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2);

(5) S function of observer: chap4_4obv.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes;

137

138

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0 0]; str 5 []; ts 5 [-1 0]; function sys 5 mdlDerivatives(t,x,u) x1p 5 x(1); x2p 5 x(2); y 5 u(1); ut 5 u(2); yp 5 u(3); k1 5 2;k2 5 1; K 5 [k1 k2]'; g 5 9.8;m 5 1;l 5 0.25;d 5 2.0; I 5 4/3*m*l^2; X 5 1/I*( 2 d*x2p 2 m*g*l*cos(x1p)) 1 1/I*ut; sys(1) 5 x2p 1 k1*(y-yp); sys(2) 5 X 1 k2*(y-yp); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2);

4.3 Sliding Mode Control Based on a Time Varying Delayed Output Observer

(6) Plot program: chap4_4plot.m close all; figure(1); plot(t,p(:,1),'k',t,p(:,3),'r',t,p1 (:,1),'b','linewidth',2); xlabel('Time/s');ylabel('x1'); legend('x1','x1 estimation','measured x1'); figure(2); subplot(211); plot(t,p(:,1)-p(:,3),'r','linewidth',2); xlabel('Time/s');ylabel('Estimation error of x1'); subplot(212); plot(t,p(:,2)-p(:,4),'r','linewidth',2); xlabel('Time/s');ylabel('Estimation error of x2'); figure(3); plot(t,delta_data1,'k','linewidth',2); xlabel('Time/s');ylabel('Varying measurement delay time');

4.3.5 Sliding mode control based on a delayed output observer Consider dynamic equation of one link manipulator as x_1 5 x2

d mgl 1 : cosx1 1 u x_2 5 2 x2 2 I I I

The control goal is x1 -x1d and x2 -x_1d as t-N. Design the sliding mode function as _ s 5 ce 1 e;

where c . 0, e 5 x1 2 x1d . Design the Lyapunov function as 1 V 5 s2 : 2

Since d mgl 1 e€ 5 x€ 1 2 x€ 1d 5 2 x2 2 cosx1 1 u 2 x€ 1d ; I I I

ð4:24Þ

139

140

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

then d mgl 1 cosx1 1 u 2 x€ 1d : s_ 5 ce_ 1 e€ 5 ce_ 2 x2 2 I I I

Design the controller as uðtÞ 5 I

  d mgl x^2 1 cosx^1 1 x€ 1d 2 ce^_ 2 η^s ; I I

ð4:25Þ

^_ where η . 0, e^ 5 x^1 2 x1d , s^ 5 ce^ 1 e. Define s~ 5 s^ 2 s, then d mgl 1 cosx1 1 u 2 x€ 1d s_ 5 ce_ 1 e€ 5 ce_ 2 x2 2 I I I d mgl d mgl cosx1 1 x^2 1 cosx^1 2 ce^_ 2 η^s 5 ce_ 2 x2 2 I I I I ; d mgl 5 2 ηs 2 η~s 2 ce~_ 1 x~2 1 ðcosx^1 2 cosx1 Þ I I d mgl 5 2 ηs 2 ηðcx~1 1 x~2 Þ 2 cx~2 1 x~2 1 ðcosx^1 2 cosx1 Þ I I

where e~ 5 e 2 e^ 5 x1 2 x^1 5 x~1 , ce~ 1 e~_ 5 cx~1 1 x~2 .

e~_ 5 e_ 2 e_^ 5 x2 2 x^2 5 x~2 ,

s~ 5 s^ 2 s 5

Then   d mgl ðcosx^1 2 cosx1 Þ V_ 5 2 ηs2 1 s 2ηðcx~1 1 x~2 Þ 2 cx~2 1 x~2 1 I I   d 2mgl ; # 2 ηs2 1 s 2ηðcx~1 1 x~2 Þ 2 cx~2 1 x~2 1 I I   2mgl 5 2 ηs2 1 s Oðx~1 ; x~2 Þ 1 I

where Oðx~1 ; x~2 Þ 5 2 ηðcx~1 1 x~2 Þ 2 cx~2 1 dI x~2 : Consider the asymptotical convergence of the observer; we have Oðx~1 ; x~2 Þ 1 2mgl I # Omax , then   V_ # 2 ηs2 1 0:5 s2 1 O2max 52 ðη 2 0:5Þs2 1 0:5O2max 52 ð2η 2 1ÞV 1 0:5O2max

Let η1 5 2η 2 1 . 0, the solution of V_ # 2 η1 V 1 0:5O2max is VðtÞ # e2η1 t Vðt0 Þ 1 0:5O2max

ðt 0

e2η1 ðt2τ Þ dτ

4.3 Sliding Mode Control Based on a Time Varying Delayed Output Observer

Since

Ðt 0

e2η1 ðt2τÞ dτ 5

Ð 1 2η1 t t η1 τ dη1 τ 0e η1 e

5

VðtÞ # e2η1 t Vðt0 Þ 1

1 2η1 t η1 t e η1 e

5 η1 , then 1

1 2 O : 2η1 max

As t-N, VðtÞ- 2η1 O2max , the convergence precision is decided by η 1 and Omax .

4.3.6 Simulation example Consider the same plant as Section 4.3.4, the initial states are chosen as ½0:50 0T , set Δ 5 1:0 with δðtÞA½0; 1:0, use controller (4.25) with

T observer (4.22), set the initial states of the observer as x^ ðt 2 δÞ 5 0 0 ,

T and choose c 5 50, η 5 30, k 5 1 and K 5 2 1 . The simulation results are given in Figs. 4.114.13. Simulation Programs:

(1) S function for delayed signal: chap4_4delta.m (2) Delayed signal generation function: delta.m

angle tracking

2 x1d x1

1 0 –1 –2

0

2

4

6

8

10 Time/s

12

14

16

18

20

angle speed tracking

2 dx1d x2

1 0 –1 –2

0

2

4

6

■ FIGURE 4.11 Position and speed tracking.

8

10 Time/s

12

14

16

18

20

141

142

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

1.5 x1 x1 estimation 1

measured x1

x1

0.5

0

–0.5

–1

–1.5 0

2

4

6

8

10 Time/s

12

14

16

18

20

■ FIGURE 4.12 Ideal signal, observed signal, and delayed signal.

Estimation error of x1

1 0.5 0 –0.5 –1

0

2

4

6

8

10 Time/s

12

14

16

18

20

0

2

4

6

8

10 Time/s

12

14

16

18

20

Estimation error of x2

0.5

0

–0.5

■ FIGURE 4.13 Estimation error of position and speed signal.

4.3 Sliding Mode Control Based on a Time Varying Delayed Output Observer

(3) Main program: chap4_5sim.mdl

(4) S function of controller: chap4_5ctrl.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {1,2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1;

143

144

CHAPTER 4 Sliding mode control based on disturbance and a delayed observer

sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [21 0]; function sys 5 mdlOutputs(t,x,u) x1d 5 sin(t); dx1d 5 cos(t); ddx1d 5 2 sin(t); x1p 5 u(2); x2p 5 u(3); e1p 5 x1p 2 x1d; e2p 5 x2p 2 dx1d; c 5 50; xite 5 30; sp 5 c*e1p 1 e2p; g 5 9.8;m 5 1;l 5 0.25;d 5 2.0;I 5 4/3*m*l^2; ut 5 I*(d/I*x2p 1 m*g*l*cos(x1p) 1 ddx1d 2 c*e2p-xite*sp); sys(1) 5 ut;

(5) S function of plant: chap4_4plant.m (6) S function of observer: chap4_4obv.m (7) Plot program: chap4_5plot.m close all; figure(1); subplot(211); plot(t,sin(t),t,p(:,1),'k','linewidth',2); xlabel('Time/s');ylabel('angle tracking'); legend('x1d','x1'); subplot(212); plot(t,cos(t),t,p(:,2),'k','linewidth',2); xlabel('Time/s');ylabel('angle speed tracking'); legend('dx1d','x2'); figure(2); plot(t,p(:,1),'k',t,p(:,3),'r',t,p1 (:,1),'b','linewidth',2); xlabel('Time/s');ylabel('x1'); legend('x1','x1 estimation','measured x1'); figure(3); subplot(211); plot(t,p(:,1) 2 p(:,3),'r','linewidth',2);

Further Reading

xlabel('Time/s');ylabel('Estimation error of x1'); subplot(212); plot(t,p(:,2)-p(:,4),'r','linewidth',2); xlabel('Time/s');ylabel('Estimation error of x2'); figure(4); plot(t,delta_data2,'k','linewidth',2); xlabel('Time/s');ylabel('Varying measurement delay time');

REFERENCES [1] K. Atsuo, I. Hiroshi, S. Kiyoshi, Chattering reduction of disturbance observer based sliding mode control, IEEE Trans. Ind. Appl. 30 (2) (1994) 456461. [2] W.H. Chen, D.J. Balance, P.J. Gawthrop, J.O. Reilly, A nonlinear disturbance observer for robotic manipulator, IEEE Trans. Ind. Electronics 47 (4) (2000) 932938. [3] S. Leping, Stability criteria for delay differential equations, J. Shanghai Teachers Univer. 27 (3) (1998) 16. [4] C.A. Desoer, M. Vidyasagar, Feedback System: Input-output Properties, Academic Press, New York, 1977. [5] Q. He, J. Liu, An observer for a velocity-sensorless VTOL aircraft with time-varying measurement delay, Int. J. Syst. Sci. 47 (3) (2015) 652661.

FURTHER READING Q. He, J. Liu, Sliding mode observer for a class of globally Lipschitz nonlinear systems with time-varying delay and noise in its output, IET Control Theory Appl. 8 (14) (2014) 13281336.

145

Chapter

5

Sliding mode control based on LMI In this chapter, six sections about sliding mode controller design on LMI technology are introduced as follows. In Section 5.1, LMI solution toolbox-YALMIP toolbox is introduced, and an example is given. In Section 5.2, LMI based sliding mode controller design for linear system is introduced, the states response and position tracking exponentially are all realized, and two examples are given. In Section 5.3, consider input disturbance, a LMI based sliding mode controller design for linear system is introduced, the states response and position tracking exponentially are all realized, and two examples are given. In Section 5.4, LMI based sliding mode controller design for a Lipschitz nonlinear system is introduced, the states response exponentially is realized, and an example is given. In Section 5.5, LMI based sliding mode controller design for a Lipschitz nonlinear system is introduced, and position tracking exponentially is realized, and an example is given. In Section 5.6, LMI based sliding mode control for chaotic systems is introduced, dynamic compensation is designed, the states response exponentially is realized, and an example is given.

5.1 THE NEW LMI SOLUTION TOOLBOX—YALMIP TOOLBOX YALMIP is an independent toolbox of Matlab. It is based on symbolic computation, which has a strong ability to optimize and solve the problem such as linear planning, nonlinear planning, mixed planning and LMI problems. LMI solution can be achieved easily by using YALMIP to solve; you can write the LMI expression directly. The key integrated commands of YALMIP toolbox are [1]: 1. the command “sdpvar” is used to express decision variables in optimization problem; 2. the command “set” can be used to express all constraint conditions; 3. the command “solvesdp” can be used to solve optimization problems; 4. The solution matrix X can be extracted by X 5 double(x). Sliding Mode Control Using MATLAB. DOI: http://dx.doi.org/10.1016/B978-0-12-802575-8.00005-9 Copyright © 2017 Tsinghua University Press Limited. Published by Elsevier Inc. All rights reserved.

147

148

CHAPTER 5 Sliding mode control based on LMI

YALMIP toolbox can be downloaded free from internet, the toolbox name is “yalmip.rar,” then you can decompress and set path “yalmip.rar” to Matlab toolbox path with “add with subfolders.” A typical LMI is AT P 1 FT BT P 1 PA 1 PBF , 0

ð5:1Þ

If A, B, P are known, we can use LMI YALMIP toolbox to solve F. 2 3 2 3 22:548 9:1 0 1 0 0 For example, choose A 5 4 1 21 0 5, B 5 4 0 1 0 5 and 0 214:2 0 0 0 1 2 3 1; 000; 000 0 0 5, use LMI program chap5_1.m, P 54 0 1; 000; 000 0 0 0 1; 000; 000 2 3 2492:4768 25:05 0 5. we can get F 5 4 25:05 2494:0248 6:6 0 6:6 2495:0248 Simulation program: chap5_1.m clear all; close all; %First example on the paper by M.Rehan A 5 [ 22.548 9.1 0;1 21 1;0 214.2 0]; B 5 [1 0 0;0 1 0;0 0 1]; F 5 sdpvar(3,3); M 5 sdpvar(3,3); P 5 1000000*eye(3); FAI 5 (A' 1 F'*B')*P 1 P*(A 1 B*F); %LMI description L 5 set(FAI , 0); solvesdp(L); F 5 double(F)

5.2 SLIDING MODE CONTROLLER DESIGN FOR A LINEAR SYSTEM BASED ON LMI 5.2.1 System description Consider the linear system x_ 5 Ax 1 Bu;

where xARn , uARn , AARn 3 n , BARn 3 n . The control goal is x-0 exponentially.

ð5:2Þ

5.2 Sliding Mode Controller Design for a Linear System Based on LMI 149

5.2.2 Linear system stabilization based on LMI For system (5.1), the controller is designed as u 5 Fx;

ð5:3Þ

where F is state feedback gain, which can be solved by LMI. Theorem 5.1: If the following LMI is satisfied αP 1 AT P 1 M T 1 PA 1 M , 0;

ð5:4Þ

21

where F 5 ðPBÞ M. Then the closed system with plant (5.1) and controller (5.2) is exponentially stable. Proof: Choose the Lyapunov function as V 5 xT Px;

where P 5 PT . 0. Then x_ 5 Ax 1 BFx

and αV 1 V_ 5 αV 1 ðxT PÞ0 x 1 xT P_x 5 αV 1 x_ T Px 1 xT P_x 5 αV 1 ðAx1BFxÞT Px 1 xT PðAx 1 BFxÞ 5 αV 1 xT AT Px 1 xT FT BT Px 1 xT PAx 1 xT PBFx ; 5 αV 1 xT ðAT P 1 FT BT P 1 PA 1 PBFÞx 5 αxT Px 1 xT Ωx 5 xT ðαP 1 ΩÞx

where α . 0, Ω 5 AT P 1 FT BT P 1 PA 1 PBF. To guarantee αV 1 V_ # 0, αP 1 Ω , 0 is needed, that is αP 1 AT P 1 FT BT P 1 PA 1 PBF , 0:

ð5:5Þ

Since F and P are unknown, to solve Eq. (5.5), the left part must be linearized. Define M 5 PBF, then we have αP 1 AT P 1 M T 1 PA 1 M , 0:

ð5:6Þ

From αV 1 V_ # 0, using Lemma 1.3, we have VðtÞ # Vð0Þexpð2αtÞ, i.e., if t-N, VðtÞ-0and x-0, the system states convergence to zero exponentially. From the LMI YALMIP toolbox, we can get M and P, then F 5 ðPBÞ21 M.

150

CHAPTER 5 Sliding mode control based on LMI

5.2.3 Tracking control for linear system based on LMI The control goal is x-xr , xr is ideal command. Define the tracking error as z 5 x 2 xr , then z_ 5 x_ 2 x_ r 5 Ax 1 Bu 2 x_ r

Controller is designed as u 5 Fx 1 ur ;

ð5:7Þ

where F is state feedback gain, which can be solved by LMI, ur 5 2 Fxr 2 B21 Axr 1 B21 x_ r , then u 5 Fx 2 Fxr 2 B21 Axr 1 B21 x_ r 5 Fz 2 B21 Axr 1 B21 x_ r

and z_ 5 Ax1 BðFz2 B21 Axr 1 B21 x_ r Þ2 x_ r 5 Ax1 BFz2 Axr 1 x_ r 2 x_ r 5 Az1 BFz

Theorem 5.2: If the following LMI is satisfied αP 1 AT P 1 M T 1 PA 1 M , 0;

ð5:8Þ

21

where F 5 ðPBÞ M. Then the closed system with plant (5.2) and controller (5.7) is exponentially stable. Proof: Design the Lyapunov function as V 5 zT Pz;

where P 5 PT . 0, then αV 1 V_ 5 αV 1 ðzT PÞ0 z 1 zT P_z 5 αV 1 z_T Pz 1 zT P_z 5 αV 1 ðAz1BFzÞT Px 1 zT PðAz 1 BFzÞ 5 αV 1 zT AT Pz 1 zT FT BT Pz 1 zT PAz 1 zT PBFz ; 5 αV 1 zT ðAT P 1 FT BT P 1 PA 1 PBFÞz 5 αzT Pz 1 zT Ωz 5 zT ðαP 1 ΩÞz

where α . 0, Ω 5 AT P 1 FT BT P 1 PA 1 PBF. To guarantee αV 1 V_ # 0, we need αP 1 Ω , 0, that is αP 1 AT P 1 FT BT P 1 PA 1 PBF , 0:

ð5:9Þ

Since F and P are unknown, to solve Eq. (5.9), the left part must be linearized, define M 5 PBF, then we have αP 1 ΩAT P 1 M T 1 PA 1 M , 0:

ð5:10Þ

5.2 Sliding Mode Controller Design for a Linear System Based on LMI 151

From αV 1 V_ # 0, using Lemma 1.3, we have VðtÞ # Vð0Þ expð2 αtÞ, i.e., if t-N, VðtÞ-0and z-0, the tracking error convergence to zero exponentially. From the LMI YALMIP toolbox, we can get M and P, then we have F 5 ðPBÞ21 M.

5.2.4 Simulation example Consider plant (5.2), and choose 2

22:548 A54 1 0

3 9:1 0 21 0 5; 214:2 0

2

3 1 0 0 B540 1 05 0 0 1

From LMI (5.4), let α 5 0 and α 5 10, respectively, we can get 2 3 2 3 2:048 25:05 0 22:952 25:05 0 F 5 4 25:05 0:5 6:6 5 and F 5 4 25:05 24:5 6:6 5 0 6:6 20:5 0 6:6 25:5 respectively, use the controller (5.3), the simulation results are given in Figs. 5.1 and 5.2.

x1

1 0

–1

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

x2

2 0

–2

x3

2 0

–2

■ FIGURE 5.1 System states response with α 5 0.

CHAPTER 5 Sliding mode control based on LMI

0.5 x1

0 –0.5

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

x2

2 0 –2 1 x3

152

0 –1

■ FIGURE 5.2 System states response with α 5 10.

  The ideal states are set as sin t cos t sin t , from LMI (5.8), let α50 and α 5 10 respectively, we can get 2 3 2 3 2:048 25:05 0 22:952 25:05 0 F 5 4 25:05 0:5 6:6 5and F 5 4 25:05 24:5 6:6 5 0 6:6 20:5 0 6:6 25:5 respectively, use controller (5.7), the simulation results are given in Figs. 5.3 and 5.4. Simulation programs: First simulation: Stabilization programs

1. LMI design program: chap5_2lmi.m clear all; close all; %First example on the paper by M.Rehan A 5 [22.548 9.1 21

1 0

0; 1;

214.2 0];

B 5 [1 0 0; 0 1 0; 0 0 1]; P 5 sdpvar(3,3); F 5 sdpvar(3,3); M 5 sdpvar(3,3);

5.2 Sliding Mode Controller Design for a Linear System Based on LMI 153

xr1,x1

2 0 –2

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

xr2,x2

5 0 –5

xr3,x3

2 0 –2

■ FIGURE 5.3 System states tracking with α 5 0.

xr1,x1

1 0 –1

xr2,x2

2 0 –2

xr3,x3

1 0 –1

■ FIGURE 5.4 System states tracking with α 5 10.

154

CHAPTER 5 Sliding mode control based on LMI

%FAI 5 (A' 1 F'*B')*P 1 P*(A 1 B*F); FAI 5 A'*P 1 M' 1 P*A 1 M; %M 5 PBF %LMI description L1 5 set(P . 0); alfa 5 0; alfa 5 10; L2 5 set((FAI 1 alfa*P) , 0); LL 5 L1 1 L2; solvesdp(LL); P 5 double(P); M 5 double(M) F 5 inv(P*B)*M

2. Simulink main program: chap5_2sim.mdl

3. Controller program: chap5_2ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes;

5.2 Sliding Mode Controller Design for a Linear System Based on LMI 155

case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(1); x2 5 u(2); x3 5 u(3); alfa 5 10; if alfa 55 0 F 5 [ 2.0480

25.0500

25.0500

0.5000

6.6000;

20.0000

6.6000

20.5000];

0.0000;

elseif alfa 55 10 F 5 [ 22.9520

25.0500

25.0500

24.5000

20.0000

6.6000

0.0000; 6.6000; 25.5000];

end ut 5 F*[x1;x2;x3]; sys(1:3) 5 ut;

4. Plant program: chap5_2plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes;

156

CHAPTER 5 Sliding mode control based on LMI

case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 3; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0, 21, 21]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) A 5 [ 22.548 9.1 1 0

21 214.2

0; 1; 0];

B 5 [1 0 0; 0 1 0; 0 0 1]; ut 5 [u(1) u(2) u(3)]'; dx 5 A*x 1 B*ut; sys(1) 5 dx(1); sys(2) 5 dx(2); sys(3) 5 dx(3); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

5. Plot program: chap5_2plot.m close all; figure(1);

5.2 Sliding Mode Controller Design for a Linear System Based on LMI 157

subplot(311); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('x1'); subplot(312); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('x2'); subplot(313); plot(t,x(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('x3'); figure(2); subplot(311); plot(t,u(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('u1'); subplot(312); plot(t,u(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('u2'); subplot(313); plot(t,u(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('u3'); Second simulation: Tracking programs

1. LMI design program: chap5_2lmi.m 2. Simulink main program: chap5_3sim.mdl

3. Ideal signal program: chap5_3input.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag)

158

CHAPTER 5 Sliding mode control based on LMI

switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 0; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) S 5 2; if S 55 1 xr 5 [10 20 30]'; elseif S 55 2 xr 5 [sin(t) cos(t) sin(t)]; end sys(1:3) 5 xr(1:3);

4. Controller program: chap5_3ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 [];

5.2 Sliding Mode Controller Design for a Linear System Based on LMI 159

otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 6; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(4); x2 5 u(5); x3 5 u(6); x 5 [x1 x2 x3]'; xr 5 [u(1) u(2) u(3)]'; S 5 2; if S 55 1 dxr 5 [0 0 0]'; elseif S 55 2 dxr 5 [cos(t) 2sin(t) cos(t)]'; end z 5 x 2xr; A 5 [ 2 2.548 9.1

0;

1

21

1;

0

2 14.2

0];

B 5 [1 0 0; 0 1 0; 0 0 1]; alfa 5 10; if alfa 55 0 F 5 [ 2.0480

2 5.0500

0.0000;

2 5.0500

0.5000

6.6000;

2 0.0000

6.6000

20.5000];

elseif alfa 55 10

160

CHAPTER 5 Sliding mode control based on LMI

F 5 [22.9520

25.0500

25.0500

24.5000

2 0.0000

6.6000

0.0000; 6.6000; 25.5000];

end ur 5 2F*xr 2inv(B)*A*xr 1 inv(B)*dxr; ut 5 F*x 1 ur; sys(1:3) 5 ut;

5. Plant program: chap5_2plant.m 6. Plot program: chap5_3plot.m close all; figure(1); subplot(311); plot(t,xr(:,1),'r',t,x(:,1),'b','linewidth',2); xlabel('time(s)');ylabel('xr1,x1'); subplot(312); plot(t,xr(:,2),'r',t,x(:,2),'b','linewidth',2); xlabel('time(s)');ylabel('xr2,x2'); subplot(313); plot(t,xr(:,3),'r',t,x(:,3),'b','linewidth',2); xlabel('time(s)');ylabel('xr3,x3'); figure(2); subplot(311); plot(t,xr(:,1) 2x(:,1),'b','linewidth',2); xlabel('time(s)');ylabel('xr1 tracking error'); subplot(312); plot(t,xr(:,2) 2 x(:,2),'b','linewidth',2); xlabel('time(s)');ylabel('xr2 tracking error'); subplot(313); plot(t,xr(:,3) 2 x(:,3),'b','linewidth',2); xlabel('time(s)');ylabel('xr3 tracking error'); figure(3); subplot(311); plot(t,u(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('u1'); subplot(312); plot(t,u(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('u2'); subplot(313); plot(t,u(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('u3');

5.3 Sliding Mode Controller Design for a Linear System Based on LMI 161

5.3 SLIDING MODE CONTROLLER DESIGN FOR A LINEAR SYSTEM BASED ON LMI 5.3.1 System description Consider a linear system as x_ 5 Ax 1 Bu 1 d; n

n3n

n

where xAR , uAR , AAR

n3n

, BAR

ð5:11Þ n31

, dAR

is disturbance.

The control goal is x-xr exponentially, xr is ideal signal.

5.3.2 Controller design Define the tracking error as z 5 x 2 xr , then z_ 5 x_ 2 x_ r 5 Ax 1 Bu 1 d 2 x_ r

Design the controller as u 5 Fx 1 ur 1 us ;

ð5:12Þ

where F is state feedback gain, which can be solved by LMI, ur 5 2 Fxr 2 B21 Axr 1 B21 x_ r , us 5 2 B21 ðη sgn ðzÞÞ, ηARn 3 1 , ηi . di ,  T η sgnðzÞ 5 η1 sgn z1 ? ηn sgn zn . then u 5 Fx 2 Fxr 2 B21 Axr 1 B21 x_ r 2 B21 ðη sgn ðzÞÞ 5 Fz 2 B21 Axr 1 B21 x_ r 2 B21 ðη sgn ðzÞÞ

and z_ 5 Ax 1 BðFz 2 B21 Axr 1 B21 x_ r 2 B21 ðη sgnðzÞÞÞ 1 d 2 x_ r 5 Ax 1 BFz 2 Axr 1 x_ r 2 η sgnðzÞ 1 d 2 x_ r 5 Az 1 BFz 2 η sgnðzÞ 1 d;

Referring to [2], we design the following theorem. Theorem 5.3: If the following LMI is satisfied αP 1 AT P 1 M T 1 PA 1 M , 0;

ð5:13Þ

where α . 0, F 5 ðPBÞ21 M, then the closed system with plant (5.11) and controller (5.12) is exponentially stable. Proof: Design the Lyapunov function as V 5 zT Pz;

where P 5 diagfpi g is a diagonal matrix and pi . 0.

162

CHAPTER 5 Sliding mode control based on LMI

then αV 1 V_ 5 αV 1 ðzT PÞ0 z 1 zT P_z 5 αV 1 z_T Pz 1 zT P_z 5 αV 1 ðAz1BFz2η sgn ðzÞ1dÞT Pz 1 zT PðAz 1 BFz 2 ηsgn ðzÞ 1 dÞ 5 αV 1 zT AT Pz 1 zT FT BT Pz 1 ð2η sgn ðzÞ1dÞT Pz

;

1 z PAz 1 z PBFz 1 z Pð2 η sgnðzÞ 1 dÞ T

T

T

# αV 1 zT ðAT P 1 FT BT P 1 PA 1 PBFÞz 5 αzT Pz 1 zT Ωz 5 zT ðαP 1 ΩÞz

where Ω 5 AT P 1 FT BT P 1 PA 1 PBF, ð2η sgn ðzÞ1dÞT Pz 5

n X ð2 ηi 1 di Þpi jzi j , 0; i51

zT Pð2 η sgn ðzÞ 1 dÞ 5

n X ð2 ηi 1 di Þpi jzi j , 0: i51

To guarantee αV 1 V_ # 0, αP 1 Ω , 0 is needed, that is αP 1 AT P 1 FT BT P 1 PA 1 PBF , 0:

ð5:14Þ

Since F and P are unknown, to solve Eq. (5.14), the left part must be linearized, define M 5 PBF, then we have αP 1 AT P 1 M T 1 PA 1 M , 0:

From αV 1 V_ # 0, using Lemma 1.3, we have VðtÞ # Vð0Þexpð2αtÞ, i.e., if t-N, VðtÞ-0 and z-0, the tracking error converges to zero exponentially. From the LMI YALMIP toolbox, we can get M and P, then F 5 ðPBÞ21 M.

5.3.3 Simulation example Consider plant (5.11), and choose 2

22:548 A54 1 0

3 9:1 0 21 0 5; 214:2 0

2

3 1 0 0 B540 1 05 0 0 1

  Ideal states are set as sin t cos t sin t , disturbances are set  T as 50 sin t 50 sin t 50 sin t , from LMI (5.10), let

5.3 Sliding Mode Controller Design for a Linear System Based on LMI 163

xr1,x1

2 0 –2

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

xr2,x2

2 0 –2

xr3,x3

2 0 –2

■ FIGURE 5.5 System states tracking with α 5 0.

2

3 1; 000; 000 0 0 5, and let α 5 0 and α 5 10, P54 0 1; 000; 000 0 0 0 1; 000; 000 respectively, we can get 2 3 2372:1481 25:05 0 5and F 5 4 25:05 2373:6961 6:6 0 6:6 2374:6961 2 3 2375:001 25:05 0 5, respectively. F5 4 25:05 2376:549 6:6 0 6:6 2377:549  Use controller (5.12) and choose η 5 50 50 50 T . The simulation results are given in Figs. 5.5 and 5.6. In the simulation, we use the saturation function instead of the switch function, and set layer Δ 5 0:05. Simulation programs:

1. LMI design program: chap5_4lmi.m clear all; close all; %First example on the paper by M.Rehan A 5 [22.548 9.1 0; 1 0

21

1;

2 14.2 0];

164

CHAPTER 5 Sliding mode control based on LMI

xr1,x1

2 0 –2

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

xr2,x2

2 0 –2

xr3,x3

2 0 –2

■ FIGURE 5.6 System states tracking with α 5 10.

B 5 [1 0 0; 0 1 0; 0 0 1]; %P 5 sdpvar(3,3); F 5 sdpvar(3,3); M 5 sdpvar(3,3); P 5 1000000*eye(3); %FAI 5 (A' 1 F'*B')*P 1 P*(A 1 B*F); alfa 5 0; alfa 5 10; FAI 5 alfa*P 1 A'*P 1 M' 1 P*A 1 M; %M 5 PBF %LMI description %L1 5 set(P . 0); L2 5 set(FAI , 0); %LL 5 L1 1 L2; solvesdp(L2); %P 5 double(P); M 5 double(M) F 5 inv(P*B)*M

5.3 Sliding Mode Controller Design for a Linear System Based on LMI 165

2. Simulink main program: chap5_4sim.mdl

3. Ideal signal program: chap5_4input.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 0; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) S 5 2;

166

CHAPTER 5 Sliding mode control based on LMI

if S 55 1 xr 5 [10 20 30]'; elseif S 55 2 xr 5 [sin(t) cos(t) sin(t)]; end sys(1:3) 5 xr(1:3);

4. Controller program: chap5_4ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 6; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(4); x2 5 u(5); x3 5 u(6); x 5 [x1 x2 x3]'; xr 5 [u(1) u(2) u(3)]'; S 5 2; if S 55 1 dxr 5 [0 0 0]'; elseif S 55 2 dxr 5 [cos(t) -sin(t) cos(t)]'; end

5.3 Sliding Mode Controller Design for a Linear System Based on LMI 167

z 5 x 2 xr; A 5 [ 2 2.548 9.1 0; 21

1

1;

2 14.2 0];

0 B 5 [1 0 0; 0 1 0;

0 0 1]; alfa 5 10; if alfa 55 0 F 5 [ 2 372.1481

2 5.0500

2 5.0500

2 373.6961

0

6.6000

0; 6.6000; 2 374.6961];

elseif alfa 55 10 F 5 [ 2 375.0010

2 5.0500

2 5.0500

2 376.5490

0

6.6000

0; 6.6000; 2 377.5490];

end delta 5 0.05; kk 5 1/delta; for i 5 1:1:3 if z(i) . delta sats(i) 5 1; elseif abs(z(i)) , 5 delta sats(i) 5 kk*z(i); elseif z(i) , 2delta sats(i) 5 21; end end xite 5 [50;50;50]; ur 5 2F*xr 2inv(B)*A*xr 1 inv(B)*dxr; %us 5 2inv(B)*[xite(1)*sign(z(1)) xite(2)*sign(z(2)) xite(3)*sats]'; us 5 2inv(B)*[xite(1)*sats(1) xite(2)*sats(2) xite(3) *sats(3)]'; %us 5 0; ut 5 F*x 1 ur 1 us; sys(1:3) 5 ut; 5. Plant program: chap5_4plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag,

168

CHAPTER 5 Sliding mode control based on LMI

case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 3; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0, 21, 21]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) A 5 [ 22.548 9.1 21

1 0

0; 1;

2 14.2 0];

B 5 [1 0 0; 0 1 0; 0 0 1]; ut 5 [u(1) u(2) u(3)]'; dt 5 [50*sin(t) 50*sin(t) 50*sin(t)]'; dx 5 A*x 1 B*ut 1 dt; sys(1) 5 dx(1); sys(2) 5 dx(2); sys(3) 5 dx(3); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

5.4 Nonlinear System Stabilization Based on LMI 169

6. Plot program: chap5_4plot.m close all; figure(1); subplot(311); plot(t,xr(:,1),'r',t,x(:,1),'b','linewidth',2); xlabel('time(s)');ylabel('xr1,x1'); subplot(312); plot(t,xr(:,2),'r',t,x(:,2),'b','linewidth',2); xlabel('time(s)');ylabel('xr2,x2'); subplot(313); plot(t,xr(:,3),'r',t,x(:,3),'b','linewidth',2); xlabel('time(s)');ylabel('xr3,x3'); figure(2); subplot(311); plot(t,u(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('u1'); subplot(312); plot(t,u(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('u2'); subplot(313); plot(t,u(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('u3');

5.4 NONLINEAR SYSTEM STABILIZATION BASED ON LMI 5.4.1 System description Consider a nonlinear system with Lipschitz conditions as x_ 5 f ðxÞ 1 Ax 1 Bu; n

n3n

n

where xAR , uAR , AAR Lipschitz condition, that is

n3n

and BAR

ð5:15Þ

, nonlinear function f ðxÞ meet

jjf ðxÞ 2 f ðxÞjj # jjLðx 2 xÞjj;

where L is the Lipschitz constant matrix. The control goal is x-0 exponentially.

5.4.2 Controller design Design the controller as u 5 Fx 2 B21 f ð0Þ;

where F is state feedback gain, which can be solved by LMI.

ð5:16Þ

170

CHAPTER 5 Sliding mode control based on LMI

Referring to [2], we design the following theorem. Theorem 5.4: If the following LMI is satisfied 

αP 1 AT P 1 M T 1 PA 1 M 1 LT L P

 P , 0; 2I

ð5:17Þ

where F 5 ðPBÞ21 M, α . 0. Then the closed system with plant (5.15) and controller (5.16) is exponentially stable. Proof: design the Lyapunov function as V 5 xT Px;

where P 5 PT . 0. Since x_ 5 f ðxÞ 2 f ð0Þ 1 ðA 1 BFÞx, then V_ 5 ðxT PÞ0 x 1 xT P_x 5 x_ T Px 1 xT P_x 5 ðf ðxÞ2f ð0Þ1ðA1BFÞxÞT Px 1 xT Pðf ðxÞ 2 f ð0Þ 1 ðA 1 BFÞxÞ 5 ðf ðxÞ2f ð0ÞÞT Px 1 xT ðA1BFÞT Px 1 xT Pðf ðxÞ 2 f ð0ÞÞ 1 xT PðA 1 BFÞx:

Since f ðxÞ is Lipschitz, then ½ f ðxÞ2f ð0ÞT ½ f ðxÞ 2 f ð0Þ # ðLðx20ÞÞT Lðx 2 0Þ 5 xT LT Lx;

i.e., xT LT Lx 2 ðf ðxÞ2f ð0ÞÞT ðf ðxÞ 2 f ð0ÞÞ \$ 0:

Let α . 0, then αV 1 V_ # αxT Px 1 ðf ðxÞ2f ð0ÞÞT Px 1 xT ðA1BFÞT Px 1 xT Pðf ðxÞ 2 f ð0ÞÞ 1 xT PðA 1 BFÞx 1 xT LT Lx 2 ðf ðxÞ2f ð0ÞÞT ðf ðxÞ 2 f ð0ÞÞ

:

ð5:18Þ



x Let Y 5 f ðxÞ2f ð0Þ

T

 , then Y T 5 xT

 ðf ðxÞ2f ð0ÞÞT . Since

αxT Px 1 xT ðA1BFÞT Px 1 xT PðA 1 BFÞx 1 xT LT Lx ; 5 xT ðαP 1 ðA1BFÞT Px 1 PðA 1 BFÞ 1 LT LÞx

then Eq. (5.18) becomes  where Ω 5

V_ # Y T ΩY;

αP 1 ðAT 1 FT BT ÞP 1 PðA 1 FBÞ 1 LT L P

 P . 2I

Appendix: Lipschitz Constant Matrix Design 171

To guarantee αV 1 V_ # 0, Y T ΩY , 0 is needed, that is, Ω , 0, i.e., 

αP 1 ðAT 1 FT BT ÞP 1 PðA 1 FBÞ 1 LT L P

 P , 0: 2I

ð5:19Þ

Since F and P are unknown, to solve Eq. (5.19), the left part must be linearized. Define M 5 PBF, then we have 

αP 1 AT P 1 M T 1 PA 1 M 1 LT L P

 P , 0: 2I

From αV 1 V_ # 0, using Lemma 1.3, we have VðtÞ # Vð0Þ expð2αtÞ, i.e., if t-N, VðtÞ-0and x-0, the system states convergence to zero exponentially. From the LMI YALMIP toolbox, we can get M and P, then F 5 ðPBÞ21 M.

5.4.3 Simulation example

2

3 22:548 9:1 0 Consider system (5.15), and choose A 5 4 1 21 1 5, 0 214:2 0 2 3 2 3 1 0 0 jx1 1 a1 j 2 jx1 2 a2 j 1 5. B 5 4 0 1 0 5 and f ðxÞ 5 4 0 2 0 0 0 1 2 3 2 0 0 From the f ðxÞ expression, we can get L 5 4 0 0 0 5. From LMI 0 0 0 (5.17), let α 5 0 and α 5 10, respectively, we can get 2 3 2 3 21:5075 25:05 0 26:5075 25:05 0 F 5 4 25:05 20:5 6:6 5and F 54 25:05 25:5 6:6 5 0 6:6 21:5 0 6:6 26:5 respectively, use controller (5.16), the simulation results are given in Figs. 5.7 and 5.8.

APPENDIX: LIPSCHITZ CONSTANT MATRIX DESIGN When ξA½a; b, f ðξÞ is a smooth function, according to mean value theorem, we have f ðaÞ 2 f ðbÞ 5 f 0 ðξÞða 2 bÞ, then jf ðaÞ 2 f ðbÞj 5 jf 0 ðξÞða 2 bÞj # maxðjf 0 ðξÞjÞja 2 bj;

where L 5 maxðjf 0 ðξÞjÞ.

172

CHAPTER 5 Sliding mode control based on LMI

x1

1 0 –1

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

x2

2 0 –2

x3

2 0 –2

■ FIGURE 5.7 System states response with α 5 0.

x1

1 0 –1

x2

2 0 –2

x3

1 0 –1

■ FIGURE 5.8 System states response with α 5 10.

Appendix: Lipschitz Constant Matrix Design 173

Since

@f ð1Þ @x1

5

1 @ðjx1 1 a1 j 2 jx1 2 a2 jÞ @x1 2

and

jx1 1 a1 j 2 jx1 2 a2 j 8 x1 1 a1 2 ðx1 2 a2 Þ 5 a2 2 a1 > > < x 1 a 1 ðx 2 a Þ 5 2x 2 a 1 a 1 1 1 2 1 2 1 5 > 2 ðx1 1 a1 Þ 2 ðx1 2 a2 Þ 5 2 2x1 2 a1 1 a2 > : 2 ðx1 1 a1 Þ 1 ðx1 2 a2 Þ 5 2 a1 2 a2

2 @f ð1Þ

according to

@f ðxÞ @x

or 21 or 0, then

6 @x1 6 @f ð2Þ 6 56 6 @x2 4 @f ð3Þ @x3

@f ð1Þ @f ð1Þ 3 @x2 @x3 7 @f ð2Þ @f ð2Þ 7 7 7, then @x2 @x2 7 @f ð3Þ @f ð3Þ 5 @x3 @x3

2   1 0 @f ðxÞ 540 0 max @x 0 0

According to 2 2 have L 5 4 0 0

x1 1 a1 . 0 & x1 2 a2 . 0 x1 1 a1 . 0 & x1 2 a2 , 0 ; x1 1 a1 , 0 & x1 2 a2 . 0 x1 1 a1 , 0 & x1 2 a2 , 0

@f ð1Þ @x1

is equal to 0 or 1

3 0 0 5: 0

jjf ðxÞ 2 f ðxÞjj # jjLðx 2 xÞjj, let L \$ maxðf 0 ðxÞÞ, then we 3 0 0 0 0 5. 0 0

Simulation programs:

1. LMI design program: chap5_5lmi.m clear all; close all; %First example on the paper by M. Rehan A 5 [22.548

9.1

1

21

0

2 14.2

B 5 [1 0 0; 0 1 0; 0 0 1]; L 5 [2 0 0; 0 0 0; 0 0 0]; P 5 sdpvar(3,3); F 5 sdpvar(3,3); M 5 sdpvar(3,3);

0; 1; 0];

174

CHAPTER 5 Sliding mode control based on LMI

alfa 5 0; alfa 5 10; FAI 5 [alfa*P 1 A'*P 1 M' 1 P*A 1 M 1 L'*L P;P 2 eye(3)]; % M 5 PBF %LMI description L1 5 set(P . 0); L2 5 set(FAI , 0); LL 5 L1 1 L2; solvesdp(LL); P 5 double(P); M 5 double(M) F 5 inv(P*B)*M

2. Simulink main program: chap5_5sim.mdl

3. Controller program: chap5_5ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end

Appendix: Lipschitz Constant Matrix Design 175

function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(1); x2 5 u(2); x3 5 u(3); f0 5 [2 0.05 0 0]'; B 5 [1 0 0; 0 1 0; 0 0 1]; alfa 5 10; if alfa 55 0 F 5 [21.5075

2 5.0500

2 5.0500

2 0.5000

6.6000;

0.0000

2 6.6000

21.5000];

0.0000;

elseif alfa 55 10 F 5 [ 2 6.5075 2 5.0500

0.0000

2 5.0500 2 5.5000

6.6000

2 0.0000

6.6000 2 6.5000];

end ut 5 F*[x1;x2;x3] 2 inv(B)*f0; sys(1:3) 5 ut;

4. Plant program: chap5_5plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes;

176

CHAPTER 5 Sliding mode control based on LMI

case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 3; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [1, 2 1, 2 1]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) a1 5 1;a2 5 1.1; fx 5 0.5*[abs(x(1) 1 a1) 2 abs(x(1) 2 a2);0;0]; A 5 [ 2 2.548 9.1 1 0

21

0; 1;

2 14.2 0];

B 5 [1 0 0; 0 1 0; 0 0 1]; ut 5 [u(1) u(2) u(3)]'; dx 5 fx 1 A*x 1 B*ut; sys(1) 5 dx(1); sys(2) 5 dx(2); sys(3) 5 dx(3); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

5.5 Nonlinear System Tracking Control Based on LMI 177

5. Plot program: chap5_5plot.m close all; figure(1); subplot(311); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('x1'); subplot(312); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('x2'); subplot(313); plot(t,x(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('x3'); figure(2); subplot(311); plot(t,u(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('u1'); subplot(312); plot(t,u(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('u2'); subplot(313); plot(t,u(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('u3');

5.5 NONLINEAR SYSTEM TRACKING CONTROL BASED ON LMI 5.5.1 System description Consider a nonlinear system with Lipschitz conditions as x_ 5 f ðxÞ 1 Ax 1 Bu 1 d;

ð5:20Þ

where xARn , uARn , AARn 3 n , BARn 3 n and dARn 3 1 are disturbance, nonlinear function f ðxÞ meets the Lipschitz condition, that is jj f ðxÞ 2 f ðxÞjj # jjLðx 2 xÞjj;

ð5:21Þ

where L is the Lipschitz constant matrix. The control goal is x-xr exponentially, and xr is ideal command signal.

178

CHAPTER 5 Sliding mode control based on LMI

5.5.2 Controller design Define the tracking error as z 5 x 2 xr , then z_ 5 x_ 2 x_ r 5 Ax 1 Bu 1 f ðxÞ 1 d 2 x_ r :

Design the controller as u 5 Fx 1 ur 1 us ;

ð5:22Þ

where F is state feedback gain, which can be solved by LMI, ur 5 2 Fxr 2 B21 Axr 2 B21 f ðxr Þ 1 B21 x_ r , us 5 2 B21 ðη sgn ðzÞÞ, ηARn 3 1 , ηi . d i ,  η sgn ðzÞ 5 η1 sgn z1 ? ηn sgn zn T . then u 5 Fx 2 Fxr 2 B21 Axr 2 B21 f ðxr Þ 1 B21 x_ r 2 B21 ðη sgn ðzÞÞ 5 Fz 2 B21 Axr 2 B21 f ðxr Þ 1 B21 x_ r 2 B21 ðη sgn ðzÞÞ

and z_ 5 Ax 1 BðFz 2 B21 Axr 2 B21 f ðxr Þ 1 B21 x_ r 2 B21 ðη sgn ðzÞÞÞ 1 f ðxÞ 1 d 2 x_ r 5 Ax 1 BFz 2 Axr 2 f ðxr Þ 1 x_ r 1 f ðxÞ 2 η sgn ðzÞ 1 d 2 x_ r 5 Az 1 BFz 1 f ðxÞ 2 f ðxr Þ 2 η sgn ðzÞ 1 d

Referring to [2], we design the following theorem. Theorem 5.5: If the following LMI is satisfied 

αP 1 AT P 1 M T 1 PA 1 M 1 LT L P

 P , 0; 2I

ð5:23Þ

where F 5 ðPBÞ21 M. Then the closed system with plant (5.20) and controller (5.22) is exponentially stable. Proof: design the Lyapunov function as V 5 zT Pz;

where P 5 PT . 0. Since z_ 5 Az 1 BFz 1 f ðxÞ 2 f ðxr Þ 2 η sgn ðzÞ 1 d;

5.5 Nonlinear System Tracking Control Based on LMI 179

then V_ 5 ðzT PÞ0 z 1 zT P_z 5 z_T Pz 1 zT P_z 5 ðAz1BFz1f ðxÞ2f ðxr Þ2η sgn ðzÞ1dÞT Pz :

1 zT PðAz 1 BFz 1 f ðxÞ 2 f ðxr Þ 2 η sgn ðzÞ 1 dÞ 5 zT ðA1BFÞT Pz 1 ðf ðxÞ2f ðxr ÞÞT Pz 1 ð2η sgn ðzÞ1dÞT Pz 1 zT PðA 1 BFÞz 1 zT Pðf ðxÞ 2 f ðxr ÞÞ 1 zT Pð2 η sgnðzÞ 1 dÞ

Since ð2η sgn ðzÞ1dÞT Pz 5

n X ð2 ηi 1 di Þpi jzi j , 0; i51

zT Pð2 η sgn ðzÞ 1 dÞ 5

n X ð2 ηi 1 di Þpi jzi j , 0 i51

From Eq. (5.21), we have ½f ðxÞ2f ðxr ÞT ½f ðxÞ 2 f ðxr Þ # ðLðx2xr ÞÞT Lðx 2 xr Þ 5 ðx2xr ÞT LT Lðx 2 xr Þ 5 zT LT Lz

;

i.e., zT LT Lz 2 ½f ðxÞ2f ðxr ÞT ½f ðxÞ 2 f ðxr Þ \$ 0 Let α . 0, then αV 1 V_ # αzT Pz 1 zT ðA1BFÞT Pz 1 ðf ðxÞ2f ðxr ÞÞT Pz 1 zT PðA 1 BFÞz 1 zT Pðf ðxÞ 2 f ðxr ÞÞ 1 zT LT Lz 2 ½f ðxÞ2f ðxr ÞT ½f ðxÞ 2 f ðxr Þ



z Define Y 5 f ðxÞ2f ðxr Þ Since

T



, then Y 5 zT T

ð5:24Þ

ðf ðxÞ2f ðxr ÞÞ . T

αzT Pz 1 zT ðA1BFÞT Pz 1 zT PðA 1 BFÞz 1 zT LT Lz 5 zT ðαP 1 ðA1BFÞT P 1 PðA 1 BFÞ 1 LT LÞz

;

then Eq. (5.24) becomes 

V_ # Y T ΩY;

 αP 1 ðAT 1 FT BT ÞP 1 PðA 1 FBÞ 1 LT L P . P 2I To guarantee αV 1 V_ # 0, we need Y T ΩY , 0, i.e., Ω , 0, then

where Ω 5 

αP 1 ðAT 1 FT BT ÞP 1 PðA 1 FBÞ 1 LT L P

 P , 0: 2I

ð5:25Þ

180

CHAPTER 5 Sliding mode control based on LMI

Since F and P are unknown, to solve Eq. (5.25), the left part must be linearized, define M 5 PBF, then we have 

αP 1 AT P 1 M T 1 PA 1 M 1 LT L P

 P ,0 2I

From αV 1 V_ # 0, using Lemma 1.3, we have VðtÞ # Vð0Þ expð2 αtÞ, i.e., if t-N, VðtÞ-0 and z-0, the tracking error convergence to zero exponentially. From the LMI YALMIP toolbox, we can get M and P, then F 5 ðPBÞ21 M.

5.5.3 Simulation example

2

3 22:548 9:1 0 Consider system (5.20), choose A54 1 21 1 5, 0 214:2 0 2 3 2 3 1 0 0 jx1 1 a1 j 2 jx1 2 a2 j 1 5. From the expresB 5 4 0 1 0 5 and f ðxÞ 5 4 0 2 0 0 1 0 2 3 2 0 0 sion of f ðxÞ, we can obtain L 5 4 0 0 0 5. 0 0 0  Ideal states are set as sin t cos t sin t , disturbances are set as  50 sin t 50 sin t 50 sin t T . From LMI (5.20), let α 5 0 and α 5 10, respectively, we can get 2 3 2 3 21:5075 25:05 0 26:5075 25:05 0 F 5 4 25:05 20:5 6:6 5and F 5 4 25:05 25:5 6:6 5, 0 6:6 21:5 0 6:6 26:5  respectively, use the controller (5.22), choose η 5 50 50 50 T , the simulation results are given in Figs. 5.9 and 5.10. In the simulation, we use the saturation function instead of the switch function, and set layer Δ 5 0:05. Simulation programs:

1. LMI design program: chap5_6lmi.m clear all; close all; %First example on the paper by M. Rehan A 5 [ 2 2.548 9.1 1 0

21

0; 1;

2 14.2 0];

5.5 Nonlinear System Tracking Control Based on LMI 181

xr1,x1

2 0 –2

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

0

5

10

15 Time(s)

20

25

30

xr2,x2

2 0 –2

xr3,x3

2 0 –2

■ FIGURE 5.9 System states tracking with α 5 0.

xr1,x1

2 0 –2

xr2,x2

2 0 –2

xr3,x3

2 0 –2

■ FIGURE 5.10 System states tracking with α 5 10. B 5 [1 0 0; 0 1 0; 0 0 1]; L 5 [2 0 0; 0 0 0; 0 0 0];

182

CHAPTER 5 Sliding mode control based on LMI

P 5 sdpvar(3,3); F 5 sdpvar(3,3); M 5 sdpvar(3,3); alfa 5 0; alfa 5 10; FAI 5 [alfa*P 1 A'*P 1 M' 1 P*A 1 M 1 L'*L P;P 2 eye(3)]; %M 5 PBF %LMI description L1 5 set(P . 0); L2 5 set(FAI , 0); LL 5 L1 1 L2; solvesdp(LL); P 5 double(P); M 5 double(M) F 5 inv(P*B)*M

2. Simulink main program: chap5_6sim.mdl

3. Ideal signal program: chap5_6input.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u);

5.5 Nonlinear System Tracking Control Based on LMI 183

case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 0; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) S 5 2; if S 55 1 xr 5 [10 20 30]'; elseif S 55 2 xr 5 [sin(t) cos(t) sin(t)]; end sys(1:3) 5 xr(1:3);

4. Controller program: chap5_6ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0;

184

CHAPTER 5 Sliding mode control based on LMI

sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 6; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(4); x2 5 u(5); x3 5 u(6); x 5 [x1 x2 x3]'; xr 5 [u(1) u(2) u(3)]'; S 5 2; if S 55 1 dxr 5 [0 0 0]'; elseif S 55 2 dxr 5 [cos(t) 2sin(t) cos(t)]'; end z 5 x 2 xr; A 5 [22.548 9.1

0;

1

21

1;

0

2 14.2

0];

B 5 [1 0 0; 0 1 0; 0 0 1]; alfa 5 10; if alfa 55 0 F 5 [ 21.5075

25.0500

25.0500

20.5000

0.0000

6.6000

0.0000; 6.6000; 21.5000];

elseif alfa 55 10 F 5 [26.5075

25.0500

0.0000

25.0500

25.5000

6.6000

0.0000

2 6.6000

2 6.5000];

end

5.5 Nonlinear System Tracking Control Based on LMI 185

a1 5 1;a2 5 1.1; fxr 5 0.5*[abs(xr(1) 1 a1) 2 abs(xr(1) 2 a2);0;0]; delta 5 0.05; kk 5 1/delta; for i 5 1:1:3 if z(i) . delta sats(i) 5 1; elseif abs(z(i)) , 5 delta sats(i) 5 kk*z(i); elseif z(i) , 2 delta sats(i) 5 21; end end xite 5 [50;50;50]; ur 5 2 F*xr 2 inv(B)*A*xr 1 inv(B)*dxr; %us 5 2 inv(B)*[xite(1)*sign(z(1)) xite(2)*sign(z(2)) xite(3)*sats]'; us 5 2 inv(B)*[xite(1)*sats(1) xite(2)*sats(2) xite(3) *sats(3)]'; %us 5 0; ur 5 2 F*xr-inv(B)*A*xr 2 inv(B)*fxr 1 inv(B)*dxr; ut 5 F*x 1 ur 1 us; sys(1:3) 5 ut;

5. Plant program: chap5_6plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes;

186

CHAPTER 5 Sliding mode control based on LMI

sizes.NumContStates 5 3; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [1, 21, 21]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) a1 5 1;a2 5 1.1; fx 5 0.5*[abs(x(1) 1 a1) 2abs(x(1) 2a2);0;0]; A 5 [22.548 9.1 21

1 0

0; 1;

214.2 0];

B 5 [1 0 0; 0 1 0; 0 0 1]; ut 5 [u(1) u(2) u(3)]'; dt 5 [50*sin(t) 50*sin(t) 50*sin(t)]'; dx 5 fx 1 A*x 1 B*ut 1 dt; sys(1) 5 dx(1); sys(2) 5 dx(2); sys(3) 5 dx(3); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

6. Plot program: chap5_6plot.m close all; figure(1); subplot(311); plot(t,xr(:,1),'r',t,x(:,1),'b','linewidth',2); xlabel('time(s)');ylabel('xr1,x1'); subplot(312); plot(t,xr(:,2),'r',t,x(:,2),'b','linewidth',2); xlabel('time(s)');ylabel('xr2,x2'); subplot(313);

5.6 Sliding Mode Control for Chaotic Systems Based on LMI 187

plot(t,xr(:,3),'r',t,x(:,3),'b','linewidth',2); xlabel('time(s)');ylabel('xr3,x3'); figure(2); subplot(311); plot(t,u(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('u1'); subplot(312); plot(t,u(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('u2'); subplot(313); plot(t,u(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('u3');

5.6 SLIDING MODE CONTROL FOR CHAOTIC SYSTEMS BASED ON LMI 5.6.1 System description Consider a Lorenz system as x_1 ðtÞ 5 aðx2 2 x1 Þ x_2 ðtÞ 5 rx1 2 x2 2 x1 x3 1 u1 ; x_3 ðtÞ 5 2 bx3 1 x1 x2 1 u2

ð5:26Þ

where a 5 10, b 5 83, r 5 28, u1 and u2 are control input. Eq. (5.26) becomes  x_ ðtÞ 5 Ax 1 f ðxÞ 1 Bu 5 Ax 1

0 f2 ðxÞ

 1

  0 u; I

0

3

xAR ,

where  f2 ðxÞ 5

2 x1 x3 x1 x2



u 5 ð u1

u2 Þ AR , T

2

0 1   0 0 0 and B 5 5 @ 1 0 A. I 0 1

2a [email protected] r 0

ð5:27Þ

a 21 0

1 0 0 A, 2b

5.6.2 Traditional sliding mode control based on LMI Define the sliding mode function as s 5 Cx;

ð5:28Þ

188

CHAPTER 5 Sliding mode control based on LMI   C1 ð1Þ 1 I 5 C1 ð2Þ 0

 where C 5 C1

 0 , C1 AR2 3 1 , I is a unit matrix 1

with 2 3 2. Choose the Lyapunov function as 1 VðtÞ 5 sT s; 2

then s_ 5 C_x 5 CAx 1 Cf ðxÞ 1 CBu _ 5 sT s_ 5 sT ðCAx 1 Cf ðxÞ 1 CBuÞ; VðtÞ

   0 5 I. I I



where CB 5 C1

Design the controller as  where η 5

η 0



u 5 2 CAx 2 Cf ðxÞ 2 ηs;

ð5:29Þ

0 and η . 0. η

then _ 5 sT s_ 5 sT ðCAx 1 Cf ðxÞ 1 CBuÞ VðtÞ 5 sT ðCAx 1 Cf ðxÞ 1 uÞ 5 sT ðCAx 1 Cf ðxÞ 2 CAx 2 Cf ðxÞ 2 ηsÞ # 2 η:s: # 0

Since sT s_ # 0, there exists t . t0 , we have s 5 0, then we have u 5 2 CAx 2 Cf ðxÞ. Since 0 1 0 10 1 0 1   0   0 0 0 0 0 0 0 @ 0 ½ C1 I  f ðxÞ5 0 [email protected] ð1Þ 1 0 [email protected] 0 [email protected] 0 A5 f ðxÞ; C1 I I f2 ð2Þ C1 ð2Þ 0 1 f2 ð2Þ f2 ð2Þ

then f ðxÞ 2 BCf ðxÞ 5 f ðxÞ 2

  0  C1 I

I  f ðxÞ 5 0

and x_ 5 Ax 1 f ðxÞ 1 Bu 5 Ax 1 f ðxÞ 1 Bð2 CAx 2 Cf ðxÞÞ : 5 Ax 1 f ðxÞ 2 BCAx 2 BCf ðxÞ 5 ðA 2 BCAÞx

Define M 5 A 2 BCA, then x_ 5 Mx.

5.6 Sliding Mode Control for Chaotic Systems Based on LMI 189

To guarantee x-0 exponentially, design the Lyapunov function as VðxÞ 5 xT x

then _ 5 ðMxÞT x 1 xT Mx 5 xT M T x 1 xT Mx VðxÞ 5 xT ðM T 1 MÞx

:

_ # 0, choose To guarantee VðxÞ M T 1 M , 0:

ð5:30Þ

The matrix C can be solved by LMI (5.30). However, in Eq. (5.30), M 5 0 cannot be avoided, thus M T 1 M , 0 cannot be satisfied, sliding mode function based on dynamic compensation should be designed.

5.6.3 Sliding mode control based on dynamic compensation Define the sliding mode function as 

where C 5 C1 with 2 3 2.





C1 ð1Þ I 5 C1 ð2Þ

s 5 Cx 1 z;

ð5:31Þ

 1 0 , C1 AR2 3 1 and I is a unit matrix 0 1

To realize x-0 exponentially, compensation is designed as follows [3]: z_ 5 Kx 2 z;

ð5:32Þ

where zAR2 is the state of the compensator, KAR2 3 3 . In Eqs. (5.31) and (5.32), C and K can be solved by LMI. Choose the Lyapunov function as VðtÞ 5

1 T s s 2

Since s_ 5 C_x 1 z_ 5 CðAx 1 f ðxÞ 1 BuÞ 1 Kx 2 z

then _ 5 sT s_ 5 sT ðCAx 1 Cf ðxÞ 1 CBu 1 Kx 2 zÞ: VðtÞ

Design the controller as u 5 2 CAx 2 Cf ðxÞ 2 Kx 1 z 2 ηs;

where η . 0.

ð5:33Þ

190

CHAPTER 5 Sliding mode control based on LMI

Consider CB 5 I, then _ 5 sT s_ 5 sT ððCAx 1 Cf ðxÞ 1 CBuÞ 1 Kx 2 zÞ VðtÞ 5 sT ðCAx 1 Cf ðxÞ 1 u 1 Kx 2 zÞ 5 sT ð2 ηsÞ 5 2 ηjjsjj # 0

Since f ðxÞ 2 BCf ðxÞ 5 f ðxÞ 2

0 I

! ½ C1

0

I  f ðxÞ 5

C1 0

!

0

0

  0  C1 I 1

0

I f ðxÞ; 0

0 B C B B0 C 5 B C1 ð1Þ @ A @ I f2 ð2Þ C1 ð2Þ 1

0 0

10

1

0

CB B 1 0C [email protected] 0 0 1

C C A

f2 ð2Þ

0 B C B C 5 f ðxÞ; [email protected] A f2 ð2Þ

then f ðxÞ 2 BCf ðxÞ 5 0

and x_ 5 Ax 1 f ðxÞ 1 Bu 5 Ax 1 f ðxÞ 1 Bð2 CAx 2 Cf ðxÞ 2 Kx 1 zÞ 5 Ax 1 ðf ðxÞ 2 BCf ðxÞÞ 2 BCAx 2 BKx 1 Bz

:

5 ðA 2 BCA 2 BKÞx 1 Bz

Since sT s_ # 0, there exists t . t0 , we have s 5 0, i.e., z 5 2 Cx, then x_ 5 ðA 2 BCA 2 BKÞx 1 Bð2 CxÞ 5 ðA 2 BðK 1 C 1 CAÞÞx:

Define M 5 A 2 BðK 1 C 1 CAÞ, then x_ 5 Mx. To guarantee x-0 exponentially, choose the Lyapunov function as VðxÞ 5 xT x

Then αV ðxÞ 1 V_ ðxÞ 5 αxT x 1 ðMxÞT x 1 xT Mx 5 αxT x 1 xT M T x 1 xT Mx ; 5 xT ðαI 1 M T 1 MÞx

where α . 0.

ð5:34Þ

5.6 Sliding Mode Control for Chaotic Systems Based on LMI 191

_ # 0, choose To guarantee VðxÞ αI 1 M T 1 M , 0:

ð5:35Þ

Matrixes C and K can be solved by Eq. (5.35). From αV 1 V_ # 0, using Lemma 1.3, we have VðtÞ # Vð0Þexpð2αtÞ, i.e., if t-N, VðtÞ-0 and x-0, the system states converge to zero exponentially.

5.6.4 Simulation example Firstly, we test the Lorenz model (5.26); choose u1 5 u2 5 0 and  xð0Þ 5 0 21 0 . Simulation results are given in Fig. 5.5. Then considering Lorenz system (5.26), we use LMI program chap5_8lmi.m. The characteristic value of M T 1 M 5 AT 2 AT CT BT 1 A 2 BCA can be obtained as 2

3 2 40 40 5: 0

It can be seen that M T 1 M , 0 cannot be guaranteed if we use Eq. (5.36) to design the sliding mode function. If we use Eqs. (5.31) and (5.32) to design the sliding mode function, dynamic compensation z_ 5 Kx 2 z is added in the sliding mode function design, use program chap5_8dylmi.m, let M 5 A 2 BðK 1 C 1 CAÞ, characteristic value of M T 1 M is 2

3 2 37:2159 4 2 37:2159 5 2 20

It can be seen by using sliding mode function with dynamic compensation, the closed system Hurwitz conditions can be guaranteed.  Consider system (5.26), xð0Þ 5 0 21 0 , let α 5 10. We can get C and K from Eq. (5.35) by using LMI program chap5_8dylmi.m as follows:  C5  K5

29:2296 0

1 0 0 1



 273:0663 109:9039 0 : 0 0 17:608

CHAPTER 5 Sliding mode control based on LMI

Then  s 5 Cx 1 z 5

 29:2296x1 1 x2 1 z: x3

Use controller (5.33) and set η 5 1:0. Simulation results are given in Figs. 5.115.13. 1 x1 x2 x3

0.8 0.6 0.4

x1,x2,x3

0.2 0 –0.2 –0.4 –0.6 –0.8 –1

0

1

2

3

4

5 Time(s)

6

7

8

9

10

■ FIGURE 5.11 System states response.

20 u1 u2

u

0 –20 –40

0

1

2

3

4

5 Time(s)

6

7

8

9

10

0 z1 z2

–2 z

192

–4 –6 –8

0

1

■ FIGURE 5.12 Control input.

2

3

4

5 Time(s)

6

7

8

9

10

5.6 Sliding Mode Control for Chaotic Systems Based on LMI 193

0.5

x3

0

–0.5

–1 0.4 0.2 0 –0.2 x2

–0.4

0

0.2

0.4

0.6

0.8

x1

■ FIGURE 5.13 System states response.

Simulation programs: First simulation: model test

1. Simulink main program: chap5_7sim.mdl

2. Plant S function: chap5_7plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u);

1

194

CHAPTER 5 Sliding mode control based on LMI

case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 3; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 2; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [1,0,-1]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) u1 5 u(1); u2 5 u(2); a 5 10;b 5 8/3;r 5 28; sys(1) 5 a*(x(2) 2 x(1)); sys(2) 5 r*x(1) 2 x(2) 2 x(1)*x(3) 1 u1; sys(3) 5 2 b*x(3) 1 x(1)*x(2) 1 u2; function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

3. Plot program: chap5_7plot.m close all; x1 5 x(:,1); x2 5 x(:,2); x3 5 x(:,3); plot3(x3,x2,x1); xlabel('x3');ylabel('x2');zlabel('x1');

Second simulation: compensation

Sliding

mode

control

based

on

dynamic

5.6 Sliding Mode Control for Chaotic Systems Based on LMI 195

1. LMI design program LMI design program: chap5_8LMI.m clear all; close all; a 5 10;b 5 8/3;r 5 28; A5[2a

a

r 21 0

0

0; 0; 2 b];

B 5 [0 0; 1 0; 0 1]; M 5 sdpvar(3,3); C1 5 sdpvar(2,1); C 5 [C1,eye(2)]; M 5 A 2 B*C*A; F 5 set((M 1 M') , 0); solvesdp(F); M 5 double(M) display('the eigvalues of M is '); eig(M) display('the eigvalues of M 1 MT is '); eig(M 1 M') C 5 double(C) LMI with dynamic compensation program: chap5_8dyLMI.m clear all; close all; a 5 10;b 5 8/3;r 5 28; A5[2a

a

r

21

0

0

0; 0; 2 b];

B 5 [0 0; 1 0; 0 1]; M 5 sdpvar(3,3);

196

CHAPTER 5 Sliding mode control based on LMI

C1 5 sdpvar(2,1); K 5 sdpvar(2,3); C 5 [C1,eye(2)]; M 5 A 2 B*C*A 2 B*K 2 B*C; F 5 set((M 1 M') , 0); solvesdp(F); M 5 double(M) display('the eigvalues of M is '); eig(M) display('the eigvalues of M 1 MT is '); eig(M 1 M') C 5 double(C) K 5 double(K)

2. Simulink main program: chap5_8sim.mdl

3. Controller S function: chap5_8ctrl.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u);

5.6 Sliding Mode Control for Chaotic Systems Based on LMI 197

case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 3; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0 0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) x1 5 u(1); x2 5 u(2); x3 5 u(3); xp 5 [x1 x2 x3]'; z 5 [x(1) x(2)]'; C 5 [0.0497 1.0000 0; 0

0

K 5 [10.4476 0

1.0000];

8.9989 0; 0

9.4963];

dz 5 K*xp 2 z; sys(1) 5 dz(1); sys(2) 5 dz(2); function sys 5 mdlOutputs(t,x,u) z 5 [x(1) x(2)]'; x1 5 u(1); x2 5 u(2); x3 5 u(3); xp 5 [x1 x2 x3]'; a 5 10;b 5 8/3;r 5 28;

198

CHAPTER 5 Sliding mode control based on LMI

f 5 [0 2x1*x3 x1*x2]'; A5[2a

a

r

21

0

0

0; 0; 2 b];

C 5 [0.0497 1.0000 0; 0

0

1.0000];

K 5 [10.4476 8.9989 0; 0

0

9.4963];

S 5 C*xp 1 z; M 5 1; if M 55 1 xite 5 1.5; ut 5 2 C*A*xp 2 C*f 2 K*xp 1 z 2 xite*S; elseif M 55 2 alfa1 5 0.50;niu 5 1.0;xite1 5 2.0; Xite 5 niu 1 xite1*(norm(S))^(alfa1 2 1); ut 5 2 C*A*xp 2 C*f 2 K*xp 1 z 2 Xite*S; end sys(1) 5 ut(1); sys(2) 5 ut(2); sys(3) 5 z(1); sys(4) 5 z(2);

4. Plant S function: chap5_8plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 3; sizes.NumDiscStates 5 0;

5.6 Sliding Mode Control for Chaotic Systems Based on LMI 199

sizes.NumOutputs 5 3; sizes.NumInputs 5 2; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [1,0, 2 1]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) u1 5 u(1); u2 5 u(2); a 5 10;b 5 8/3;r 5 28; sys(1) 5 a*(x(2) 2 x(1)); sys(2) 5 r*x(1) 2 x(2) 2 x(1)*x(3) 1 u1; sys(3) 5 2 b*x(3) 1 x(1)*x(2) 1 u2; function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3);

5. Plot program: chap5_8plot.m close all; figure(1); plot(t,x(:,1),'r',t,x(:,2),'b',t,x (:,3),'k','linewidth',2); xlabel('time(s)');ylabel('x1,x2,x3'); legend('x1','x2','x3'); figure(2); subplot(211); plot(t,ut(:,1),'r',t,ut(:,2),'k','linewidth',2); xlabel('time(s)');ylabel('u'); legend('u1','u2'); subplot(212); plot(t,z(:,1),'r',t,z(:,2),'k','linewidth',2); xlabel('time(s)');ylabel('z'); legend('z1','z2'); figure(3); x1 5 x(:,1); x2 5 x(:,2); x3 5 x(:,3); plot3(x1,x2,x3); xlabel('x1');ylabel('x2');zlabel('x3');

200

CHAPTER 5 Sliding mode control based on LMI

grid on; display('the last x is'); G 5 size(x,1); x(G,:)

REFERENCES [1] J. Lo¨fberg, YALMIP: a free MATLAB Toolbox for rapid prototyping of optimization problems, ,http://www.mathworks.com/matlabcentral/newsreader/view_ thread/59636.. [2] M. Rehan, K.-S. Hong, S.S. Ge, Stabilization and tracking control for a class of nonlinear systems, Nonlinear Anal. Real World Appl. 12 (2011) 17861796. [3] H. Wang, Z. Han, Q. Xie, W. Zhang, Sliding mode control for chaotic systems based on LMI, Commun. Nonlinear Sci. Numer. Simul. 14 (2009) 14101417.

Chapter

6

Sliding mode control based on the RBF neural network Past research of the universal approximation theorem [1] has shown that any nonlinear function over a compact set with arbitrary accuracy can be approximated by the RBF neural network. There have been significant research efforts on the RBF neural control for nonlinear systems. The unknown nonlinearities in the system can be approximated by the RBF neural network whose weight value parameters are adjusted online according to adaptive laws for the purpose of controlling the output of the nonlinear system to track a given trajectory. The Lyapunov function is used to develop adaptive control algorithm based on the RBF model. The chattering action is decreased. In the books [2,3], we have designed a sliding mode controller based on RBF for several kinds of systems. In this section, we will design a sliding mode controller based on RBF for other kinds of systems. In Section 6.1, a simple adaptive sliding mode control based on RBF is introduced, unknown function f ðxÞ is approximated by the RBF neural network. In Section 6.2, an adaptive sliding mode control based on RBF compensation is discussed, to improve control performance, we design the RBF neural network to compensate disturbance acted on the control input. In Section 6.3, sliding mode control based on the RBF neural network with minimum parameter learning method is introduced, minimum parameter learning can be used in the RBF neural network to reduce the computational burden and increase real-time performance [4]. Using the minimum parameter learning, in this section, a sliding mode controller based on the RBF neural network is designed. In Section 6.4, based on Section 6.3, sliding mode controller based on RBF with MPL is designed for manipulators.

Sliding Mode Control Using MATLAB. DOI: http://dx.doi.org/10.1016/B978-0-12-802575-8.00006-0 Copyright © 2017 Tsinghua University Press Limited. Published by Elsevier Inc. All rights reserved.

201

202

CHAPTER 6 Sliding mode control based on the RBF neural network

6.1 A SIMPLE ADAPTIVE SLIDING MODE CONTROL BASED ON RBF 6.1.1 System description Consider a simple dynamic system as _ 1 u; θ€ 5 f ðθ; θÞ

ð6:1Þ

where θ is angle, u is control input. Eq. (6.1) can be written as x_1 5 x2 ; x_2 5 f ðxÞ 1 u

ð6:2Þ

where f ðxÞ is an unknown function. Let the desired output be xd, and denote e_ 5 x2 2 x_d :

e 5 x1 2 xd ;

Define the sliding mode function as _ s 5 ce 1 e;

c . 0;

ð6:3Þ

then s_ 5 ce_ 1 e€ 5 ce_ 1 x_2 2 x€d 5 ce_ 1 f ðxÞ 1 u 2 x€d :

_ From Eq. (6.3), we can see that if s-0, then e-0 and e-0.

6.1.2 RBF neural network approximation RBF networks are often used to approximate any unknown function [1]. The algorithms of RBF networks are: hj 5 exp

! jjx 2 cj jj2 ; 2b2j

f 5 W T hðxÞ 1 ε;

ð6:4Þ ð6:5Þ

where x is the input signal of the network, i is the input number of the network, j is the number of hidden layer nodes in the network, h 5 ½h1 ; h2 ; ?; hn T is the output of Gaussian function, W* is ideal neural network weight value, ε is approximation error of neural network, and ε # εN . If we use the RBF network to approximate f ðxÞ, the network input is  selected as x 5 x1 x2 T , and output of the RBF neural network is ^ T hðxÞ: f^ðxÞ 5 W

ð6:6Þ

6.1 A Simple Adaptive Sliding Mode Control Based on RBF 203

6.1.3 Sliding mode controller design Define the Lyapunov function as 1 1 ~T~ V 5 s2 1 W W; 2 2γ

ð6:7Þ

~ 5W ^ 2 W. where γ . 0, W ^ T hðxÞ 5 2 W ~ T hðxÞ 1 ε, then Since f ðxÞ 2 f^ðxÞ 5 W T hðxÞ 1 ε 2 W 1 T _^ 1 ~ T _^ V_ 5 s_s 1 W~ W 5 sðce_ 1 f ðxÞ 1 u 2 x€d Þ 1 W W γ γ

Design the sliding mode controller as u 5 2 ce_ 2 f^ðxÞ 1 x€d 2 ηsgnðsÞ;

ð6:8Þ

then 1 ~ T _^ V_ 5 sðf ðxÞ 2 f^ðxÞ 2 ηsgnðsÞÞ 1 W W γ _^ ~ TW ~ T hðxÞ 1 ε 2 ηsgnðsÞÞ 1 1 W 5 sð2 W γ   T 1 _ 5 εs 2 ηjsj 1 W~ W^ 2 shðxÞ γ

Design the adaptive law as _^ 5 γshðxÞ: W

ð6:9Þ

If we choose η . jεjmax , then V_ 5 εs 2 ηjsj # 0. From the above analysis, we can see that RBF approximation error can be overcome by the robust term ηsgnðsÞ. When V_  0, we have s  0, according to LaSalle invariance principle, the closed system is asymptotically stable, s-0 as t-N, and the convergence precision is related to η. ^ is limited. Since when Since V \$ 0, V_ # 0, V is limited as t-N, thus W ~ ^ _ V  0, we cannot get W  0, W cannot converge to W*.

6.1.4 Simulation example Consider a plant as x_1 5 x2 ; x_2 5 f ðxÞ 1 u

where f ðxÞ 5 10x1 x2 . The desired trajectory is chosen as xd 5 sint. The initial state of the plant is set as ½0:15 0. We adapt control law as Eq. (6.8) and adaptive law as Eq. (6.9), choose c 5 200, η 5 0:50 and γ 5 500.

204

CHAPTER 6 Sliding mode control based on the RBF neural network

The structure of RBF is chosen as 2-5-1. Consider the range of x1 and x2 ,  we choose ci 5 22 21 0 1 2 , bj 5 3:0, the initial value of each element of RBF weight matrix is set as 0.10. Simulation results are shown in Figs. 6.1 and 6.2.

position tracking

1

0

–1

–2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

0

2

4

6

8

10 12 Time(s)

14

16

18

20

4

6

8

10 Time(s)

speed tracking

2 1 0 –1 –2

■ FIGURE 6.1 Position and speed tracking.

40 30

f approximation

20 10 0 –10 –20 –30 –40

■ FIGURE 6.2 f ðxÞ and ^f ðxÞ.

0

2

12

14

16

18

20

6.1 A Simple Adaptive Sliding Mode Control Based on RBF 205

Simulation Programs:

1. Main program: chap6_1sim.mdl

2. S function of controller: chap6_1ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes global b c lama sizes 5 simsizes; sizes.NumContStates 5 5; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 4;

206

CHAPTER 6 Sliding mode control based on the RBF neural network

sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 0.1*ones(1,5); str 5 []; ts 5 [0 0]; c 5 0.5*[22

21 0

1

2;

22

21 0

1

2];

b 5 3.0; lama 5 10; function sys 5 mdlDerivatives(t,x,u) global b c lama xd 5 sin(t); dxd 5 cos(t); x1 5 u(2); x2 5 u(3); e 5 x1 2 xd; de 5 x2 2 dxd; s 5 lama*e 1 de; W 5 [x(1) x(2) x(3) x(4) x(5)]'; xi 5 [x1;x2]; h 5 zeros(5,1); for j 5 1:1:5 h(j) 5 exp( 2 norm(xi 2 c(:,j))^2/(2*b^2)); end gama 5 1500; for i 5 1:1:5 sys(i) 5 gama*s*h(i); end function sys 5 mdlOutputs(t,x,u) global b c lama xd 5 sin(t); dxd 5 cos(t); ddxd 5 -sin(t); x1 5 u(2); x2 5 u(3); e 5 x1 2 xd;

6.1 A Simple Adaptive Sliding Mode Control Based on RBF 207

de 5 x2 2 dxd; s 5 lama*e 1 de; W 5 [x(1) x(2) x(3) x(4) x(5)]; xi 5 [x1;x2]; h 5 zeros(5,1); for j 5 1:1:5 h(j) 5 exp( 2 norm(xi 2 c(:,j))^2/(2*b^2)); end fn 5 W*h; xite 5 1.50; %fn 5 10*x1 1 x2; %Precise f ut 5 2 lama*de 1 ddxd 2 fn 2 xite*sign(s); sys(1) 5 ut; sys(2) 5 fn;

3. S function of plant: chap6_1plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 2; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.15;0];

208

CHAPTER 6 Sliding mode control based on the RBF neural network

str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); f 5 10*x(1)*x(2); sys(1) 5 x(2); sys(2) 5 f 1 ut; function sys 5 mdlOutputs(t,x,u) f 5 10*x(1)*x(2); sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 f;

4. Plot program: chap6_1plot.m close all; figure(1); subplot(211); plot(t,x(:,1),'r',t,x(:,2),'b','linewidth',2); xlabel('time(s)');ylabel('position tracking'); subplot(212); plot(t,cos(t),'r',t,x(:,3),'b','linewidth',2); xlabel('time(s)');ylabel('speed tracking'); figure(2); plot(t,f(:,1),'r',t,f(:,3),'b','linewidth',2); xlabel('time(s)');ylabel('f approximation');

6.2 ADAPTIVE SLIDING MODE CONTROL BASED ON RBF COMPENSATION 6.2.1 System description Consider a plant as 

x_1 5 x2 ; x_2 5 f ðx; tÞ 1 bðu 2 δðx2 ÞÞ 1 dt

ð6:10Þ

where b . 0, dt is disturbance, jdtj # D, u is control input and δðx2 Þ is friction force. The desired angle signal is set as xd, and the control goals are x1 -xd and x2 -x_d . To improve control performance, we can design the RBF neural network to compensate δðx2 Þ.

6.2 Adaptive Sliding Mode Control Based on RBF Compensation

6.2.2 Sliding mode control based on RBF compensation The algorithm of the RBF networks is 

jjx 2 cj jj2 2b2j T δ 5 W hðxÞ 1 ε



hj 5 exp

;

ð6:11Þ

where x is the input signal of the network, i is the input number of the network, j is the number of hidden layer nodes in the network, h 5 ½h1 ; h2 ; . . .; hn T is the output of Gaussian function, W* is ideal neural network weight value, ε is approximation error of neural network, and ε # εmax , δ^ is output of RBF, If we use the RBF network to approximate f ðxÞ, the network input is  selected as x 5 x1 x2 T , and output of the RBF neural network is Consider x 5 x2 as input of RBF, we can design the RBF neural network to approximate δðx2 Þ, then the output of RBF is ^ T h: δ^ 5 W

ð6:12Þ

~ 5W ^ 2 W  , then Define W ^ h 5 ðW T 2 W ^ Þh 1 ε 5 2 W ~ h 1 ε: δ 2 δ^ 5 W T h 1 ε 2 W T

T

T

Define the tracking error as e 5 x1 2 xd , then e_ 5 x_1 2 x_d , and define the sliding mode function as _ s 5 ce 1 e;

ð6:13Þ

where c . 0. Then s_ 5 ce_ 1 e€ 5 ce_ 1 x€1 2 x€d 5 ce_ 1 f 1 bðu 2 δÞ 1 dt 2 x€d : 5 ce_ 1 f 1 bðu 2 δÞ 1 dt 2 x€d

Design the sliding mode controller as 1 ^ u 5 ð2 ce_ 2 f 1 x€d 2 ηsgnðsÞÞ 1 δ; b

where η \$ D 1 bεmax . Then ~ T h 2 εÞ 1 dt: s_ 52 ηsgnðsÞ 1 bðδ^ 2 δÞ 1 dt 5 2 ηsgnðsÞ 1 bðW

ð6:14Þ

209

210

CHAPTER 6 Sliding mode control based on the RBF neural network

Design the Lyapunov function as 1 1 ~T~ L 5 s2 1 γ W W; 2 2

ð6:15Þ

where γ . 0. Then _^ _~ 5 2 ηjsj 1 sUdt 1 sbðW ~ TW ~ TW ~ T h 2 εÞ 1 γ W V_ 5 s_s 1 γ W _^ ~ T ðsbh 1 γ WÞ 5 2 ηjsj 1 sUdt 2 sbε 1 W

Design the adaptive law as _^ 5 2 1 sbh: W γ

ð6:16Þ

Then V_ 5 2 ηjsj 1 ðdt 2 bεÞs # 0

When V_  0, we have s  0, according to LaSalle invariance principle, the closed system is asymptotically stable, s-0 as t-N, and the convergence precision is related to η. ^ is limited. Since when Since V \$ 0, V_ # 0, V is limited as t-N, thus W ~ ^ _ V  0, we cannot get W  0, W cannot converge to W*.

6.2.3 Simulation example Consider a plant as 

x_1 5 x2 ; x_2 5 2 25x2 1 133ðu 2 δðx2 ÞÞ 1 10sint

where δðx2 Þ is considered as friction model and δðx2 Þ 5 x2 1 0:01sgnðx2 Þ. Consider Eq. (6.10), we have f ðx; tÞ 5 2 25x2 , b 5 133, D 5 10. The desired trajectory is xd 5 sint. The initial states of the plant set as ½1; 0. We adapt the control law as Eq. (6.14) and the adaptive law as Eq. (6.16), choose c 5 5, η 5 D 1 0:5 and γ 5 0:10. In control law (6.14), the saturation function is used instead of the switch function, and Δ 5 0.02. The structure of RBF is chosen as 1-5-1. Consider the range of x2; we  choose ci 5 21:0 20:5 0 0:5 1:0 , bj 5 1:0, the initial value of each element of RBF weight matrix is set as 0.0. Simulation results are shown in Figs. 6.36.5.

6.2 Adaptive Sliding Mode Control Based on RBF Compensation

angle tracking

2 ideal angle signal tracking signal

1 0 –1 –2

0

1

2

3

4

5 Time(s)

6

7

8

9

10

speed tracking

2 ideal speed signal tracking signal

1 0 –1 –2

0

1

2

3

4

5 Time(s)

6

7

8

9

10

■ FIGURE 6.3 Angle and angle speed tracking.

1.5

Control input,u

1

0.5

0

–0.5

–1

–1.5

■ FIGURE 6.4 Control input.

0

1

2

3

4

5 Time(s)

6

7

8

9

10

211

212

CHAPTER 6 Sliding mode control based on the RBF neural network

1.5 true delta delta estimation 1

delta

0.5

0

–0.5

–1

–1.5 0

1

2

3

4

5 Time(s)

6

7

8

^ 2 Þ. ■ FIGURE 6.5 δðx2 Þ and δðx Simulation Programs:

1. Main program: chap6_2sim.mdl.m

9

10

6.2 Adaptive Sliding Mode Control Based on RBF Compensation

2. S function of controller: chap6_2ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 5; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 []; function sys 5 mdlOutputs(t,x,u) x1d 5 sin(t); dx1d 5 cos(t); ddx1d 5 2 sin(t); x1 5 u(2); x2 5 u(3); deltap 5 u(5); e 5 x1 2 x1d; de 5 x2 2 dx1d; c 5 5; s 5 c*e 1 de; D 5 1.0; xite 5 D 1 0.50; fai 5 0.02;

213

214

CHAPTER 6 Sliding mode control based on the RBF neural network

if abs(s) , 5 fai sat 5 s/fai; else sat 5 sign(s); end b 5 133; f 5 2 25*x2; ut 5 1/b*( 2 c*de 2 f 1 ddx1d 2 xite*sat) 1 deltap; sys(1) 5 ut; sys(2) 5 s;

3. RBF Approximation : chap6_2rbf.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes global cij bj c sizes 5 simsizes; sizes.NumContStates 5 5; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 0*ones(1,5); str 5 []; ts 5 []; cij 5 1*[ 2 1 2 0.5 0 0.5 1]; bj 5 1.0; function sys 5 mdlDerivatives(t,x,u) global cij bj

6.2 Adaptive Sliding Mode Control Based on RBF Compensation

s 5 u(1); x2 5 u(3); b 5 133; xi 5 x2; h 5 zeros(5,1); for j 5 1:1:5 h(j) 5 exp( 2 norm(xi 2 cij(:,j))^2/(2*bj^2)); end gama 5 0.10; for i 5 1:1:5 sys(i) 5 2 1/gama*s*b*h(i); end function sys 5 mdlOutputs(t,x,u) global cij bj s 5 u(1); x2 5 u(3); xi 5 x2; W 5 [x(1) x(2) x(3) x(4) x(5)]'; h 5 zeros(5,1); for j 5 1:1:5 h(j) 5 exp( 2 norm(xi 2 cij(:,j))^2/(2*bj^2)); end deltap 5 W'*h; sys(1) 5 deltap;

4. S function of plant: chap6_2plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end

215

216

CHAPTER 6 Sliding mode control based on the RBF neural network

function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.2 0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); delta 5 1*x(2) 1 0.01*sign(x(2)); sys(1) 5 x(2); sys(2) 5 2 25*x(2) 1 133*(ut 2 delta) 1 1.0*sin(t); function sys 5 mdlOutputs(t,x,u) delta 5 1*x(2) 1 0.01*sign(x(2)); sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 delta;

5. Plot program: chap6_2plot.m close all; figure(1); subplot(211); plot(t,y(:,1),'r',t,y(:,2),'-.k','linewidth',2); xlabel('time(s)');ylabel('angle tracking'); legend('ideal angle signal','tracking signal'); subplot(212); plot(t,cos(t),'r',t,y(:,3),'-.k','linewidth',2); xlabel('time(s)');ylabel('speed tracking'); legend('ideal speed signal','tracking signal'); figure(2); plot(t,ut(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('Control input,u'); figure(3); plot(t,y(:,3),'r',t,deltap(:,1),'-.k','linewidth',2); xlabel('time(s)');ylabel('delta'); legend('true delta','delta estimation');

6.3 Sliding Mode Control Based on RBF with MPL

6.3 SLIDING MODE CONTROL BASED ON RBF WITH MPL The minimum parameter learning (MPL) method [4] can decrease the number of online adaptive parameters to only one, which can be used in the RBF neural network to reduce the computational burden and increase real-time performance. Using minimum parameter learning, in this section, a sliding mode control based on RBF is introduced.

6.3.1 System description Consider a second nonlinear system as _ 1 gðθ; θÞu _ 1 dðtÞ; θ€ 5 f ðθ; θÞ

ð6:17Þ

_ in unknown nonlinear function, gðθ; θÞ _ is known nonlinear where f ðθ; θÞ function, uAR and y 5 θAR are input and output, dðtÞ is disturbance, jdðtÞj # D. _ we have Denote x1 5 θ, x2 5 θ, x_1 5 x2 : x_2 5 f ðx1 ; x2 Þ 1 gðx1 ; x2 Þu 1 dðtÞ

Define the ideal angle as x1d , and angle tracking error as e 5 x1 2 x1d , design the sliding mode function as s 5 e_ 1 ce;

ð6:18Þ

where c . 0. Then _ s_ 5 e€ 1 ce_ 5 x€1 1 ce_ 2 x€1d 5 f ðx1 ; x2 Þ 1 gðx1 ; x2 Þu 1 d 2 x€1d 1 ce:

ð6:19Þ

In this section, we design the RBF neural network with MPL to approximate f ðx1 ; x2 Þ.

6.3.2 Sliding mode control based on RBF The algorithm of the RBF network is ! jjx 2 cj jj2 hj 5 exp 2 ; 2b2j

j 5 1; . . .; m

f ðx1 ; x2 Þ 5 W T hðxÞ 1 ε

where x is the input signal of the network, j is the number of hidden layer nodes in the network, h 5 ½h1 ; h2 ; . . .; hn T is the output of Gaussian function,

217

218

CHAPTER 6 Sliding mode control based on the RBF neural network

W* is ideal neural network weight value, ε is approximation error of neural network, and ε # εN . If we use the RBF network to approximate f ðx1 ; x2 Þ, the network input is selected as x 5 ½x1 x2 T , and output of the RBF neural network can be expressed as ^ T hðxÞ: f^ðxÞ 5 W

ð6:20Þ

Using minimum parameter learning [4], define φ 5 jjWjj2 , where φ is a positive constant, let φ^ be an estimation of φ and define φ~ 5 φ^ 2 φ. Design the controller as u5

  1 1 2 sφ^ hT h 1 θ€ d 2 ce_ 2 ηsgnðsÞ 2 μs ; _ 2 gðθ; θÞ

ð6:21Þ

where η \$ εN 1 D, μ . 0. Substituting Eq. (6.21) into Eq. (6.19), we then have 1 s_ 5 W T h 1 ε 2 sφ^ hT h 2 ηsgnðsÞ 1 d 2 μs: 2

ð6:22Þ

The Lyapunov function is designed as 1 1 ~2 φ ; L 5 s2 1 2 2γ

where γ . 0. Consider Eqs. (6.21) and (6.22); we have   1 _ 1 ^ T 1 _ h 2 ηsgnðsÞ 1 d 2 μs 1 φ~ φ^ L_ 5 s_s 1 φ~ φ^ 5 s W T h 1 ε 2 sφh γ 2 γ 1 1 1 ^ T 1 _ # s2 φhT h 1 2 s2 φh h 1 ðε 1 dÞs 2 η 1 φ~ φ^ 2 μs2 2 2 2 γ 1 ~ T 1 1 _ 5 2 s2 φh h 1 1 ðε 1 dÞs 2 ηjsj 1 φ~ φ^ 2 μs2 : 2 2 γ   1 1_ 1 5 φ~ 2 s2 hT h 1 φ^ 1 1 ðε 1 dÞs 2 ηjsj 2 μs2 2 γ 2   1 1_ 1 # φ~ 2 s2 hT h 1 φ^ 1 2 μs2 2 γ 2

Design the adaptive law as _ γ ^ φ^ 5 s2 hT h 2 κγφ; 2

where κ . 0.

ð6:23Þ

6.3 Sliding Mode Control Based on RBF with MPL

Then   1 κ 2 1 κ 2 κ 2 1 φ 1 : L_ # 2κφ~ φ^ 1 2 μs2 # 2 ðφ~ 2 φ2 Þ 1 2 μs2 5 2 φ~ 2 μs2 1 2 2 2 2 2 2

Define κ 5

2μ γ,

then

      μ 2 κ 1 1 ~2 1 2 κ 1 φ 1 s 1 φ2 1 522μL1Q; L_ #2 φ~ 2 μs21 φ2 1 522μ γ 2 2 2γ 2 2 2

where Q 5 κ2 φ2 1 12. Use Lemma 1.3; the solution of L_ # 2 2μL 1 Q is L#

  Q Q 22μt 1 Lð0Þ 2 e ; 2μ 2μ

then 2μ 2 κ 2 1 φ 11 φ 1 Q κφ2 1 1 φ2 1 γ 2 2 5 5 : 5 5 1 lim L 5 t-N 2μ 4μ 4μ 2μ 4μ 2γ

ð6:24Þ

Form above, we can see that the convergence precision depends on γ and μ. Remark 1: s2 φhT h115s2 jjWjj2 hT h115s2 jjWjj2 jjhjj2 115 s2 jjW T hjj2 1 1 \$ 2sW T h, i.e., sW T h # 12 s2 φhT h 1 12; 2 2 ~ ~ 1 φ2 \$ 0 and φ~ 2 1 Remark 2: since ðφ1φÞ \$ 0, then φ~ 1 2φφ ~ φ^ 2 φÞ ~ 1 φ2 \$ 0, i.e., 2φ~ φ^ \$ φ~ 2 2 φ2 . 2φð

However, the shortcoming of the minimum parameter learning method is that its approximation precision cannot be guaranteed.

6.3.3 Simulation example Consider an inverted pendulum as x_1 5 x2 gsinx1 2 mlx22 cosx1 sinx1 =ðmc 1 mÞ cosx1 =ðmc 1 mÞ ; x_2 5 1 u lð4=3 2 mcos2 x1 =ðmc 1 mÞÞ lð4=3 2 mcos2 x1 =ðmc 1 mÞÞ

where f ðx1 ; x2 Þ 5

gsinx1 2 mlx22 cosx1 sinx1 =ðmc 1 mÞ lð4=3 2 mcos2 x1 =ðmc 1 mÞÞ ,

cosx1 =ðmc 1 mÞ gðx1 ; x2 Þ 5 lð4=3 2 mcos2 x1 =ðmc 1 mÞÞ,

x1 and x2 are angle and angle speed, respectively, g 5 9:8, mc 5 1 is cart mass, m 5 0:1 is the mass of pendulum, l 5 0:5 is half the length of the pendulum and u is control input.

219

220

CHAPTER 6 Sliding mode control based on the RBF neural network

Let the ideal angle be x1d 5 0:1sinðtÞ. The initial states of the plant is ½π=60; 0, we use control law as Eq. (6.21) and adaptive law as Eq. (6.23), choose γ 5 0:05, c 5 15 and η 5 0:1. Simulation results are shown in Figs. 6.6 and 6.7.

angle tracking

0.2 ideal angle angle tracking

0.1 0 –0.1 –0.2

0

2

4

6

8

10

Time(s)

speed tracking

0.5 ideal speed speed tracking

0 –0.5 –1 –1.5

0

2

4

6

8

10

Time(s)

■ FIGURE 6.6 Angle and angle speed tracking.

50 0

Control input,u

–50 –100 –150 –200 –250 –300

0

2

4

6 Time(s)

■ FIGURE 6.7 Control input.

8

10

6.3 Sliding Mode Control Based on RBF with MPL

Simulation programs

1. Main program: chap6_3sim.mdl

2. S function of controller: chap6_3ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes global cc bb c miu sizes 5 simsizes; sizes.NumContStates 5 1; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1;

221

222

CHAPTER 6 Sliding mode control based on the RBF neural network

sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 0; str 5 []; ts 5 []; cc 5 [ 2 2 2 1 0 1 2; 2 2 2 1 0 1 2]; bb 5 1; c 5 200; miu 5 30; function sys 5 mdlDerivatives(t,x,u) global cc bb c miu x1d 5 u(1); dx1d 5 u(2); x1 5 u(3); x2 5 u(4); e 5 x1 2 x1d; de 5 x2 2 dx1d; s 5 c*e 1 de; xi 5 [x1;x2]; h 5 zeros(5,1); for j 5 1:1:5 h(j) 5 exp( 2 norm(xi 2 cc(:,j))^2/(2*bb*bb)); end gama 5 150; k 5 2*miu/gama; sys(1) 5 gama/2*s^2*h'*h 2 k*gama*x; function sys 5 mdlOutputs(t,x,u) global cc bb c miu x1d 5 u(1); dx1d 5 u(2); x1 5 u(3); x2 5 u(4); e 5 x1 2 x1d; de 5 x2 2 dx1d; thd 5 0.1*sin(t); dthd 5 0.1*cos(t); ddthd 5 2 0.1*sin(t); s 5 c*e 1 de;

6.3 Sliding Mode Control Based on RBF with MPL

fi 5 x; xi 5 [x1;x2]; h 5 zeros(5,1); for j 5 1:1:5 h(j) 5 exp( 2 norm(xi 2 cc(:,j))^2/(2*bb*bb)); end g 5 9.8;mc 5 1.0;m 5 0.1;l 5 0.5; S 5 l*(4/3-m*(cos(x1))^2/(mc 1 m)); gx 5 cos(x1)/(mc 1 m); gx 5 gx/S; xite 5 0.5; miu 5 40; ut 5 1/gx*( 2 0.5*s*fi*h'*h 1 ddthd 2 c*de 2 xite*sign(s) 2 miu*s); sys(1) 5 ut;

3. S function of plant: chap6_3plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [pi/60 0];

223

224

CHAPTER 6 Sliding mode control based on the RBF neural network

str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) g 5 9.8;mc 5 1.0;m 5 0.1;l 5 0.5; S 5 l*(4/3 2 m*(cos(x(1)))^2/(mc 1 m)); fx 5 g*sin(x(1)) 2 m*l*x(2)^2*cos(x(1))*sin(x(1))/(mc 1 m); fx 5 fx/S; gx 5 cos(x(1))/(mc 1 m); gx 5 gx/S; %%%%%%%%% dt 5 0.1*10*sin(t); %%%%%%%%% sys(1) 5 x(2); sys(2) 5 fx 1 gx*u 1 dt; function sys 5 mdlOutputs(t,x,u) g 5 9.8; mc 5 1.0; m 5 0.1; l 5 0.5; S 5 l*(4/3 2 m*(cos(x(1)))^2/(mc 1 m)); fx 5 g*sin(x(1)) 2 m*l*x(2)^2*cos(x(1))*sin(x(1))/(mc 1 m); fx 5 fx/S; sys(1) 5 x(1); sys(2) 5 x(2);

4. Plot program: chap6_3plot.m close all; figure(1); subplot(211); plot(t,y(:,1),'r',t,y(:,2),'b:','linewidth',2); xlabel('time(s)');ylabel('angle tracking'); legend('ideal angle','angle tracking'); subplot(212); plot(t,0.1*cos(t),'r',t,y(:,3),'b:','linewidth',2); xlabel('time(s)');ylabel('speed tracking'); legend('ideal speed','speed tracking'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('Control input,u');

6.4 Sliding Mode Control Based on RBF with MPL for Manipulators

6.4 SLIDING MODE CONTROL BASED ON RBF WITH MPL FOR MANIPULATORS Based on Section 6.3, in this section, we discuss about sliding mode controller design based on RBF with MPL for manipulators.

6.4.1 System description Consider the dynamic equation of n link manipulators as DðqÞ€q 1 Cðq; q_ Þ_q 1 GðqÞ 1 Fð_qÞ 1 τ d 5 τ;

ð6:25Þ

where D(q) is the inertia matrix, Cðq; q_ Þ is the coriolis/centripetal matrix, G(q) is the gravity vector, Fð_qÞ is friction force, τ d denotes unknown disturbance and τ is the control input. Tracking errors are defined as eðtÞ 5 qd ðtÞ 2 qðtÞ:

The control goals are eðtÞ-0 and e_ ðtÞ-0 as t-N.

6.4.2 RBF neural network design Define the sliding mode function as r 5 e_ 1 Λe;

ð6:26Þ

where Λ 5 ΛT . 0, then q_ 5 2r 1 q_ d 1 Λe D_r 5 Dð€qd 2 q€ 1 Λ_eÞ 5 Dð€qd 1 Λ_eÞ 2 D€q 5 Dð€qd 1 Λ_eÞ 1 Cq_ 1 G 1 F 1 τ d 2 τ 5 Dð€qd 1 Λ_eÞ 2 Cr 1 Cð_qd 1 ΛeÞ 1 G 1 F 1 τ d 2 τ

;

ð6:27Þ

5 2 Cr 2 τ 1 f 1 τ d

where f 5 Dð€qd 1 Λ_eÞ 1 Cð_qd 1 ΛeÞ 1 G 1 F. In practical engineering, modeling information in Eq. (6.25) is often unknown, in this section, we use the RBF neural network with MPL to approximate f function [5], then we can design the controller without modelling. For the ith joint, the algorithm of the RBF network is hij 5 expðjjxi 2 cij jj2 =σ2ij Þ; fi 5 wTi hi 1 εi ;

j 5 1; 2; . . .; m ð6:28Þ

225

226

CHAPTER 6 Sliding mode control based on the RBF neural network

where xi 5 ½ ei e_ i qdi q_ di q€ di  are input of RBF, hi 5 ½hi1 hi2 ?him T , εi is approximation error and wi is ideal weight value. According to the fi expression, the inputs of RBF are chosen as X5½e

then

e_

qd

q_ d

q€ d ;

2

3 2 T wT1 h1 1 ε1 w1 h1 6 7 6 ^ 6 7 6 ^ 6 7 6 T 7 6 T f 5 ½ f1 ?fi ?fn T 5 6 6 wi hi 1 εi 7 5 6 wi hi 6 7 6 ^ 4 5 4 ^ wTn hn 1 εn wTn hn

3 7 7 7 7 1 ε; 7 7 5

where ε 5 ½ε1 ?εi ?εn T , jjεjj # εN .

6.4.3 Controller design and analysis based on MPL Define w^ i as an estimation of wi , then define ~ i 5 wi 2 w^ i ; w

jjwi jjF # wimax :

Define the minimum parameter as φ 5 max1 # i # n fjjwi jj2 g [4], where φ is a positive constant, and φ^ is an estimation of φ, φ~ 5 φ^ 2 φ. 2

3 2 3 h1 w1 ~ ^ according to the GL operator [6], W, Define W54 ^ 5; H54 ^ 5, W5W2 wn hn 2 T 3 2 T 3 2 T 3 w1 h1 r1 r1 h1 h1 5, then f can we have W3 H 5 4 ^ 5, r3 r 5 4 ^ 5 and H3H 5 4 ^ T T T wn hn rn rn hn hn be expressed as f 5 W3 H 1 ε:

Design the control law as τ5

1^ φr3 ðH3 HÞ 1 K v r 2 v; 2

ð6:29Þ

where v is the robust term to overcome approximation error ε. The robust term v is designed as v 5 2 ðεN 1 bd ÞsgnðrÞ;

where jjτ d jj # bd .

ð6:30Þ

6.4 Sliding Mode Control Based on RBF with MPL for Manipulators

Substituting Eq. (6.29) into Eq. (6.27), we have 1 D_r 5 2 ðK v 1 CÞr 2 φ^ r3ðH3HÞ 1 ðf 1 τ d Þ 1 v: 2

ð6:31Þ

Define the Lyapunov function as 1 1 ~2 φ ; L 5 rT Dr 1 2 2γ

where γ . 0. Then 1 _ 1 _ 1 φ~ φ^ L_ 5 rT D_r 1 rT Dr 2 γ   1 1 _ 1 _ 5 rT 2ðK v 1 CÞr 2 φ^ r3ðH3HÞ 1 ðf 1 τ d Þ 1 v 1 rT Dr 1 φ~ φ^ 2 2 γ   1 1 _ 2 2CÞr 1 1 φ~ φ_^ 5 rT 2K v r 2 φ^ r3ðH3HÞ 1 W3H 1 ðε 1 τ d 1 vÞ 2 rT ðD 2 2 γ   1^ 1 ~ _^ T T T 5 r 2 φ r3ðH3HÞ 1 W3H 2 r K v r 1 r ðε 1 τ d 1 vÞ 1 φφ 2 γ

Since _ 2 2CÞr 5 0 rT ðD rT ðε 1 τ d 1 vÞ 5 rT ðε 1 τ d 2 ðεN 1 bd ÞsgnðrÞÞ # 0 2 2 T 3 w1 h1 n X rT ½W3H 5 4 r1 ? rn 4 ^ 5 5 r1 wT1 h1 1 ? 1 rn wTn hn 5 ri wTi hi T i51 wn hn ri2 φ hTi hi 1 1 \$ ri2 jjwi jj2 jjhi jj2 1 1 \$ 2ri wTi hi ; 1 1 1 1 ri wTi hi # ri2 φhTi hi 1 5 ri2 φhTi hi 1 2 2 2 2

which is

n 1 X n r2 hT hi 1 rT ½W3H # φ 2 i51 i i 2 02 3 2 T 31 r1 h h   B6 7 6 1 1 7C 1 1  rT 2 φ^ r3ðH3HÞ 5 2 φ^ r1 ? rn @4 ^ 534 ^ 5A 2 2 T rn h hn 3 n 2 r1 hT1 h1 6 ; 1  7 5 2 φ^ r1 ? rn 4 ^ 5 2 rn hTn hn n

1 1 X 5 2 φ^ r12 jjh1 jj2 1 ? 1 rn2 jjhn jj2 5 2 φ^ r 2 jjhi jj2 2 2 i51 i

where n denotes number of joints, for second link manipulators, n 5 2.

227

228

CHAPTER 6 Sliding mode control based on the RBF neural network

Then we have n n 1 X 1 X n 1 _ ri2 jjhi jj2 1 φ ri2 hTi hi 1 1 φ~ φ^ 2 rT K v r L_ # 2 φ^ 2 i51 2 i51 2 γ n 1 X n 1 _ 5 2 φ~ r 2 jjhi jj2 1 1 φ~ φ^ 2 rT K v r 2 i51 i 2 γ

:

! n X 1 1 n _ 2 2 r jjhi jj 1 φ^ 1 2 rT K v r 5 φ~ 2 2 i51 i γ 2

Design the adaptive law as n _ γX 2 r jjhi jj2 : φ^ 5 2 i51 i

ð6:32Þ

Then n L_ # 2 rT K v r: 2

To guarantee L_ # 0, we must ensure n2 # rT K v r, then we have jjrjj #

rﬃﬃﬃﬃﬃﬃﬃﬃ n : 2K v

ð6:33Þ

6.4.4 Simulation example Consider dynamic equation of two link manipulators as DðqÞ€q 1 Cðq;_qÞ_q 1 GðqÞ 1 Fð_qÞ 1 τ d 5 τ;

where 2 DðqÞ 5 4

p1 1 p2 1 2p3 cosq2

p2 1 p3 cosq2

p2 1 p3 cosq2

p2

2 Cðq; q_ Þ 5 4 " GðqÞ 5

3 5;

2p3 q_2 sinq2

2p3 ðq_1 1 q_2 Þsinq2

p3 q_1 sinq2

0

p4 gcosq1 1 p5 gcosðq1 1 q2 Þ

p5 gcosðq1 1 q2 Þ  Fð_qÞ 5 0:2sgnð_qÞ; τ d 5 0:2sinðtÞ

3 5

# ; 0:2sinðtÞ T

6.4 Sliding Mode Control Based on RBF with MPL for Manipulators

The initial states of the plant are chosen as ½0:50; 0; 0:50; 0, p 5 ½p1 ; p2 ; p3 ; p4 ; p5  5 ½2:9; 0:76; 0:87; 3:04; 0:87. The ideal angle signals of two joints are set as q1d 5 0:1sint and q2d 5 0:1sint. In RBF neural network design, according to f ðxÞ expression, the inputs are  chosen as z 5 e e_ qd q_ d q€ d , and according to the inputs range, 2 3 2 1 0:5 0 0:5 1 6 7 6 2 1 0:5 0 0:5 1 7 6 7 7 we choose c 5 0:1 3 6 6 2 1 0:5 0 0:5 1 7, bi 5 0:50, i 5 1; . . .; 5, 6 7 4 2 1 0:5 0 0:5 1 5 2 1 0:5 0 0:5 1 and initial weight values are set as zero.

position tracking for link 2

position tracking for link 1

We adapt control law (6.29) and adaptive law (6.32), choose K v 5 diagf200; 200g, Λ 5 diagf50; 50g, εN 5 0:50, bd 5 0:20 and γ 5 500, the saturation function is used instead of the switch function, and set Δ 5 0:01. The simulation results are shown in Figs. 6.86.10.

0.6 Ideal position signal tracking signal

0.4 0.2 0 –0.2

0

1

2

3

4

5 Time(s)

6

7

8

9

10

0.6 Ideal position signal tracking signal

0.4 0.2 0 –0.2

0

1

2

■ FIGURE 6.8 Angle tracking of first link and second link.

3

4

5 Time(s)

6

7

8

9

10

229

CHAPTER 6 Sliding mode control based on the RBF neural network

speed tracking for link 2

speed tracking for link 1

230

5 0 Ideal speed signal tracking signal

–5 –10 –15

0

1

2

3

4

5 Time(s)

6

7

8

9

10

5 0 Ideal speed signal tracking signal

–5 –10 –15

0

1

2

3

4

5 Time(s)

6

7

8

9

10

■ FIGURE 6.9 Angle speed tracking of first link and second link.

control input of link 1

5000

0

–5000

–10000 0

1

2

3

4

5 6 aTime(s)

7

8

9

10

1

2

3

4

5 Time(s)

7

8

9

10

control input of link 2

2000 0 –2000 –4000 –6000

0

■ FIGURE 6.10 Control input of first link and second link.

6

6.4 Sliding Mode Control Based on RBF with MPL for Manipulators

Simulation Programs:

1. Main simulink program: chap6_4sim.mdl

2. S function of input: chap6_4input.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 6; sizes.NumInputs 5 0; sizes.DirFeedthrough 5 0;

231

232

CHAPTER 6 Sliding mode control based on the RBF neural network

sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) qd1 5 0.1*sin(t); d_qd1 5 0.1*cos(t); dd_qd1 5 2 0.1*sin(t); qd2 5 0.1*sin(t); d_qd2 5 0.1*cos(t); dd_qd2 5 2 0.1*sin(t); sys(1) 5 qd1; sys(2) 5 d_qd1; sys(3) 5 dd_qd1; sys(4) 5 qd2; sys(5) 5 d_qd2; sys(6) 5 dd_qd2;

3. S function of controller: chap6_4ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes global node c b Fai node 5 5; c 5 0.1*[ 2 1 2 0.5 0 0.5 1; 2 1 2 0.5 0 0.5 1; 2 1 2 0.5 0 0.5 1; 2 1 2 0.5 0 0.5 1; 2 1 2 0.5 0 0.5 1]; b 5 0.50; Fai 5 50*eye(2);

6.4 Sliding Mode Control Based on RBF with MPL for Manipulators

sizes 5 simsizes; sizes.NumContStates 5 1; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 10; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) global node c b Fai qd1 5 u(1); d_qd1 5 u(2); dd_qd1 5 u(3); qd2 5 u(4); d_qd2 5 u(5); dd_qd2 5 u(6); q1 5 u(7); d_q1 5 u(8); q2 5 u(9); d_q2 5 u(10); e1 5 qd1 2 q1; e2 5 qd2 2 q2; de1 5 d_qd1 2 d_q1; de2 5 d_qd2 2 d_q2; e 5 [e1;e2]; de 5 [de1;de2]; r 5 de 1 Fai*e; qd 5 [qd1;qd2]; dqd 5 [d_qd1;d_qd2]; ddqd 5 [dd_qd1;dd_qd2]; z1 5 [e(1);de(1);qd(1);dqd(1);ddqd(1)]; z2 5 [e(2);de(2);qd(2);dqd(2);ddqd(2)]; h1 5 zeros(7,1); h2 5 zeros(7,1); for j 5 1:1:node h1(j) 5 exp( 2 norm(z1 2 c(:,j))^2/(b*b)); h2(j) 5 exp( 2 norm(z2 2 c(:,j))^2/(b*b)); end

233

234

CHAPTER 6 Sliding mode control based on the RBF neural network

gama 5 500; sumi 5 (r(1))^2*norm(h1)^2 1 (r(2))^2*norm(h2)^2; sys(1) 5 gama/2*sumi; function sys 5 mdlOutputs(t,x,u) global node c b Fai qd1 5 u(1); d_qd1 5 u(2); dd_qd1 5 u(3); qd2 5 u(4); d_qd2 5 u(5); dd_qd2 5 u(6); q1 5 u(7); d_q1 5 u(8); q2 5 u(9); d_q2 5 u(10); q 5 [q1;q2]; e1 5 qd1 2 q1; e2 5 qd2 2 q2; de1 5 d_qd1 2 d_q1; de2 5 d_qd2 2 d_q2; e 5 [e1;e2]; de 5 [de1;de2]; r 5 de 1 Fai*e; qd 5 [qd1;qd2]; dqd 5 [d_qd1;d_qd2]; ddqd 5 [dd_qd1;dd_qd2]; faip 5 x(1); z1 5 [e(1);de(1);qd(1);dqd(1);ddqd(1)]; z2 5 [e(2);de(2);qd(2);dqd(2);ddqd(2)]; h1 5 zeros(7,1); h2 5 zeros(7,1); for j 5 1:1:node h1(j) 5 exp( 2 norm(z1 2 c(:,j))^2/(b*b)); h2(j) 5 exp( 2 norm(z2 2 c(:,j))^2/(b*b)); end p 5 [2.9 0.76 0.87 3.04 0.87]; D 5 [p(1) 1 p(2) 1 2*p(3)*cos(q2) p(2) 1 p(3)*cos(q2); p(2) 1 p(3)*cos(q2) p(2)]; H 5 [h1;h2];

6.4 Sliding Mode Control Based on RBF with MPL for Manipulators

Kv 5 200*eye(2); epN 5 0.50; bd 5 0.2; M 5 2; if M 55 1 sat 5 sign(r); elseif M 55 2 %Saturated function fai0 5 0.01; if norm(r) , 5 fai0 sat 5 r/fai0; else sat 5 sign(r); end end v 5 -(epN 1 bd)*sat; Kw 5 Kv*r; Dr 5 D*r; %tol 5 (r.*fai)/2*(H.*H) 1 Kv*r-v; tol(1) 5 faip/2*r(1)*norm(h1)^2 1 Kw(1) 2 v(1); tol(2) 5 faip/2*r(2)*norm(h2)^2 1 Kw(2) 2 v(2); sys(1) 5 tol(1); sys(2) 5 tol(2);

4. S function of plant: chap6_4plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes global p g sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4;

235

236

CHAPTER 6 Sliding mode control based on the RBF neural network

sizes.NumInputs 5 2; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.50 0 0.50 0]; str 5 []; ts 5 []; p 5 [2.9 0.76 0.87 3.04 0.87]; g 5 9.8; function sys 5 mdlDerivatives(t,x,u) global p g D 5 [p(1) 1 p(2) 1 2*p(3)*cos(x(3)) p(2) 1 p(3)*cos(x(3)); p(2) 1 p(3)*cos(x(3)) p(2)]; C 5 [-p(3)*x(4)*sin(x(3)) 2 p(3)*(x(2) 1 x(4))*sin(x(3)); p(3)*x(2)*sin(x(3)) 0]; G 5 [p(4)*g*cos(x(1)) 1 p(5)*g*cos(x(1) 1 x(3)); p(5)*g*cos(x(1) 1 x(3))]; dq 5 [x(2);x(4)]; F 5 0.2*sign(dq); told 5 [0.2*sin(t);0.2*sin(t)]; tol 5 u(1:2); S 5 inv(D)*(tol-C*dq-G-F-told); sys(1) 5 x(2); sys(2) 5 S(1); sys(3) 5 x(4); sys(4) 5 S(2); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

5. Plot program: chap6_4plot.m close all; figure(1); subplot(211); plot(t,x1(:,1),'k',t,x1(:,2),'k:','linewidth',2); xlabel('time(s)');ylabel('position tracking for link 1'); legend('Ideal position signal','tracking signal'); subplot(212); plot(t,x2(:,1),'k',t,x2(:,2),'k:','linewidth',2);

Further Reading

xlabel('time(s)');ylabel('position tracking for link 2'); legend('Ideal position signal','tracking signal'); figure(2); subplot(211); plot(t,x3(:,1),'k',t,x3(:,2),'k:','linewidth',2); xlabel('time(s)');ylabel('speed tracking for link 1'); legend('Ideal speed signal','tracking signal'); subplot(212); plot(t,x4(:,1),'k',t,x4(:,2),'k:','linewidth',2); xlabel('time(s)');ylabel('speed tracking for link 2'); legend('Ideal speed signal','tracking signal'); figure(3); subplot(211); plot(t,tol1(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('control input of link 1'); subplot(212); plot(t,tol2(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('control input of link 2');

REFERENCES [1] J. Park, I.W. Sandberg, Universal approximation using radial basis function networks, Neural Comput. 3 (2) (1991) 246257. [2] J. Liu, X. Wang, Advanced Sliding Mode Control for Mechanical Systems_Design, Analysis and Matlab Simulation, Tsinghua & Springer Press, Beijing, 2011. [3] J. Liu, RBF Neural Network Control for Mechanical Systems_Design, Analysis and Matlab Simulation, Tsinghua & Springer Press, Beijing, 2013. [4] B. Chen, X. Liu, K. Liu, C. Lin, Direct adaptive fuzzy control of nonlinear strictfeedback systems, Automatica 45 (2009) 15301535. [5] F.L. Lewis, K. Liu, A. Yesildirek, Neural net robot controller with guaranteed tracking performance, IEEE Trans. Neural Netw. 6 (3) (1995) 703715. [6] S.S. Ge, C.C. Hang, T.H. Lee, T. Zhang, Stable Adaptive Neural Network Control, Kluwer, Boston, MA, 2001.

FURTHER READING Hongjun Yang, Jinkun Liu, Minimum parameter learning method for an N-link manipulator with nonlinear disturbance observer, Int. J. Robot. Autom. (2015). Available from: http://dx.doi.org/10.2316/Journal.206.2016.3.206-4442.

237

Chapter

7

Sliding mode control based on a fuzzy system Past research of universal approximation theorem [1] shown that any nonlinear function over a compact set with arbitrary accuracy can be approximated by a fuzzy system. There have been significant research efforts on adaptive fuzzy control for nonlinear systems [2]. In the book [3], several kinds of fuzzy sliding mode controller design methods have been introduced, refer to this book, in this chapter, two sections are introduced as follows: In Section 7.1, sliding mode control based on a fuzzy system approximation is introduced, unknown function f ðxÞ is approximated by fuzzy system, and robustness can be guaranteed by switch term. In Section 7.2, sliding mode control based on a fuzzy system with minimum parameter learning method is introduced, minimum parameter learning can be used in fuzzy system to reduce the computational burden and increase real-time performance [4]. Using the minimum parameter learning, in this section, a sliding mode controller based on a fuzzy system is designed.

7.1 SLIDING MODE CONTROL BASED ON A FUZZY SYSTEM APPROXIMATION 7.1.1 Problem statement Consider a second-order system as follows: x_1 5 x2 x_2 5 f ðxÞ 1 u 1 dðtÞ;

ð7:1Þ

where x1 and x2 are respectively angle and angle speed, u is the control input, dðtÞ is disturbance, jdðtÞj # D.

Sliding Mode Control Using MATLAB. DOI: http://dx.doi.org/10.1016/B978-0-12-802575-8.00007-2 Copyright © 2017 Tsinghua University Press Limited. Published by Elsevier Inc. All rights reserved.

239

240

CHAPTER 7 Sliding mode control based on a fuzzy system

Let the desired output be x1d , and denote error as e 5 x1d 2 x1 :

Design a sliding mode function as s 5 e_ 1 ce;

ð7:2Þ

s_ 5 e€ 1 ce_ 5 x€ 1d 2 x€ 1 1 ce_ 5 x€ 1d 2 f 2 u 1 ce_ 2 dðtÞ:

ð7:3Þ

where c . 0, then

If f is known, we can design a control law as u 5 2 f 1 x€ 1d 1 ce_ 1 η sgnðsÞ:

ð7:4Þ

Then Eq. (7.3) becomes s_ 5 2 η sgnðsÞ; therefore, if we design η \$ jεjmax , we have s_s 5 2 ηjsj 2 sdðtÞ # 0

If f ðxÞ is unknown, we should approximate f ðxÞ by some algorithms. In this section, fuzzy system is used to approximate unknown function f ðxÞ.

7.1.2 Controller design based on a fuzzy system 7.1.2.1 Uncertainty approximation using a fuzzy system

_

If f ðxÞ is unknown, we can replace f ðxÞ with the fuzzy system f ðxÞ to realize feedback control. Using the universal approximation theorem, three steps are designed as follows: 1. For x1 and x2 , define five fuzzy sets for Al1i and Al2i respectively, li 5 1; 2; . . .; 5; n 2. Design Li51 pi 5 p1 3 p2 5 25 fuzzy rules to construct fuzzy system _ f ðxjθf Þ: Rð1Þ : Rð25Þ :

If x1 is A11 and. . .and x2 is A12 then f^ is B1 ; If x1 is A51 and. . .and x2 is A52 then f^ is B25 ;

ð7:5Þ

where li 5 1; 2; . . .; 5 and i 5 1; 2, p1 5 p2 5 5. 3. Using fuzzy inference, the output of fuzzy system is 5 P 5 P

f^ðxjθf Þ 5

l1 51 l2 51 5 P

2  ylf1 l2 L μAli ðxi Þ

5 P

l1 51 l2 51



i

i51

2

L μAli ðxi Þ

i51

i

where μAj ðxi Þ is the membership function of xi . i

 ;

ð7:6Þ

7.1 Sliding Mode Control Based on a Fuzzy System Approximation

Let ylf1 l2 be a free parameter and be put in the set θ^ f ARð25Þ . Column vector ξðxÞ is introduced and Eq. (7.6) can be written as: T f^ðxjθf Þ 5 θ^ f ξðxÞ;



ð7:7Þ

n

where x 5 x1 x2 T , ξðxÞ is Li51 pi 5 p1 3 p2 5 25 dimensional column vector, and l1 ; l2 elements are, respectively, 2

L μAli ðxi Þ i ξ l1 l2 ðxÞ 5 p pi51 2 : 1 2 P P L μAli ðxi Þ l1 51 l2 51

i51

ð7:8Þ

i

The membership functions are needed to be selected according to experiences. Moreover, all the states must be known.

7.1.2.2 Design of adaptive fuzzy sliding mode controller Suppose the optimal parameter as θf



  5 arg min sup f^ðxj θf Þ 2 f ðxÞ θf AΩ f



xARn

where Ω f is the set of θf , i.e., θf AΩ f . The term f can be expressed as f 5 θT f ξðxÞ 1 ε;

ð7:9Þ

where x is the input signal of the fuzzy system, where ξðxÞ is the fuzzy vector, ε is approximation error of fuzzy system, and ε # εN . The fuzzy system is used to approximate f. The fuzzy system input is  selected as x 5 x1 x2 T , and the output of the fuzzy system is T f^ðxjθf Þ 5 θ^ f ξðxÞ:

ð7:10Þ

Control input item (7.4) is written as u 5 2 f^ 1 x€ 1d 1 ce_ 1 η sgnðsÞ:

ð7:11Þ

Substituting Eq. (7.11) into Eq. (7.3), we have s_ 5 x€ 1d 2 f 2 u 1 ce_ 5 θ€ d 2 f 2 ð2 f^ 1 x€ 1d 1 ce_ 1 η sgnðsÞÞ 1 ce_ 5 2 f 1 f^ 2 η sgnðsÞ 5 2 f~ 2 η sgnðsÞ;

ð7:12Þ

since ^T ~T f~ 5 f 2 f^ 5 f 5 θT f ξðxÞ 1 ε 2 θf ξðxÞ 5 θf ξðxÞ 1 ε;

where θ~ f 5 θf 2 θ^ f .

ð7:13Þ

241

242

CHAPTER 7 Sliding mode control based on a fuzzy system

Define the Lyapunov function as 1 1 T V 5 s2 1 γ θ~ f θ~ f ; 2 2

where γ . 0. With a derivative V, and from Eqs. (7.4) and (7.12), we have T T_ V_ 5 s_s 1 γ θ~ f θ_~ f 5 sð2 f~ 2 η sgnðsÞÞ 2 γ θ~ f θ^ f  T T_ 5 s 2 θ~ f ξðxÞ 2 ε 2 η sgnðsÞ 2 γ θ~ f θ^ f  T _ 5 2 θ~ f sξðxÞ 1 γ θ^ f 2 sðε 1 η sgnðsÞÞ:

Let the adaptive law be 1 _ θ^ f 5 2 sξðxÞ; γ

ð7:14Þ

then V_ 5 2 sðε 1 η sgnðsÞÞ 5 2 sε 2 ηjsj:

Due to the approximation error ε is sufficiently small, if we design η \$ εN , we can obtain approximately V_ # 0. Using LaSalle’s invariance _ principle, if t-N, then s-0, i.e., e-0 and e-0.

7.1.3 Simulation example Consider the following plant as x_1 5 x2 x_2 5 f ðxÞ 1 u 1 dðtÞ:

To fuzzify x1 and x2 , consider the range value of x1 and x2 , we select five membership functions as: μNM ðxi Þ 5 exp½ 2 ððxi 1π=3Þ=ðπ=12ÞÞ2 ; μNS ðxi Þ 5 exp½ 2 ððxi 1π=6Þ=ðπ=12ÞÞ2 ; μZ ðxi Þ 5 exp½ 2 ðxi =ðπ=12ÞÞ2 ; μPS ðxi Þ 5 exp½ 2 ððxi 2π=6Þ=ðπ=12ÞÞ2 ; μPM ðxi Þ 5 exp½ 2 ððxi 2π=3Þ=ðπ=12ÞÞ2 :

The membership functions are given in Fig. 7.1. The desired trajectory is chosen as xd ðtÞ 5 sin t, the initial states are ½0:15; 0, use control law (7.11) and adaptive law (7.14), choose c 5 15, η 5 0:50 and γ 5 5000, the simulation results are shown in Figs. 7.27.4.

7.1 Sliding Mode Control Based on a Fuzzy System Approximation

1 0.9

Membership function degree

0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 –1.5

–1

–0.5

0 x

0.5

1

1.5

■ FIGURE 7.1 Membership function of xi .

position tracking

2 ideal position position tracking

1 0 –1 –2

0

2

4

6

8

10 12 Time(s)

14

16

18

20

speed tracking

2 ideal speed speed tracking

1 0 –1 –2

0

2

4

6

■ FIGURE 7.2 Position and speed tracking.

8

10 12 Time(s)

14

16

18

20

243

CHAPTER 7 Sliding mode control based on a fuzzy system

40

30

Control input

20

10

0

–10

–20

–30

0

2

4

6

8

10 12 Time(s)

14

16

18

20

■ FIGURE 7.3 Control input.

50 ideal f estimation of f

40 30

f approximation

244

20 10 0 –10 –20 –30

0

2

4 _

■ FIGURE 7.4 f ðxÞ and f ðxÞ.

6

8

10 12 Time(s)

14

16

18

20

7.1 Sliding Mode Control Based on a Fuzzy System Approximation

Simulation Programs:

1. Plot program: chap7_1mf.m clear all; close all; L1 5 2 pi/3; L2 5 pi/3; L 5 L2 2 L1; T 5 L*1/1000; x 5 L1:T:L2; figure(1); for i 5 1:1:5 gs 5 2[(x 1 pi/3 2 (i 2 1)*pi/6)/(pi/12)].^2; u 5 exp(gs); hold on; plot(x,u,'linewidth',2); end xlabel('x');ylabel('Membership function degree');

2. Main Simulink program: chap7_1sim.mdl

3. Control law program: chap7_1ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes;

245

246

CHAPTER 7 Sliding mode control based on a fuzzy system

case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates5 25; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [0.1*ones(25,1)]; str 5 []; ts 5 [0 0]; function sys 5 mdlDerivatives(t,x,u) xd 5 sin(t); dxd 5 cos(t); x1 5 u(2); x2 5 u(3); e 5 x1 2 xd; de 5 x2 2 dxd; c 5 15; s 5 c*e 1 de; xi 5 [x1;x2]; FS1 5 0; for l1 5 1:1:5 gs1 5 2 [(x1 1 pi/3 2 (l1 2 1)*pi/6)/(pi/12)]^2; u1(l1) 5 exp(gs1); end for l2 5 1:1:5 gs2 5 2 [(x2 1 pi/3 2 (l2 2 1)*pi/6)/(pi/12)]^2; u2(l2) 5 exp(gs2); end

7.1 Sliding Mode Control Based on a Fuzzy System Approximation

for l1 5 1:1:5 for l2 5 1:1:5 FS2(5*(l1 2 1) 1 l2) 5 u1(l1)*u2(l2); FS1 5 FS1 1 u1(l1)*u2(l2); end end FS 5 FS2/(FS1 1 0.001); for i 5 1:1:25 thta(i,1) 5 x(i); end gama 5 5000; S 5 gama*s*FS; for i 5 1:1:25 sys(i) 5 S(i); end function sys 5 mdlOutputs(t,x,u) xd 5 sin(t); dxd 5 cos(t); ddxd 5 2 sin(t); x1 5 u(2); x2 5 u(3); e 5 x1 2 xd; de 5 x2 2 dxd; c 5 15; s 5 c*e 1 de; xi 5 [x1;x2]; FS1 5 0; for l1 5 1:1:5 gs1 5 2 [(x1 1 pi/3 2 (l1 2 1)*pi/6)/(pi/12)]^2; u1(l1) 5 exp(gs1); end for l2 5 1:1:5 gs2 5 2 [(x2 1 pi/3 2 (l2 2 1)*pi/6)/(pi/12)]^2; u2(l2) 5 exp(gs2); end for l1 5 1:1:5 for l2 5 1:1:5 FS2(5*(l1 2 1) 1 l2) 5 u1(l1)*u2(l2); FS1 5 FS1 1 u1(l1)*u2(l2); end

247

248

CHAPTER 7 Sliding mode control based on a fuzzy system

end FS 5 FS2/(FS1 1 0.001); for i 5 1:1:25 thta(i,1) 5 x(i); end fxp 5 thta'*FS'; xite 5 0.50; ut 5 2 c*de 1 ddxd 2 fxp 2 xite*sign(s); sys(1) 5 ut; sys(2) 5 fxp;

4. Plant S function: chap7_1plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 3; sizes.NumInputs 5 2; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.15;0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); f 5 3*(x(1) 1 x(2)); sys(1) 5 x(2); sys(2) 5 f 1 ut; function sys 5 mdlOutputs(t,x,u)

7.2 Sliding Mode Control Based on a Fuzzy System with Minimum Parameter Learning Method

f 5 3*(x(1) 1 x(2)); sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 f;

5. Plot program: chap7_1plot.m close all; figure(1); subplot(211); plot(t,x(:,1),'k',t,x(:,2),'r:','linewidth',2); xlabel('time(s)');ylabel('position tracking'); legend('ideal position','position tracking'); subplot(212); plot(t,cos(t),'k',t,x(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('speed tracking'); legend('ideal speed','speed tracking'); figure(2); plot(t,ut(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('Control input'); figure(3); plot(t,f(:,1),'k',t,f(:,3),'r:','linewidth',2); xlabel('time(s)');ylabel('f approximation'); legend('ideal f','estimation of f');

7.2 SLIDING MODE CONTROL BASED ON A FUZZY SYSTEM WITH MINIMUM PARAMETER LEARNING METHOD The minimum parameter learning (MPL) method [4] can decrease the number of online adaptive parameters to only one, which can be used in fuzzy system to reduce the computational burden and increase real-time performance. Using the minimum parameter learning, in this section, a sliding mode control based on a fuzzy system is introduced.

7.2.1 Problem statement Consider a second-order system as follows: x_1 5 x2 x_2 5 f ðxÞ 1 u 1 dðtÞ;

ð7:15Þ

where x1 and x2 are respectively angle and angle speed, u is the control input, dðtÞ is disturbance, jdðtÞj # D.

249

250

CHAPTER 7 Sliding mode control based on a fuzzy system

Denote x1d as an ideal angle and define the tracking error as e 5 x1 2 x1d :

Design a sliding mode function as s 5 e_ 1 ce;

ð7:16Þ

where c . 0, then _ s_ 5 e€ 1 ce_ 5 x€ 1 2 x€ 1d 1 ce_ 5 f 1 u 1 d 2 x€ 1d 1 ce:

If f is known, we can design a control law as u 5 2 f 1 x€ 1d 2 ce_ 2 η sgnðsÞ:

ð7:17Þ

Then s_ 5 2 η sgnðsÞ 1 d; therefore, if we design η \$ D, we have s_s 5 2 ηjsj 1 ηd # 0:

If f ðxÞ is unknown, we should approximate f ðxÞ by some algorithms. In the following, we will simply recall fuzzy systems approximate unknown function f ðxÞ.

7.2.2 Uncertainty approximation using a fuzzy system

_

If f ðxÞ is unknown, we can replace f ðxÞ with the fuzzy system f ðxÞ to realize feedback control. Using the universal approximation theorem, three steps are designed as follows: 1. For x1 and x2 , define the fuzzy sets Al1i and Al2i , respectively, li 5 1; 2; . . .; 5; n 2. Design Li51 pi 5 p1 3 p2 5 25 fuzzy rules to construct fuzzy system _ f ðxjθf Þ: Rð1Þ : Rð25Þ :

If x1 is A11 and. . .and x2 is A12 then f^ is B1 ; If x1 is A51 and. . .and x2 is A52 then f^ is B25 ;

ð7:18Þ

where li 5 1; 2; . . .; 5, i 5 1; 2, p1 5 p2 5 5. 3. Using fuzzy inference, the output of a fuzzy system is 5 P 5 P

f^ðxjθf Þ 5

l1 51 l2 51

2  ylf1 l2 L μAli ðxi Þ

5 P 5 P l1 51 l2 51



i

i51

2

L μAli ðxi Þ

i51

i

where μAj ðxi Þ is the membership function of xi . i

 ;

ð7:19Þ

7.2 Sliding Mode Control Based on a Fuzzy System with Minimum Parameter Learning Method

Let ylf1 l2 be a free parameter and be put in the set θ^ f ARð25Þ . Column vector ξðxÞ is introduced and Eq. (7.19) can be written as: T f^ðxjθf Þ 5 θ^ f ξðxÞ;



ð7:20Þ

n

where x 5 x1 x2 T , ξðxÞ is the Li51 pi 5 p1 3 p2 5 25 dimensional column vector, and l1 ; l2 elements are respectively 2

L μAli ðxi Þ i ξ l1 l2 ðxÞ 5 p pi51 2 : 1 2 P P L μAli ðxi Þ l1 51 l2 51

i51

ð7:8Þ

i

The membership functions are needed to be selected according to experiences. Moreover, all the states must be known.

7.2.3 Design of an adaptive fuzzy sliding mode controller with MPL Suppose the optimal parameter is     θf 5 arg min supf^ðxj θf Þ 2 f ðxÞ ; θf AΩf

xARn

where Ω f is the set of θf , i.e., θf AΩ f . The term f can be expressed as f 5 θT f ξðxÞ 1 ε;

ð7:21Þ

where x is the input signal of the fuzzy system, where ξðxÞ is the fuzzy vector, ε is approximation error of fuzzy system, and ε # εN . The fuzzy system is used to approximate f. The fuzzy system input is  selected as x 5 x1 x2 T , and the output of the fuzzy system is T f^ðxjθf Þ 5 θ^ f ξðxÞ:

ð7:22Þ

Using minimum parameter learning [4], define φ 5 jjθf jj2 , where φ is a positive constant, and let φ^ be an estimation of φ. Design the controller as 1 ^ T u 5 2 sφξ ξ 1 x€ 1d 2 ce_ 2 η sgnðsÞ 2 μs; 2

where η \$ εN 1 D, μ . 0.

ð7:23Þ

251

252

CHAPTER 7 Sliding mode control based on a fuzzy system

Then we have 1 ^ T _ s_ 5 f 1 u1d 2 x€ 1d 1 ce_ 5 f 2 sφξ ξ 1 x€ 1d 2 ce2η sgnðsÞ 2 μs1d2 x€ 1d 1ce_ 2 1 ^ T 5 θT f ξðxÞ 1 ε 2 sφξ ξ 2 η sgnðsÞ 2 μs 1 d: 2

The Lyapunov function is designed as 1 1 ~2 φ ; V 5 s2 1 2 2γ

where γ . 0, φ~ 5 φ^ 2 φ. Then 1 _ V_ 5 s_s 1 φ~ φ^ γ   1 ^ T 1 _ 5 s θT s φξ ξðxÞ 1 ε 2 ξ 2 η sgnðsÞ 2 μs 1 d 1 φ~ φ^ f 2 γ 1 1 1 ^ T 1 _ # s2 φξT ξ 1 1 εs 2 s2 φξ ξ 2 ηjsj 2 μs2 1 ds 1 φ~ φ^ 2 2 2 γ 1 ~ T 1 1 _ 5 2 s2 φξ ξ 1 1 εs 2 ηjsj 2 μs2 1 ds 1 φ~ φ^ 2 2 γ   1 1_ 1 5 φ~ 2 s2 ξT ξ 1 φ^ 1 2 μs2 1 εs 2 ηjsj 1 ds 2 γ 2   1 1_ 1 # φ~ 2 s2 ξT ξ 1 φ^ 1 2 μs2 : 2 γ 2

Design the adaptive law as _ γ ^ φ^ 5 s2 ξT ξ 2 κγ φ; 2

ð7:24Þ

where κ . 0. Then   1 1 κ~2 κ ~2 κ 2 1 2 2 2 2 ~ ^ _ V # 2 κφφ 1 2 μs # 2 φ 2 φ 1 2 μs 52 φ 2 μs 1 φ 1 : 2 2 2 2 2 2

Define κ 5

2μ γ,

then

      μ 2 κ 2 1 1 ~2 1 2 κ 2 1 V_ # 2 φ~ 2 μs2 1 φ 1 5 2 2μ φ 1 s 1 φ 1 γ 2 2 2γ 2 2 2 5 2 2μV 1 Q;

where Q 5 κ2 φ2 1 12.

7.2 Sliding Mode Control Based on a Fuzzy System with Minimum Parameter Learning Method

Using Lemma 1.3, the solution of V_ # 2 2μV 1 Q is V#

  Q Q 22μt 1 Vð0Þ 2 e ; 2μ 2μ

then 2μ 2 κ 2 1 φ 11 2 φ 1 Q κφ 1 1 φ2 1 γ 25 52 5 : 5 1 lim V 5 t-N 2μ 4μ 4μ 4μ 2μ 2γ

ð7:25Þ

From above, we can see that the convergence precision depends on γ and μ. Regarding the above analysis, two remarks are given as follows. 2 Remark 1: s2 φξT ξ115s2 jjθf jj2 ξT ξ115s2 jjθf jj2 jjξjj2 115s2 jjθT f ξjj 1 T T 1 2  T 1 1 \$ 2sθf ξ, i.e., sθf ξ # 2 s θf ξ ξ 1 2; 2 ~ Remark 2: since ðφ1φÞ \$ 0, then 2 2 ~ φ^ 2 φÞ ~ 1 φ \$ 0, i.e., 2φ~ φ^ \$ φ~ 2 2 φ2 . φ~ 1 2φð

2 ~ 1 φ2 \$ 0 φ~ 1 2φφ

and

However, the shortcoming of minimum parameter learning method is that the approximation precision cannot be guaranteed.

7.2.4 Simulation example Consider the following plant: x_1 5 x2 x_2 5 f ðxÞ 1 u 1 dðtÞ;

where f ðxÞ 5 3ðx1 1 x2 Þ, dðtÞ 5 sin t. To fuzzify x1 and x2 , consider the range value of x1 and x2 , we select five membership functions as: μNM ðxi Þ 5 exp½ 2 ððxi 1π=3Þ=ðπ=12ÞÞ2 ; μNS ðxi Þ 5 exp½ 2 ððxi 1π=6Þ=ðπ=12ÞÞ2 ; μZ ðxi Þ 5 exp½ 2 ðxi =ðπ=12ÞÞ2 ; μPS ðxi Þ 5 exp½ 2 ððxi 2π=6Þ=ðπ=12ÞÞ2 ; μPM ðxi Þ 5 exp½ 2 ððxi 2π=3Þ=ðπ=12ÞÞ2 :

The membership functions are given in Fig. 7.5; its program is also chap7_1mf.m. Choose the desired trajectory as xd ðtÞ 5 sin t, the initial states are set as ½0:20; 0, use control law (7.23) and adaptive law (7.24), choose η 5 1:1, μ 5 10 and γ 5 100. To reduce chattering, use the saturation function instead of the sign function, and choose Δ 5 0:02, the simulation results are shown in Figs. 7.67.8.

253

CHAPTER 7 Sliding mode control based on a fuzzy system

1 0.9

Membership function degree

0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0 –1.5

–1

–0.5

0 x

0.5

1

1.5

■ FIGURE 7.5 Membership function of xi .

angle tracking

2 ideal angle angle tracking

1 0 –1 –2

0

1

2

3

4

5 Time(s)

6

7

8

9

10

2 speed tracking

254

ideal speed speed tracking

1

0

–1

0

1

2

3

■ FIGURE 7.6 Position and speed tracking.

4

5 Time(s)

6

7

8

9

10

7.2 Sliding Mode Control Based on a Fuzzy System with Minimum Parameter Learning Method

40 20

Control input,u

0 –20 –40 –60 –80 –100 –120 0

1

2

3

4

5 Time(s)

6

7

8

9

5 Time(s)

6

7

8

9

10

■ FIGURE 7.7 Control input.

30

Estimation of phi

25

20

15

10

5

0

0

1

2

^ ■ FIGURE 7.8 Change of φ.

3

4

10

255

256

CHAPTER 7 Sliding mode control based on a fuzzy system

Simulation Programs:

1. Main Simulink program: chap7_2sim.mdl

2. Control law program: chap7_2ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 1; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes);

7.2 Sliding Mode Control Based on a Fuzzy System with Minimum Parameter Learning Method

x0 5 0; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) x1d 5 u(1); dx1d 5 u(2); x1 5 u(3); x2 5 u(4); e 5 x1 2 x1d; de 5 x2 2 dx1d; c 5 50; s 5 c*e 1 de; xi 5 [x1;x2]; FS1 5 0; for l1 5 1:1:5 gs1 5 2 [(x1 1 pi/3 2 (l1 2 1)*pi/6)/(pi/12)]^2; u1(l1) 5 exp(gs1); end for l2 5 1:1:5 gs2 5 2 [(x2 1 pi/3 2 (l2 2 1)*pi/6)/(pi/12)]^2; u2(l2) 5 exp(gs2); end for l1 5 1:1:5 for l2 5 1:1:5 FS2(5*(l1 2 1) 1 l2) 5 u1(l1)*u2(l2); FS1 5 FS1 1 u1(l1)*u2(l2); end end FS 5 FS2/(FS1 1 0.001); miu 5 10; gama 5 100; k 5 2*miu/gama; sys(1) 5 gama/2*s^2*FS*FS'-k*gama*x; function sys 5 mdlOutputs(t,x,u) x1d 5 u(1); dx1d 5 u(2); x1 5 u(3); x2 5 u(4);

257

258

CHAPTER 7 Sliding mode control based on a fuzzy system

e 5 x1 2 x1d; de 5 x2 2 dx1d; x1d 5 sin(t); dx1d 5 cos(t); ddx1d 5 2 sin(t); c 5 50; s 5 c*e 1 de; phi 5 x; xi 5 [x1;x2]; xi 5 [x1;x2]; FS1 5 0; for l1 5 1:1:5 gs1 5 2 [(x1 1 pi/3 2 (l1 2 1)*pi/6)/(pi/12)]^2; u1(l1) 5 exp(gs1); end for l2 5 1:1:5 gs2 5 2 [(x2 1 pi/3 2 (l2 2 1)*pi/6)/(pi/12)]^2; u2(l2) 5 exp(gs2); end for l1 5 1:1:5 for l2 5 1:1:5 FS2(5*(l1 2 1) 1 l2) 5 u1(l1)*u2(l2); FS1 5 FS1 1 u1(l1)*u2(l2); end end FS 5 FS2/(FS1 1 0.001); xite 5 1.0 1 0.10; miu 5 10; %Saturated function fai 5 0.02; if abs(s) , 5 fai sats 5 s/fai; else sats 5 sign(s); end %ut5 2 0.5*s*phi*FS*FS'1ddx1d 2 c*de 2 xite*sign(s) 2 miu*s; ut 5 2 0.5*s*phi*FS*FS' 1 ddx1d 2 c*de 2 xite*sats 2 miu*s; sys(1) 5 ut; sys(2) 5 x(1);

7.2 Sliding Mode Control Based on a Fuzzy System with Minimum Parameter Learning Method

3. Plant S function: chap7_2plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9 } sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 2; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 2; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.20 0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) %%%%%%%%% dt 5 sin(t); %%%%%%%%% fx 5 3*x(1)*x(2); sys(1) 5 x(2); sys(2) 5 fx 1 u 1 dt; function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2);

4. Plot program: chap7_2plot.m close all; figure(1); subplot(211); plot(t,y(:,1),'r',t,y(:,2),'b:','linewidth',2);

259

260

CHAPTER 7 Sliding mode control based on a fuzzy system

xlabel('time(s)');ylabel('angle tracking'); legend('ideal angle','angle tracking'); subplot(212); plot(t,cos(t),'r',t,y(:,3),'b:','linewidth',2); xlabel('time(s)');ylabel('speed tracking'); legend('ideal speed','speed tracking'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('Control input,u'); figure(3); plot(t,phip(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('Estimation of phi');

REFERENCES [1] L.X. Wang, A Course in Fuzzy System and Control, Prentice Hall, Upper Saddle River, NJ, 1997. [2] L.X. Wang, Stable adaptive fuzzy control of nonlinear systems, IEEE Trans. Fuzzy Syst. 1 (2) (1993) 146155. [3] J. Liu, X. Wang, Advanced Sliding Mode Control for Mechanical Systems_Design, Analysis and Matlab Simulation, Tsinghua & Springer Press, Beijing, 2011. [4] Bing Chen, X. Liu, K. Liu, C. Lin, Direct adaptive fuzzy control of nonlinear strict-feedback systems, Automatica 45 (2009) 15301535.

Chapter

8

Sliding mode control of a class of underactuated systems The past decade there has been increasing interest in underactuated systems. These systems are characterized by the fact that they have fewer actuators than the degrees of freedom to be controlled. Underactuated systems have very important applications such as free-flying space robots, underwater robots, surface vessels, manipulators with structural flexibility, etc. They are used for reducing weight, cost or energy consumption, while still maintaining an adequate degree of dexterity without reducing the reachable configuration space. Some other advantages of underactuated systems include less damage while hitting an object, and tolerance for failure of actuators [1,2]. Control researchers have given considerable attention to many examples of control problems associated with underactuated mechanical systems, and different control strategies have been proposed, in this chapter, mainly refer to [1], we discuss several methods to design the sliding mode control for underactuated systems.

8.1 SLIDING MODE CONTROL OF A CLASS OF UNDERACTUATED SYSTEM 8.1.1 System description Consider an underactuated system as follows: x_1 5 x2 x_2 5 f1 ðx1 ; x2 ; x3 Þ x_3 5 x4

ð8:1Þ

x_4 5 f2 ðx1 ; x2 ; x3 Þ 1 bðx1 ; x2 ; x3 Þu 1 d;

where u is control input, d is disturbance, jdj # D.

Sliding Mode Control Using MATLAB. DOI: http://dx.doi.org/10.1016/B978-0-12-802575-8.00008-4 Copyright © 2017 Tsinghua University Press Limited. Published by Elsevier Inc. All rights reserved.

261

262

CHAPTER 8 Sliding mode control of a class of underactuated systems

The function f1 ðx1 ; x2 ; x3 Þ must be satisfied following four assumptions as follows: Assumption 1: f1 ð0; 0; 0Þ-0; @f1 is invertible; Assumption 2: @x3 Assumption 3: x3 -0 if f1 ð0; 0; x3 Þ-0.    @f1  Assumption 4:   # β 3 , i 5 1; 2; 3. @x3 The control goals are xi -0; i 5 1; 2; 3; 4 as t-N. Define e1 5 x1 e2 5 e_1 5 x2 e3 5 e€1 5 x_2 5 f1 ðx1 ; x2 ; x3 Þ @f1 @f1 @f1 x2 1 f1 1 x4 e4 5 ⃛e 1 5 f_1 5 @x1 @x2 @x3

ð8:2Þ

8.1.2 Sliding mode controller design Design the sliding mode function as s 5 c1 e1 1 c2 e2 1 c3 e3 1 e4 ;

ð8:3Þ

where ci . 0 and i 5 1; 2; 3. Then   @f1 @f1 @f1 s_ 5 c1 e_1 1 c2 e_2 1 c3 e_3 1 e_4 5 c1 x2 1 c2 f1 1 c3 x2 1 f1 1 x4 @x1 @x2 @x3       d @f1 d @f1 d @f1 @f1 x4 1 x2 1 f1 1 ðf2 1 bu 1 dÞ 1 dt @x1 dt @x2 dt @x3 @x3 ð8:4Þ

Let s_ 5 0, then we can get equivalent control as       @f1 21 @f1 @f1 @f1 d @f1 c1 x2 1 c2 f1 1 c3 b x2 1 f1 1 x4 1 x2 dt @x1 @x3 @x1 @x2 @x3      d @f1 d @f1 @f1 1 x4 1 f1 1 f2 @x3 dt @x2 dt @x3 ð8:5Þ 

ueq 5 2

To satisfy s_s # 0, controller can be designed as 

@f1 where usw 5 2 b @x3

21

u 5 ueq 1 usw ;

½M sgnðsÞ 1 λs, λ . 0.

ð8:6Þ

8.1 Sliding Mode Control of a Class of Underactuated System

Substituting Eq. (8.6) into Eq. (8.4), we have



s_ 5 c1 e_1 1 c2 e_2 1 c3 e_3 1 e_4 5 c1 x2 1 c2 f1 1 c3

@f1 @f1 @f1 x2 1 f1 1 x4 @x1 @x2 @x3



      d @f1 d @f1 d @f1 @f1 1 x4 1 x2 1 f1 1 ðf2 1 bu 1 dÞ @x3 dt @x1 dt @x2 dt @x3 5 2 M sgnðsÞ 2 λs 1

@f1 d: @x3

Define M 5 β 3 D 1 ρ; ρ . 0:

Design the Lyapunov function as V 5 

1 2 2s ,

ð8:7Þ

then

 @f1 d V_ 5 s_s 5 s 2 ðβ 3 D 1 ρÞsgnðsÞ 2 λs 1 @x3 @f1 2 5 2 ðβ 3 D 1 ρÞjsj 2 λs 1 s d # 2 ρjsj 2 λs2 # 0: @x3

Since e_1 5 x2 e_2 5 x_2 5 f1 @f1 @f1 @f1 e_3 5 f_1 5 x2 1 f1 1 x4 @x1 @x2 @x3       d @f1 d @f1 d @f1 e_4 5 x2 1 f1 1 x4 dt @x1 dt @x2 dt @x3       d @f1 d @f1 d @f1 @f1 x4 1 x2 1 f1 1 ð f2 1 bu 1 dÞ: 5 dt @x1 dt @x2 dt @x3 @x3

From Eq. (8.2), we have e_1 5 e2 , e_2 5 e3 and e_3 5 e4 . s_s # 0 indicates that there exists s 5 0 as t . t0 , when s 5 0, we have e4 5 2 c1 e1 2 c2 e2 2 c3 e3 , 2 3 0 1 0 define A 5 4 0 0 1 5, E1 5 e1 e2 e3 T , then we have 2c1 2c2 2c3 E_ 1 5 AE1

ð8:8Þ

Choose Q 5 Q . 0, if we design A as Hurwitz, then there exists a Lyapunov equation AT P 1 PA 5 2 Q, P 5 PT . 0. T

Design the Lyapunov function as V1 5 ET1 PE1 , then T _ 1 5 ðAE1 ÞT PE1 1 ET PðAE1 Þ V_ 1 5 E_ 1 PE1 1 ET1 PE 1

5 ET1 AT PE1 1 ET1 PAE1 5 ET1 ðAT P 1 PAÞE1 5 2ET1 QE1 # 2 λmin ðQÞjjE1 jj22 # 0;

where λmin ðQÞ is the minimum eigenvalue of Q.

263

264

CHAPTER 8 Sliding mode control of a class of underactuated systems

In the above analysis, three remarks are given as follows. Remark 1: From V_ 1 # 0, we have e1 -0, e2 -0, e3 -0, consider s 5 c1 e1 1 c2 e2 1 c3 e3 1 e4 -0, we have e4 -0. From e1 -0 and e2 -0, we can get x1 -0, x2 -0, consider e3 5 f1 ð0; 0; x3 Þ-0 and Assumption 3, we have x3 -0. From Eq. (8.2), we have x4 -0. Remark 2: to guarantee that A is Hurwitz, let     2λ 1 0    5 λ2 ð2 c3 2 λÞ 2 c1 2 c2 λ 5 2 λ3 2  jA 2 λIj 5  0 2λ 1   2c1 2c2 2c3 2 λ  c3 λ2 2 c2 λ 2 c1 5 0, from ðλ13Þ3 5 0, we have λ3 1 9λ2 1 27λ 1 27 5 0 then we can set c1 5 27 and c2 5 27, c3 5 9. Remark 3: three assumptions can be explained as follows: 1. The closed system stability requires that e3 5 0, x1 5 0, x2 5 0, x3 5 0 exist at the same time, i.e., Assumption 1 f1 ð0; 0; 0Þ-0 must be satisfied; @f1 2. only Assumption 2 exists, i.e., must be invertible, control law @x3 (8.6) can be effective; 3. only Assumption 3 exists, i.e., f1 ð0; 0; x3 Þ 5 0 and x3 -0 exists at the same time, x3 -0 can be guaranteed.

8.1.3 Position tracking If the tracking control goals are set as x1 -xd and x2 -x_d , then we have e1 5 x1 2 xd e2 5 e_1 5 x2 2 x_d e3 5 e€1 5 x_2 2 x€d 5 f1 ðx1 ; x2 ; x3 Þ 2 x€d @f1 @f1 @f1 e4 5 ⃛ e 1 5 f_1 2 ⃛x d 5 x2 1 f1 1 x4 2 ⃛x d @x1 @x2 @x3

and s_ 5 c1 e_1 1 c2 e_2 1 c3 e_3 1 e_4 : 5 c1 x_1 1 c2 x_2 1 c3 x€2 1 f_1 2 c1 x_d 2 c2 x€d 2 c3 ⃛x d 2€€ xd

Let s_ 5 0; we have       @f1 21 @f1 @f1 @f1 d @f1 c1 x2 1 c2 f1 1 c3 b x2 1 f1 1 x4 1 x2 @x3 @x1 @x2 @x3 dt @x1      d @f1 d @f1 @f1 x4 1 f1 1 f2 2 c1 x_d 2 c2 x€d 2 c3 ⃛x d 2€€ xd 1 dt @x2 dt @x3 @x3 ð8:9Þ 

ueq 5 2

8.1 Sliding Mode Control of a Class of Underactuated System

8.1.4 Simulation example 8.1.4.1 First example Consider a simple underactuated system as x_1 5 x2 x_2 5 g sin x1 =l 1 x3 x_3 5 x4 x_4 5 u 2 d;

where f1 5 g sin x1 =l 1 x3 , f2 5 0, d 5 10 sin t. Consider control goals as xi -0; i 5 1; 2; 3; 4. From the model, we have   @f1 @f1 @f1 d @f1 gd ðx2 cos x1 Þ 5 5 g cos x1 =l, 5 0, 5 1, x2 5 dt @x l dt @x1 @x2 @x3    1 g d @f1 d @f1 ð f1 cos x1 2 x2 sin x1 Þ, x4 5 0. The initial system f1 5 0, l dt @x2 dt @x3 states are set as 0:15 0 0 0 . @f1 5 1 we can choose β 3 5 1:1, use controllers (8.5) and (8.6), @x3 design M from Eq. (8.7), and choose c1 5 27, c2 5 27, c3 5 9, ρ 5 1:0, λ 5 1:0 and D 5 10, adapt the saturation function instead of the switch function, set Δ 5 0:05, simulation results are shown in Figs. 8.1 and 8.2.

From

0.2 x1

0 –0.2

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0.1 x2

0 –0.1

0.5 x3

0 –0.5

x4

1 0 –1

■ FIGURE 8.1 System states response.

265

CHAPTER 8 Sliding mode control of a class of underactuated systems

20 15 10 5 0 ut

266

–5 –10 –15 –20 –25 –30

0

5

10 Time(s)

15

■ FIGURE 8.2 Control input.

Simulation Programs:

1. Main program: chap8_1sim.mdl

2. S function of controller: chap8_1ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 [];

20

8.1 Sliding Mode Control of a Class of Underactuated System

otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(1); x2 5 u(2); x3 5 u(3); x4 5 u(4); c1 5 27;c2 5 27;c3 5 9; l 5 10;g 5 9.8; f1 5 g*sin(x1)/l 1 x3; b 5 1; f2 5 0; f1_x1 5 g*cos(x1)/l; f1_x2 5 0; f1_x3 5 1; beta3 5 1.0 1 0.1; D 5 2 g/l*sin(x1)*x2^2 1 g/l*cos(x1)*f1; ueq 5 2 inv(f1_x3*b)*(c1*x2 1 c2*f1 1 c3*f1_x1*x2 1 c3*f1_x2 *f1 1 c3*f1_x3*x4 1 D); e1 5 x1; e2 5 x2; e3 5 f1; e4 5 f1_x1*x2 1 f1_x2*f1 1 f1_x3*x4; s 5 c1*e1 1 c2*e2 1 c3*e3 1 e4;

267

268

CHAPTER 8 Sliding mode control of a class of underactuated systems

d_up 5 10; rou 5 1.0; M 5 beta3*d_up 1 rou; nmn 5 1.0; S 5 2; if S 55 1 sat 5 sign(s); elseif S 55 2

%Saturated function

fai 5 0.05; if abs(s) , 5 fai sat 5 s/fai; else sat 5 sign(s); end end usw 5 -inv(f1_x3*b)*(M*sat 1 nmn*s); ut 5 ueq 1 usw; sys(1) 5 ut;

3. S function of plant: chap8_1plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0;

8.1 Sliding Mode Control of a Class of Underactuated System

sys 5 simsizes(sizes); x0 5 [0.15;0;0;0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); l 5 10; g 5 9.8; f1 5 g*sin(x(1))/l 1 x(3); sys(1) 5 x(2); sys(2) 5 f1; sys(3) 5 x(4); sys(4) 5 ut 2 10*sin(t); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

4. Plot program: chap8_1plot.m close all; figure(1); subplot(411); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('x1'); subplot(412); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('x2'); subplot(413); plot(t,x(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('x3'); subplot(414); plot(t,x(:,4),'r','linewidth',2); xlabel('time(s)');ylabel('x4'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('ut');

Consider position tracking and speed tracking, let ideal position signal as x1 -xd and x2 -x_d . The initial system states are set as 0:15 0 0 0 . Use controller (8.6), design M from Eq. (8.7), and

269

CHAPTER 8 Sliding mode control of a class of underactuated systems

2 ideal position signal position tracking

xd,x1

1 0 –1 –2

0

5

10 Time(s)

15

20

2 ideal speed signal speed tracking

dxd,x2

1 0 –1 –2

0

5

10 Time(s)

15

20

■ FIGURE 8.3 Position and speed tracking.

30 25 20 15 10 ut

270

5 0 –5 –10 –15

0

5

10 Time(s)

15

20

■ FIGURE 8.4 Control input.

design ueq from Eq. (8.9), choose β 3 5 1:1, c1 5 27, c2 5 27, c3 5 9, ρ 5 1:0, λ 5 1:0, and D 5 10, adapt the saturation function instead of the switch function, and set Δ 5 0:05. Simulation results are shown in Figs. 8.3 and 8.4.

8.1 Sliding Mode Control of a Class of Underactuated System

Simulation Programs:

1. Main program: chap8_2sim.mdl

2. S function of controller: chap8_2ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 5; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u)

271

272

CHAPTER 8 Sliding mode control of a class of underactuated systems

xd 5 sin(t); dxd 5 cos(t); ddxd 5 -sin(t); dddxd 5 -cos(t); ddddxd 5 sin(t); x1 5 u(2); x2 5 u(3); x3 5 u(4); x4 5 u(5); c1 5 27;c2 5 27;c3 5 9; l 5 10;g 5 9.8; f1 5 g*sin(x1)/l 1 x3; b 5 1; f2 5 0; f1_x1 5 g*cos(x1)/l; f1_x2 5 0; f1_x3 5 1; beta3 5 1.0 1 0.1; D 5 -g/l*sin(x1)*x2^2 1 g/l*cos(x1)*f1; ueq 5 2 inv(f1_x3*b)*(c1*x2 1 c2*f1 1 c3*f1_x1*x2 1 c3*f1_x2*f1 1 c3*f1_x3*x4 1 D 2 c1*dxd 2 c2*ddxd 2 c3*dddxd 2 ddddxd); e1 5 x1 2 xd; e2 5 x2 2 dxd; e3 5 f1 2 ddxd; e4 5 f1_x1*x2 1 f1_x2*f1 1 f1_x3*x4-dddxd; s 5 c1*e1 1 c2*e2 1 c3*e3 1 e4; d_up 5 10; rou 5 1.0; M 5 beta3*d_up 1 rou; nmn 5 1.0; S 5 2; if S 55 1 sat 5 sign(s); elseif S 55 2

%Saturated function

fai 5 0.05; if abs(s) , 5 fai

8.1 Sliding Mode Control of a Class of Underactuated System

sat 5 s/fai; else sat 5 sign(s); end end usw 5 2 inv(f1_x3*b)*(M*sat 1 nmn*s); ut 5 ueq 1 usw; sys(1) 5 ut; 3. S function of plant: chap8_2plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.15;0;0;0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); l 5 10; g 5 9.8; f1 5 g*sin(x(1))/l 1 x(3); sys(1) 5 x(2); sys(2) 5 f1; sys(3) 5 x(4); sys(4) 5 ut-10*sin(t);

273

274

CHAPTER 8 Sliding mode control of a class of underactuated systems

function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

4. Plot program: chap8_2plot.m close all; figure(1); subplot(211); plot(t,x(:,1),'r',t,x(:,2),'b','linewidth',2); legend('ideal position signal','position tracking'); xlabel('time(s)');ylabel('xd,x1'); subplot(212); plot(t,cos(t),'r',t,x(:,3),'b','linewidth',2); legend('ideal speed signal','speed tracking'); xlabel('time(s)');ylabel('dxd,x2'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('ut');

8.1.4.2 Second example Consider a single pendulum cart system, the dynamic model is θ€ 5

mðm 1 Mc Þgl ml θ2 v; ðMc 1 mÞI 1 Mc ml2 ðMc 1 mÞI 1 Mc ml2

x€ 5 2

m2 gl2 I 1 ml2 θ1 v; ðMc 1 mÞI 1 Mc ml2 ðMc 1 mÞI 1 Mc ml2

1 where I 5 12 mL2 , l 5 12 L, θ denotes pendulum angle, and x denotes cart position, g 5 9:8 and v is the control input. The mass of cart is Mc 5 1, the mass of pendulum is m 5 0:10 and the length of one half of the pendulum is l 5 0:5.

_ _ _ The control goals are θ-0, θ-0, x-0 and x-0. Define z1 5 x, z2 5 x, _ then θ1 5 θ, θ2 5 θ, z_1 5 z2 z_2 5 t2 θ1 1 t4 v θ_ 1 5 θ2 θ_ 2 5 t1 θ1 1 t3 v;

8.1 Sliding Mode Control of a Class of Underactuated System

mðm 1 Mc Þgl m2 gl2 , t2 5 2 , 2 ðMc 1 mÞI 1 Mc ml ðMc 1 mÞI 1 Mc ml2 ml I 1 ml2 , t 5 . 2 4 ðMc 1 mÞI 1 Mc ml2 ðMc 1 mÞI 1 Mc ml2

where

t1 5

t3 5

Define t4 θ1 t3 t4 x 2 5 z2 2 θ 2 t3 x3 5 θ1 x 1 5 z1 2

x4 5 θ2 :

Let t1 θ1 1 t3 v 5 u, then v5

u 2 t1 θ1 t3

ð8:10Þ

and x_1 5 x2 t4 t4 x_2 5 z_2 2 θ_ 2 5 t2 θ1 1 t4 v 2 ðt1 θ1 1 t3 vÞ t3 t3     t4 t1 t4 5 t2 2 t1 θ1 5 t2 2 x3 5 Tx3 t3 t3 x_3 5 x4 x_4 5 u;

where T 5 t2 2 t1t3t4 . Define f1 5 Tx3 , and e1 5 x1 e2 5 x2 e3 5 f1 @f1 @f1 @f1 e4 5 x2 1 f1 1 x4 5 Tx4 @x1 @x2 @x3

Consider control goals as xi -0; i 5 1; 2; 3; 4. From f1 5 Tx3 , we     @f1 @f1 @f1 d @f1 d @f1 have 5 0, 5 0, 5 T, and x2 5 0, f1 5 0, dt @x1 dt @x2 @x @x2 @x3  1 d @f1 _ 50 x4 5 0. The initial system states are set as θð0Þ 5 2108; θð0Þ dt @x3 _ 5 0. and xð0Þ 5 0:20; xð0Þ

275

CHAPTER 8 Sliding mode control of a class of underactuated systems

x4-cart speed

x3-cart position

x2-angle speed

x1-angle

Using controller (8.6), design M from Eq. (8.7). Consider d 5 0; we choose M 5 ρ 5 1:0, design ueq from Eq. (8.9), choose c1 5 27, c2 5 27, c3 5 9, ρ 5 1:0 and λ 5 1:0, design v from Eq. (8.10), adapt the saturation function instead of the switch function, set Δ 5 0.05, simulation results are shown in Figs. 8.5 and 8.6.

0.2 0 –0.2

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0.5 0 –0.5

0.2 0 –0.2

1 0 –1

■ FIGURE 8.5 States response of cart pendulum system.

1 0.5 0 –0.5 –1 ut

276

–1.5 –2 –2.5 –3 –3.5 –4

0

■ FIGURE 8.6 Control input.

5

10 Time(s)

15

20

8.1 Sliding Mode Control of a Class of Underactuated System

Simulation Programs:

1. Main program: chap8_3sim.mdl

2. S function of controller: chap8_3ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) c1 5 27;c2 5 27;c3 5 9;

277

278

CHAPTER 8 Sliding mode control of a class of underactuated systems

g 5 9.8;Mc 5 1.0;m 5 0.1;L 5 0.5; I 5 1/12*m*L^2; l 5 1/2*L; t1 5 m*(Mc 1 m)*g*l/[(Mc 1 m)*I 1 Mc*m*l^2]; t2 5 2 m^2*g*l^2/[(m 1 Mc)*I 1 Mc*m*l^2]; t3 5 2 m*l/[(Mc 1 m)*I 1 Mc*m*l^2]; t4 5 (I 1 m*l^2)/[(m 1 Mc)*I 1 Mc*m*l^2]; th1 5 u(1); %th th2 5 u(2); %dth z1 5 u(3); %x z2 5 u(4); %dx x1 5 z1 2 t4/t3*th1; x2 5 z2 2 t4/t3*th2; x3 5 th1; x4 5 th2; T 5 t2-t1*t4/t3; b 5 1; f1 5 T*x3; f2 5 0; f1_x1 5 0; f1_x2 5 0; f1_x3 5 T; ueq 5 2 inv(f1_x3*b)*(c1*x2 1 c2*f1 1 c3*f1_x1*x2 1 c3*f1_x2 *f1 1 c3*f1_x3*x4); e1 5 x1; e2 5 x2; e3 5 f1; e4 5 T*x4; s 5 c1*e1 1 c2*e2 1 c3*e3 1 e4; rou 5 1.0; M 5 rou; nmn 5 1.0; S 5 2; if S 55 1 sat 5 sign(s); elseif S 55 2 fai 5 0.1;

%Saturated function

8.1 Sliding Mode Control of a Class of Underactuated System

if abs(s) , 5 fai sat 5 s/fai; else sat 5 sign(s); end end usw 5 2 inv(f1_x3*b)*(M*sat 1 nmn*s); ut 5 ueq 1 usw; v 5 (ut 2 t1*th1)/t3; sys(1) 5 v;

3. S function of plant: chap8_3plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [-10/57.3,0,0.20,0]; str 5 []; ts 5 [0 0]; function sys 5 mdlDerivatives(t,x,u) %Single Link Inverted Pendulum Parameters g 5 9.8;Mc 5 1.0;m 5 0.1;L 5 0.5; I 5 1/12*m*L^2; l 5 1/2*L;

279

280

CHAPTER 8 Sliding mode control of a class of underactuated systems

t1 5 m*(Mc 1 m)*g*l/[(Mc 1 m)*I 1 Mc*m*l^2]; t2 5 2 m^2*g*l^2/[(m 1 Mc)*I 1 Mc*m*l^2]; t3 5 2 m*l/[(Mc 1 m)*I 1 Mc*m*l^2]; t4 5 (I 1 m*l^2)/[(m 1 Mc)*I 1 Mc*m*l^2]; A 5 [0,1,0,0; t1,0,0,0; 0,0,0,1; t2,0,0,0]; B 5 [0;t3;0;t4]; C 5 [1,0,0,0; 0,0,1,0]; v 5 u(1); sys(1) 5 x(2); sys(2) 5 t1*x(1) 1 t3*v;

%ddth

sys(3) 5 x(4); sys(4) 5 t2*x(1) 1 t4*v;

%ddx

function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1);

%th

sys(2) 5 x(2); sys(3) 5 x(3);

%x

sys(4) 5 x(4); 4. Plot program: chap8_3plot.m close all; figure(1); subplot(411); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('x1-angle'); subplot(412); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('x2-angle speed'); subplot(413); plot(t,x(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('x3-cart position'); subplot(414); plot(t,x(:,4),'r','linewidth',2); xlabel('time(s)');ylabel('x4-cart speed'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('ut');

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

8.2 SLIDING MODE CONTROL BASED ON HURWITZ FOR AN UNDERACTUATED SYSTEM In this section, we will consider how to design the sliding mode control based on Hurwitz for two kinds of underactuated systems.

8.2.1 Sliding mode control based on Hurwitz for a simple underactuated system 8.2.1.1 System description Consider the same underactuated system of section 8.1.4.1 as x_1 5 x2 x_2 5 g sin x1 =l 1 x3 x_3 5 x4

ð8:11Þ

x_4 5 u 2 d;

where d is disturbance, jdj # D. The control goals are xi -0; i 5 1; 2; 3; 4 as t-N. Different from 8.1.1, in this section, we introduce a sliding mode controller design by Hurwitz.

8.2.1.2 Sliding mode controller design Define the sliding mode function as s 5 c1 x1 1 c1 x2 1 c3 x3 1 x4 ;

where c1 , c2 , and c3 will be designed based on Hurwitz. Then we have s_ 5 c1 x_1 1 c2 x_2 1 c3 x_3 1 x_4 5 c1 x2 1 c2 ðg sin x1 =l 1 x3 Þ 1 c3 x4 1 u 2 d:

Design the controller as u 5 2 c1 x2 2 c2 ðg sin x1 =l 1 x3 Þ 2 c3 x4 2 ks 2 ηsgnðsÞ;

ð8:12Þ

where k . 0, η . D. Substituting Eq. (8.12) into s_, we have s_ 5 2 ks 2 ηsgnðsÞ 2 d, then s_s 5 2 ks2 2 ηjsj 2 sd # 0.

281

282

CHAPTER 8 Sliding mode control of a class of underactuated systems

8.2.1.3 Hurwitz stability analysis The term s_s # 0 indicates that there exists ts , when t \$ ts , s 5 0, i.e., s 5 c1 x1 1 c1 x2 1 c3 x3 1 x4 5 0:

Then x4 5 2 c1 x1 2 c2 x2 2 c3 x3 :

ð8:13Þ

The system equilibrium point is xi -0; i 5 1; 2; 3; 4, at the equilibrium point, sin x1 5 x1 1 ε1 x1 , then we have x_1 5 x2 g g x_2 5 x1 1 x3 1 ε1 x1 l l x_3 5 2 c1 x1 2 c2 x2 2 c3 x3 ;

where ε1 is error caused by linearization. Then we obtain a state equation as x_ 5 Ax 1 εx;

ð8:14Þ

2 3 3 0 0 0 0 1 0 g 0 1 5, ε 5 4 ε1 0 0 5. x3 T , A 5 4 g=l l 2c1 2c2 2c3 0 0 0 2

where x 5 x1 x2

Since ε is very small value, if we design A as Hurwitz, the stability of x_ 5 Ax 1 εx can be guaranteed, and as t-N x-0, i.e., x1 x2 x3 -0.     2λ 1 0     From jA 2 λIj 5 0, we have  g=l 2λ 1  5 0, then    2c1 2c2 2c3 2 λ  2λ2 ðλ 1 c3 Þ 2 c1 2 c2 λ 1 ðλ 1 c3 Þ

and

g 50 l

g g 2λ3 2 c3 λ2 1 2c2 1 λ 2 c1 1 c3 5 0 l l

i.e.,

g g λ3 1 c3 λ2 1 c2 2 λ 1 c1 2 c3 5 0 l l

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

From ðλ13Þ3 5 0, we have λ3 1 9λ2 1 27λ 1 27 5 0, then we can get 8 c3 5 9 > > > g < c2 5 1 27 l > > > : c1 5 c3 g 1 27: l

ð8:15Þ

Moreover, consider s-0, we have x4 -0. Compared with sliding mode controller design of the first example in section 8.1, the design method in this section is easy.

8.2.1.4 Simulation example Consider a system as x_1 5 x2 x_2 5 g sin x1 =l 1 x3 x_3 5 x4 x_4 5 u 2 d

The initial states are set as 0:15

0 0 0 , and set d 5 10 sin t, l 5 10.

Using controller (8.12), and setting η 5 D 1 0:10, k 5 10, adapt the saturation function instead of the switch function, and let Δ 5 0:10. Simulation results are shown in Figs. 8.7 and 8.8.

x1

0.2 0 –0.2

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

x2

0.2 0 –0.2

x3

0.5 0 –0.5

x4

5 0 –.5

■ FIGURE 8.7 System states response.

283

CHAPTER 8 Sliding mode control of a class of underactuated systems

20 10 0 –10 –20 ut

284

–30 –40 –50 –60 –70

0

5

10 Time(s)

15

■ FIGURE 8.8 Control input. Simulation Programs:

1. Main program: chap8_4sim.mdl

2. S function of controller: chap8_4ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]);

20

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) l 5 10;g 5 9.8; x1 5 u(1);x2 5 u(2);x3 5 u(3);x4 5 u(4); c3 5 9; c2 5 g/l 1 27; c1 5 c3*g/l 1 27; s 5 c1*x1 1 c2*x2 1 c3*x3 1 x4; D 5 3.0; xite 5 D 1 0.10; S 5 2; if S 55 1 sat 5 sign(s); elseif S 55 2

%Saturated function

fai 5 0.10; if abs(s) , 5 fai sat 5 s/fai; else sat 5 sign(s); end end k 5 10; ut 5 2 c1*x2 2 c2*(g/l*sin(x1) 1 x3) 2 c3*x4 2 k*s 2 xite*sat; sys(1) 5 ut;

285

286

CHAPTER 8 Sliding mode control of a class of underactuated systems

3. S function of plant: chap8_4plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.15;0;0;0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); l 5 10; g 5 9.8; f1 5 g*sin(x(1))/l 1 x(3); sys(1) 5 x(2); sys(2) 5 f1; sys(3) 5 x(4); sys(4) 5 ut 2 3*sin(t); function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

4. Plot program: chap8_4plot.m close all; figure(1); subplot(411); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('x1'); subplot(412); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('x2'); subplot(413); plot(t,x(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('x3'); subplot(414); plot(t,x(:,4),'r','linewidth',2); xlabel('time(s)');ylabel('x4'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('ut');

8.2.2 Sliding mode control based on Hurwitz for an inverted pendulum 8.2.2.1 System description An inverted pendulum dynamic model is expressed as "

Mc 1 m

ml cos θ

#" # x€

ml cos θ

ml2

θ€

2 54

mlθ_ sin θ 2

mgl sin θ

3 51

" # u 0

;

ð8:16Þ

i.e., 2 ðMc 1 mÞx€ 1 ml θ€ cos θ 5 ml θ_ sin θ 1 u ml cos θx€ 1 ml2 θ€ 5 mgl sin θ;

where Mc is mass of cart, m is mass of pendulum, x is position of cart, and θ is pendulum angle, l denotes the pendulum length. _ _ The control goals are set as x-0, x-0, θ-0 and θ-0 as t-N.

287

288

CHAPTER 8 Sliding mode control of a class of underactuated systems

8.2.2.2 Sliding mode controller design Eq. (8.16) can be expressed as "

#" # " # x€ fa 1 u 5 ; Muu fu θ€

Maa

Mau

Mau

where Maa 5 Mc 1 m, Mau 5 ml cos θ, Muu 5 ml2 , fu 5 mgl sin θ.   Maa Mau Define M 5 , then Eq. (8.17) becomes Mau Muu "

"

fa 5 ml sin θUθ_ ,

21

5

fa 1 u

2Mau ð fa 1 uÞ 1 Maa fu Maa Muu 2 Mau Mau

5

2

#

" # fa 1 u 2Mau Maa 5 5 MðθÞ Maa Muu 2 Mau Mau θ€ fu fu " # " # Muu ð fa 1 uÞ 2 Mau fu Muu fa 2 Mau fu

" # x€

#

2Mau

Muu

ð8:17Þ

"

Muu u

#

2Mau fa 1 Maa fu 2Mau u 1 Maa Muu 2 Mau Mau Maa Muu 2 Mau Mau

i.e., x€ 5

Muu fa 2 Mau fu Muu 1 u Maa Muu 2 Mau Mau Maa Muu 2 Mau Mau

2 Mau fa 1 Maa fu 2 Mau 1 u: θ€ 5 Maa Muu 2 Mau Mau Maa Muu 2 Mau Mau

The above equation can be written as x€ 5 f1 1 b1 u θ€ 5 f2 1 b2 u;

ð8:18Þ

Muu fa 2Mau fu Muu 2Mau fa 1Maa fu , b1 5 , f2 5 Maa Muu 2Mau Mau Maa Muu 2Mau Mau Maa Muu 2Mau Mau 2Mau and b2 5 . Maa Muu 2Mau Mau where f1 5

For Eq. (8.18), define the sliding mode function as s 5 x_ 1 c1 x 1 c2 θ_ 1 c3 θ;

where c1 , c2 , and c3 are designed by Hurwitz. Then s_ 5 x€ 1 c2 θ€ 1 c1 x_ 1 c3 θ_ 5 f1 1 b1 u 1 c2 ð f2 1 b2 uÞ 1 c1 x_ 1 c3 θ_ _ 5 f1 1 c2 f2 1 ðb1 1 c2 b2 Þu 1 c1 x_ 1 c3 θ:

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

Design the controller as u52

1 ð f1 1 c2 f2 1 c1 x_ 1 c3 θ_ 1 ηsgnðsÞÞ; b1 1 c2 b2

ð8:19Þ

where η . 0. Substituting Eq. (8.19) into s_, we have s_ 5 2 ηsgnðsÞ; then we s_s 5 2ηsUsgnðsÞ 5 2ηjsj # 0:

8.2.2.3 Hurwitz stability analysis The term s_s # 0 indicates that there exists ts , when t \$ ts , we have s 5 x_ 1 c1 x 1 c2 θ_ 1 c3 θ 5 0;

i.e., x_ 5 2 c1 x 2 c2 θ_ 2 c3 θ:

Substituting Eq. (8.19) into Eq. (8.18), we obtain θ€ 5 f2 1 b2

21 _ ð f1 1 c2 f2 1 c1 x_ 1 c3 θÞ b1 1 c2 b2

5

1 _ ð f2 b1 1 c2 f2 b2 2 f1 b2 2 c2 f2 b2 2 b2 ðc1 x_ 1 c3 θÞÞ b1 1 c2 b2

5

1 _ ð f2 b1 2 f1 b2 2 b2 ðc1 x_ 1 c3 θÞÞ b1 1 c2 b2

5

f2 b1 2 f1 b2 b2 _ 2 ðc1 x_ 1 c3 θÞ b1 1 c2 b2 b1 1 c2 b2

5

1 _ ð fu 1 Mau ðc1 x_ 1 c3 θÞÞ; Muu 2 c2 Mau

where 2 Mau fa 1 Maa fu Muu fa 2 Mau fu Muu 1 Mau 5 Maa Muu 2 Mau Mau Maa Muu 2 Mau Mau Maa fu Muu 2 Mau fu Mau f2 b1 2 f1 b2 f2 Muu 1 f1 Mau fu 5 fu , 5 5 Maa Muu 2 Mau Mau b1 1 c2 b2 Muu 2 c2 Mau Muu 2 c2 Mau b2 2 Mau and 5 . b1 1 c2 b2 Muu 2 c2 Mau f2 Muu 1 f1 Mau 5

289

290

CHAPTER 8 Sliding mode control of a class of underactuated systems

Adding Muu and Mau into the above, we have θ€ 5

1 _ ðmgl sin θ 1 ml cos θðc1 x_ 1 c3 θÞÞ ml2 2 c2 ml cos θ

5

1 _ ðg sin θ 1 cos θðc1 ð2 c1 x 2 c2 θ_ 2 c3 θÞ 1 c3 θÞÞ l 2 c2 cos θ

5

g sin θ 1 cos θð2 c1 c3 θ 1 ð2 c1 c2 1 c3 Þθ_ 2 c1 c1 xÞ : l 2 c2 cos θ

_ y3 5 x, then Define y1 5 θ; y2 5 θ; y_1 5 y2 g sin y1 1 cos y1 ð2 c1 c3 y1 1 ð2 c2 c1 1 c3 Þy2 2 c1 c1 y3 Þ y_2 5 l 2 c2 cos θ y_3 5 2 c3 y1 2 c2 y2 2 c1 y3 :

ð8:20Þ

The system equilibrium point is θ 5 0; θ_ 5 0; x 5 0; x_ 5 0, i.e., y1 5 0; y2 5 0; y3 5 0. At the equilibrium point, let sin θ  θ, cos θ  1, then Eq. (8.20) becomes y_1 5 y2 gy1 2 c1 c3 y1 1 ð2 c2 c1 1 c3 Þy2 2 c1 c1 y3 y_2 5 1 ε1 y1 1 ε2 y2 1 ε3 y3 ; l 2 c2 y_3 5 2 c3 y1 2 c2 y2 2 c1 y3

where εi is error caused by linearization, i 5 1; 2; 3. Then we obtain 2

0 where A 5 4 A21 2c3

y_ 5 Ay 1 εy;

1 A22 2c2

3

2

0 0 A23 5, ε 5 4 ε1 2c1 0

0 ε2 0

3

ð8:21Þ

0 ε3 5. 0

Since εi is a very small value, if we design A as Hurwitz, the stability of y_ 5 Ay 1 εy can be guaranteed, then if t-N, we have y-0, i.e., _ y1 y2 y3 -0, or x-0, θ-0 and θ-0. Moreover, consider s-0; _ we have x-0. g 2 c1 c3 2 c2 c1 1 c3 c2 , A22 5 and A23 5 2 1 , from l 2 c2 l 2 c2 l 2 c2    2λ 1 0   A23  5 0, then jA 2 λIj 5 0, we have  A21 A22 2 λ  2c3 2c2 2c1 2 λ 

Let c2 6¼ l, A21 5

2λðλ 2 A22 Þðλ 1 c1 Þ 2 c3 A23 2 c2 λA23 2 ð2 c1 2 λÞA21 5 0;

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

i.e., λ3 2 ðA22 2 c1 Þλ2 1 ð2 c1 A22 2 A21 1 c2 A23 Þλ 2 c1 A21 1 c3 A23 5 0:

Compared with the above equation, from ðλ 1 1Þðλ 1 2Þðλ 1 3Þ 5 1, i.e., λ3 1 6λ2 1 11λ 1 6 5 0, we can get equation sets as 8 > : 2 c1 A21 1 c3 A23 5 6:

Since A22 2 c1 5

2 c2 c1 1 c3 2 lc1 1 c2 c1 c3 2 lc1 5 l 2 c2 l 2 c2 2 c2 c1 1 c3 g 2 c1 c3 c2 2 2 c2 1 l 2 c2 l 2 c2 l 2 c2 c2 c21 2 c1 c3 2 g 1 c1 c3 2 c2 c21 g 5 52 l 2 c2 l 2 c2

2 c1 A22 2 A21 1 c2 A23 5 2 c1

2c1 A21 1 c3 A23 5 2 c1

g 2 c1 c3 c3 c21 2 c1 g 1 c21 c3 2 c3 c21 c1 g 2 5 52 ; l 2 c2 l 2 c2 l 2 c2 l 2 c2

i.e., 8 c3 2 lc1 > > 56 >2 > l 2 c2 > > < g 5 11 2 > l 2 c2 > > > c g > > : 2 1 5 6: l 2 c2

Then 8 lc 2 c3 5 6ðl 2 c2 Þ > < 1 11ðl 2 c2 Þ 5 2 g > : c1 g 5 2 6ðl 2 c2 Þ:

The solution of the above equations are 8 g > c2 5 l 1 > > 11 > < 6 c1 5 ðc2 2 lÞ > > g > > : c3 5 lc1 1 6ðc2 2 lÞ:

ð8:22Þ

291

CHAPTER 8 Sliding mode control of a class of underactuated systems

8.2.2.4 Simulation example

Cart position response

Angle speed response

Angle response

Consider system (8.16); we choose mc 5 0:4, m 5 0:14, l 5 0:215 h π i 0 0:5 0 , 2 and g 5 9:8, and set initial system states as 3 use Eq. (8.22) to get c1 , c2 , and c3 . In controller (8.19), set η 5 50, use the saturation function instead of the switch function, set Δ 5 0.10. The simulation results are shown in Figs. 8.9 and 8.10.

Cart speed response

292

1

0

–1

0

5

10

15

20

25 Time(s)

30

35

40

45

50

0

5

10

15

20

25 Time(s)

30

35

40

45

50

0

5

10

15

20

25 Time(s)

30

35

40

45

50

0

5

10

15

20

25 Time(s)

30

35

40

45

50

1

0

–1

5 0 –5 –10

5

0

–5

■ FIGURE 8.9 System states response.

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

4 3

Control input

2 1 0 –1 –2 –3 –4

0

5

10

15

20

25 Time(s)

30

35

40

45

■ FIGURE 8.10 Control input.

Simulation Programs:

1. Main program: chap8_5sim.mdl

2. S function of controller: chap8_5ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0,

50

293

294

CHAPTER 8 Sliding mode control of a class of underactuated systems

[sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(1);x2 5 u(2);

%Pendulum angle

x3 5 u(3);x4 5 u(4);

%Cart

g 5 9.8;mc 5 0.4;m 5 0.14;l 5 0.215; c2 5 l 1 g/11; c1 5 6/g*(c2 2 l); c3 5 l*c2 1 6*(c2 2 l); s 5 x4 1 c1*x3 1 c2*x2 1 c3*x1; Maa 5 mc 1 m; Mau 5 m*l*cos(x1); Muu 5 m*l^2; fa 5 m*l*sin(x1)*x2^2; fu 5 m*g*l*sin(x1); xite 5 3; fai 5 0.10; if abs(s) , 5 fai sat 5 s/fai;

8.2 Sliding Mode Control Based on Hurwitz for an Underactuated System

else sat 5 sign(s); end b1 5 Muu/(Maa*Muu-Mau^2); b2 5 -Mau/(Maa*Muu-Mau^2); f1 5 (Muu*fa-Mau*fu)/(Maa*Muu-Mau^2); f2 5 (-Mau*fa 1 Maa*fu)/(Maa*Muu-Mau^2); ut 5 -1/(b1 1 c2*b2)*(f1 1 c2*f2 1 c1*x4 1 c3*x2 1 xite*sat); sys(1) 5 ut;

3. S function of plant: chap8_5plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [ 2 pi/3,0,0.5,0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) g 5 9.8;mc 5 0.4;m 5 0.14;l 5 0.215; th 5 x(1); dth 5 x(2);

295

296

CHAPTER 8 Sliding mode control of a class of underactuated systems

M 5 [mc 1 m m*l*cos(th); m*l*cos(th) m*l^2]; fa 5 m*l*sin(th)*dth^2; fu 5 m*g*l*sin(th); F 5 [fa;fu]; U 5 [u(1);0]; a 5 inv(M)*(F 1 U); ddx 5 a(1); ddth 5 a(2); sys(1) 5 x(2); sys(2) 5 ddth;

%Pendulum angle

sys(3) 5 x(4); sys(4) 5 ddx;

%Cart

function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

4. Plot program: chap8_5plot.m close all; figure(1); subplot(411); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('Angle response'); subplot(412); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('Angle speed response'); subplot(413); plot(t,x(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('Cart position response'); subplot(414); plot(t,x(:,4),'r','linewidth',2); xlabel('time(s)');ylabel('Cart speed response'); figure(2); plot(t,u(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('Control input');

8.3 Sliding Mode Control for a Special Underactuated System

8.3 SLIDING MODE CONTROL FOR A SPECIAL UNDERACTUATED SYSTEM 8.3.1 System description Consider a special underactuated nonlinear system as x_1 5 x2 x_2 5 g sin x1 =l 1 x33 x_3 5 x4

ð8:23Þ

x_4 5 u;

where f ðx1 ; x3 Þ 5 g sin x1 =l 1 x33 , u is control input. The control goals are xi -0; i 5 1; 2; 3; 4 as t-N. If we design the sliding mode controller according to traditional method, define the error state equation as e1 5 x1 e2 5 e_1 5 x2 e3 5 e€1 5 x_2 5 f ðx1 ; x3 Þ @f @f e4 5 ⃛e 1 5 f_ 5 x2 1 x4 : @x1 @x3

ð8:24Þ

Design the sliding mode function as s 5 c1 e1 1 c2 e2 1 c3 e3 1 e4 ;

ð8:25Þ

where ci . 0, i 5 1; 2; 3. From Eq. (8.25), we have s_ 5 c1 e_1 1 c2 e_2 1 c3 e_3 1 e_4       @f @f d @f d @f @f x4 1 5 c1 x2 1 c2 f 1 c3 x2 1 x4 1 x2 1 u: @x1 @x3 dt @x1 dt @x3 @x3 ð8:26Þ

@f1 @f 5 1, in this section, 5 3x23 is @x3 @x3 invertible, u will not be realized. In the following, reference to [1], a new sliding mode controller design method is introduced. or the first example in Section 8.1,

8.3.2 Sliding mode controller design @f is invertible, sliding mode control cannot be designed. @x3 To overcome this question, we define a new function, f1 ðx1 ; x3 Þ, as

Consider

f ðx1 ; x3 Þ 5 g sin x1 =l 1 x33 1 x3 2 x3 5 f1 ðx1 ; x3 Þ 2 x3 ;

where f1 ðx1 ; x3 Þ 5 g sin x1 =l 1 x33 1 x3 .

297

298

CHAPTER 8 Sliding mode control of a class of underactuated systems

In the sliding mode controller design, f1 ðx1 ; x3 Þ must be satisfied as three assumptions as follows: Assumption 1: f1 ð0; 0Þ-0; @f1 is invertible; Assumption 2: @x3 Assumption 3: if f1 ð0; x3 Þ-0, then x3 -0. Then Eq. (8.23) becomes x_1 5 x2 x_2 5 f1 ðx1 ; x3 Þ 2 x3 x_3 5 x4 x_4 5 u:

ð8:27Þ

And we can get error state equation as e1 5 x1 e2 5 e_1 5 x2

ð8:28Þ

e3 5 f1 ðx1 ; x3 Þ e4 5 e_3 5 f_1 ðx1 ; x3 Þ 5

@f1 @f1 x2 1 x4 : @x1 @x3

In the above equation, to prevent singularity in the controller design, we do not let e3 5 e_2 . Design the sliding mode function as s 5 c1 e1 1 c2 e2 1 c3 e3 1 e4 ;

ð8:29Þ

where ci . 0, i 5 1; 2; 3. Then s_ 5 c1 e_1 1 c2 e_2 1 c3 e_3 1 e_4     @f1 @f1 d @f1 @f1 5 c1 x2 1 c2 ðf1 2 x3 Þ 1 c3 x2 1 x4 1 x2 1 x4 ; dt @x1 @x1 @x3 @x3 ð8:30Þ

where

      d @f1 @f1 d @f1 @f1 d @f1 @f1 x2 1 x4 1 x2 1 x4 5 ðf1 2x3 Þ1 u. dt @x1 dt @x1 dt @x3 @x3 @x1 @x3

Then 

 @f1 @f1 x2 1 x4 @x1 @x3     d @f1 @f1 d @f1 @f1 1 x2 1 x4 1 ð f1 2 x3 Þ 1 u: @x1 @x3 dt @x1 dt @x3

s_ 5 c1 x2 1 c2 ð f1 2 x3 Þ 1 c3

ð8:31Þ

8.3 Sliding Mode Control for a Special Underactuated System     @f1 @f1 d @f1 x2 1 M 5 c1 x2 1 c2 ðf1 2 x3 Þ 1 c3 x2 1 x4 1 dt @x1 @x1 @x3   @f1 d @f1 ð f1 2 x 3 Þ 1 x4 ; the sliding mode controller can be designed as dt @x3 @x1 Define



@f1 u5 @x3

21

2 M 2 ηsgns 2 ks ;

ð8:32Þ

where η . 0, k . 0. Substituting Eq. (8.32) into Eq. (8.31), we have s_ 5 2 ηsgnðsÞ 2 ks. Design the Lyapunov function as V 5 12 s2 , then we have V_ 5 s_s 5 2 ηjsj 2 ks2 # 0:

8.3.3 Convergence analysis From Eqs. (8.27) and (8.28), we have e_1 5 e2 , e_2 5 e3 2 x3 and e_3 5 e4 . From s_s # 0, under controller (8.32), the system can reach and thereafter stay on the manifold s 5 0 in finite time. On the manifold, we have s 5 0, i.e., e4 5 2 c1 e1 2 c2 e2 2 c3 e3 . 2 3 0 1 0 Define A 5 4 0 0 1 5, and design A as Hurwitz, then 2c1 2c2 2c3 e_1 5 e2 e_2 5 e3 2 x3

ð8:33Þ

e_3 5 2 c1 e1 2 c2 e2 2 c3 e3 :

d2 5 2 x3 , Define E 5 e1 e2 e3 T , from e3 5 f1 ðx1 ; x3 Þ 5 g sin x1 =l 1 x33 1 x3 , we have d2 5 2 x3 5g sin x1 =l 1 x33 2 e3 , then x3 ð1 1 x23 Þ 5 e3 2 g sin x1 =l, consider sin x1 , x1 , we can obtain jx3 j # jx3 jð1 1 x23 Þ 5 je3 2 g sin x1 =lj # je3 j 1 gje1 j=l:

Then we obtain jd2 j # ð1 1 g=lÞjjEjj2 :

Define D 5 0 d2 we have

0 T , γ 5 1 1 g=l and jjDjj2 # γjjEjj2 , from Eq. (8.33),

To guarantee E 5 e1

E_ 5 AE 1 D:

e2

ð8:34Þ

e3 T -0, A must be designed as Hurwitz.

299

300

CHAPTER 8 Sliding mode control of a class of underactuated systems   2λ  0  2c1

Since jA 2 λIj 5 

1 2λ 2c2

  0   5 λ2 ð2 c3 2 λÞ 2 c1 2 c2 λ 5 2 λ3 2 1  2c3 2 λ 

c3 λ2 2 c2 λ 2 c1 5 0; from ðλ1aÞ3 5 0, we 3a2 λ 1 a3 5 0, then we can design ci as follows:

have

λ3 1 3aλ2 1

c1 5 a3 ; c2 5 3a2 ; c3 5 3a; a . 0:

ð8:35Þ

Let Q 5 QT . 0, since A is Hurwitz, there exists the Lyapunov equation AT P 1 PA 5 2 Q, P 5 PT . 0. Design the Lyapunov function as V1 5 ET PE, then T _ T PE1ET PE5ðAE1DÞ _ PE1ET PðAE1 DÞ V_ 1 5 E

5ET AT PE1 DT PE1ET PAE1ET PD5ET ðAT P 1PAÞE1 DT PE1ET PD 52 ET QE1 DT PE1 ET PD# 2λmin ðQÞjjEjj22 12λmax ðPÞγjjEjj22 5ð2λmin ðQÞ1 2λmax ðPÞγÞjjEjj22 ;

where DT PE 1 ET PD # 2λmax ðPÞγjjEjj22 , λmin ðQÞ is the minimum eigenvalue of Q and λmax ðPÞ is the maximum eigenvalue of P. λmin ðQÞ . γ. Choose Q 5 I 3 , thus λmin ðQÞ 5 1, To realize V_ 1 # 0, let 2λmax ðPÞ 1 λmin ðQÞ , and . γ becomes λleft ð2 AÞ . γ, which λmax ðPÞ 5 2λleft ð2 AÞ 2λmax ðPÞ can be realized by A design. If we design A as Hurwitz, E 5 e1 e2 e3 T -0 will be satisfied, and then we have e1 -0, e2 -0, e3 -0, from s-0, we have e4 -0. Then we can get x1 -0, x2 -0, Consider e3 5 f1 ð0; x3 Þ-0, assumption 3 and Eq. (8.24), we can get x3 -0, x4 -0.

8.3.4 Simulation example Consider a system as x_1 5 x2 x_2 5 g sin x1 =l 1 x33 x_3 5 x4 x_4 5 u;

where f1 ðx1 ; x3 Þ 5 g sin x1 =l 1 x33 1 x3 , l 5 10. The control goals are xi -0; i 5 1; 2; 3; 4. From f1 ðx1 ; x3 Þ expression,   @f1 @f1 d @f1 g we have 5 g cos x1 =l, 5 3x23 1 1, 5 2 sin x1  x2 dt @x1 l @x1 @x3

8.3 Sliding Mode Control for a Special Underactuated System   d @f1 5 6x3 x4 , and dt @x3 0:1 0:1 0:1 0:1 .

the

initial

system

states

are

set

as

Considering γ 5 1 1 g=l 5 1:98, choose a 5 50, then we can get c1 c2 and c3 by Eq. (8.35). Use controller (8.31), and set k 5 1:0, η 5 5:0. Use the saturation function instead of the switch function, and set Δ 5 0.10. We obtain the simulation results, which are shown in Figs. 8.11 and 8.12.

x1

0.2 0 –0.2

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

0

5

10 Time(s)

15

20

x2

0.1 0 –0.1

x3

0.5 0 –0.5

x4

1 0 –1

■ FIGURE 8.11 System states response.

1

x 104

0.5 0

ut

–0.5 –1 –1.5 –2 –2.5 –3

0

5

10

15

20

25 Time(s)

■ FIGURE 8.12 Control input.

30

35

40

45

50

301

302

CHAPTER 8 Sliding mode control of a class of underactuated systems

Simulation Programs:

1. Main program: chap8_6sim.mdl

2. S function of controller: chap8_6ctrl.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 [];

8.3 Sliding Mode Control for a Special Underactuated System

ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) x1 5 u(1);x2 5 u(2);x3 5 u(3);x4 5 u(4); l 5 10;g 5 9.8; f1 5 g*sin(x1)/l 1 x3^3 1 x3; f1_x1 5 g*cos(x1)/l; f1_x3 5 3*x3^2 1 1; dt_f1_x1 5 -g*sin(x1)/l*x2; dt_f1_x3 5 6*x3*x4; e1 5 x1; e2 5 x2; e3 5 f1; e4 5 f1_x1*x2 1 f1_x3*x4; a 5 50; c1 5 a^3;c2 5 3*a^2;c3 5 3*a; s 5 c1*e1 1 c2*e2 1 c3*e3 1 e4; M 5 c1*x2 1 c2*(f1-x3) 1 c3*(f1_x1*x2 1 f1_x3*x4) 1 dt_f1_x1 *x2 1 f1_x1*(f1-x3) 1 dt_f1_x3*x4; k 5 1;xite 5 5; fai 5 0.010; if abs(s) , 5 fai sat 5 s/fai; else sat 5 sign(s); end ut 5 1/f1_x3*(-M-k*s-xite*sat); sys(1) 5 ut;

3. S function of plant: chap8_6plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u);

303

304

CHAPTER 8 Sliding mode control of a class of underactuated systems

case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [0.10;0.10;0.10;0.10]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) ut 5 u(1); l 5 10;g 5 9.8; sys(1) 5 x(2); sys(2) 5 g*sin(x(1))/l 1 (x(3))^3; sys(3) 5 x(4); sys(4) 5 ut; function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

4. Plot program: chap8_6plot.m close all; figure(1); subplot(411); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('x1'); subplot(412); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('x2');

References 305

subplot(413); plot(t,x(:,3),'r','linewidth',2); xlabel('time(s)');ylabel('x3'); subplot(414); plot(t,x(:,4),'r','linewidth',2); xlabel('time(s)');ylabel('x4'); figure(2); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('ut');

REFERENCES [1] X. Rong, U. Ozguner, Sliding mode control of a class of underactuated systems, Automatica 44 (2008) 233248. [2] H. Ashrafiuona, R.S. Erwinb, Sliding mode control of underactuated multibody systems and its application to shape change control, Int. J. Control. 81 (12) (2008) 18491858.

Chapter

9

Sliding mode control for underactuated system with decoupling algorithm In the paper [1,2], a general decoupling algorithm for under actuated system was proposed, refer to this paper, in this chapter, two sections are introduced as follows: In Section 9.1, general decoupling algorithm for underactuated system is introduced, an example is given. In Section 9.2, consider a single inverted pendulum dynamic model, the standard decoupling algorithm is used to decouple the system, a sliding mode controller is designed by using Hurwitz, an example is given. In Section 9.3, consider a translational oscillator with rotational actuator (TORA) system, the standard decoupling algorithm is used to decouple the system, a sliding mode controller is designed by using Hurwitz, an example is given.

9.1 GENERAL DECOUPLING ALGORITHM FOR UNDERACTUATED SYSTEM R.O. Saber proposed a general decoupling algorithm for under actuated system [1,2]. Consider the following coupled under actuated system q_1 5 p1 p_1 5 f1 ðq; pÞ 1 g1 ðq2 Þu q_2 5 p2

;

ð9:1Þ

p_2 5 f2 ðq; pÞ 1 g2 ðq2 Þu

where q 5 ½ q1

q2 , p 5 ½ p1

p2 .

Sliding Mode Control Using MATLAB. DOI: http://dx.doi.org/10.1016/B978-0-12-802575-8.00009-6 Copyright © 2017 Tsinghua University Press Limited. Published by Elsevier Inc. All rights reserved.

307

308

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

Model decoupling algorithm is designed as [1]: x1 5 q1 2

ð q2 0

g1 ðsÞ ds g2 ðsÞ

g1 ðq2 Þ p2 x2 5 p1 2 g2 ðq2 Þ x3 5 q2

:

ð9:2Þ

x4 5 p2

The essence of decoupling algorithm is to remove u in x_2 . From Eq. (9.2) we can get  0   g1 g1 p_ p2 2 g2 g2 2  0 g1 g1 5 f1 1 g 1 u 2 p2 2 ð f2 1 g2 uÞ : g2 g2  0 g1 g1 5 f1 2 p2 2 f2 g2 g2

x_2 5 p_1 2

Then Eq. (9.1) can be decoupled as x_1 5 x2 x_2 5 f1 2

 0 g1 g1 p2 2 f2 : g2 g2

ð9:3Þ

x_3 5 x4 x_4 5 f2 1 g2 u

9.2 SLIDING MODE CONTROL FOR AN INVERTED PENDULUM 9.2.1 System description Consider a single inverted pendulum dynamic model, near the equilibrium point, we have sin θ  θ, cos θ  1, then we can get a linear equation for the single inverted pendulum as θ€ 5

mðm 1 MÞgl ml θ2 ðu 1 dðtÞÞ ðM 1 mÞI 1 Mml2 ðM 1 mÞI 1 Mml2

x€ 5 2

m2 gl2 I 1 ml2 θ1 ðu 1 dðtÞÞ 2 ðM 1 mÞI 1 Mml ðM 1 mÞI 1 Mml2

;

ð9:4Þ

where M is the mass of cart, m is the mass of pendulum, x is the position of cart, θ is the pendulum angle, L denotes the pendulum length, l 5 12 L, u is the control input, I 5 13 ml2 is the moment of inertia for the pendulum around its center of gravity and d(t) is disturbance. _ _ The control goals are x-0, x-0, θ-0 and θ-0.

9.2 Sliding Mode Control for an Inverted Pendulum

9.2.2 Model decoupling In order to design the sliding mode controller, model (9.4) needs to be _ p2 5 x, _ define decoupled. Define q1 5 θ, q2 5 x, then p1 5 θ, 1 MÞgl m gl ml f1 ðq; pÞ5 ðMmðm 1mÞI 1 Mml2 q1 , g1 ðq2 Þ52 ðM 1mÞI 1Mml2 , f2 ðq;pÞ52 ðM 1mÞI 1Mml2 q1 2

g1 ðq2 Þ I 1 ml and g2 ðq2 Þ5 ðM 1mÞI 1Mml2 , then g2 ðq2 Þ 5 2

2

ml ðM 1 mÞI 1 Mml2 I 1ml2 ðM 1 mÞI 1 Mml2

2

52I 1mlml2 .

Using the standard decoupling algorithm (9.2), we can get a decoupling algorithm as ð q2

g1 ðsÞ ml ds 5 q1 1 q2 g2 ðsÞ I 1 ml2 g1 ðq2 Þ ml p2 5 p1 1 z2 5 p1 2 p2 : g2 ðq2 Þ I 1 ml2 ξ 1 5 q2 ξ 2 5 p2 z1 5 q1 2

0

ð9:5Þ

_ Then the balance point of the inverted pendulum θ-0, x-0, θ-0 and _x-0 is equivalent to z1 -0, z2 -0 and ξ 1 -0, ξ 2 -0. Using the decoupling algorithm, we obtain z_1 5 z2   mðm 1 MÞgl ml m2 gl2 q1 z_2 5 2 ðM 1 mÞI 1 Mml2 I 1 ml2 ðM 1 mÞI 1 Mml2 : ξ_ 1 5 ξ 2 ξ_ 2 5 2

m2 gl2 I 1 ml2 q1 1 ðu 1 dðtÞÞ 2 ðM 1 mÞI 1 Mml ðM 1 mÞI 1 Mml2

mðm 1 MÞgl m2 gl2 ml ðM 1 mÞI 1 Mml2 2 I 1 ml2 ðM 1 mÞI 1 Mml2 , I 1 ml2 ðM 1 mÞI 1 Mml2 , Eq. (9.6) then becomes

Defining T1 5 and T3 5

ð9:6Þ

2

2

m gl T2 5 2 ðM 1 mÞI 1 Mml2

z_1 5 z2 z_2 5 T1 q1 : ξ_ 1 5 ξ 2 ξ_ 2 5 T2 q1 1 T3 ðu 1 dðtÞÞ

Considering q1 5 z1 2 I 1mlml2 q2 5 z1 2 I 1mlml2 ξ 1 5 z1 1 T4 ξ 1 ml T4 5 2 I 1 ml2 , then Eq. (9.7) becomes z_1 5 z2 z_2 5 T1 z1 1 T1 T4 ξ 1 : ξ_ 1 5 ξ 2 ξ_ 2 5 T2 z1 1 T2 T4 ξ 1 1 T3 ðu 1 dðtÞÞ

ð9:7Þ

and

ð9:8Þ

309

310

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

9.2.3 Sliding mode controller design  For Eq. (9.8), define μ1 5 ξ 2 ; µ2 5 z1 mode controller as

z2

ξ 1 Τ , design the sliding

σ 5 μ1 2 Cµ2 ;

 where C 5 c1

ð9:9Þ

c3 .

c2

Then we have _ 2 5 T2 z1 1 T2 T4 ξ 1 1 T3 ðu 1 dðtÞÞ 2 Cµ _ 2: σ_ 5 μ_ 1 2 Cµ

Design the sliding mode controller as u5

1 _ 2 2 hsgnðσÞÞ; ð2T2 z1 2 T2 T4 ξ 1 1 Cµ T3

ð9:10Þ

  where h \$ dðtÞ. Design the Lyapunov function as 1 V 5 σ2 ; 2

then σσ_ 5 σð2hsgnðσÞ 1 dðtÞÞ # 0:

From σσ_ # 0, under controller (9.10), the system can reach and thereafter stay on the manifold σ 5 0 in finite time ts. On the manifold, we have σ 5 μ1 2 Cµ2 5 0, i.e., μ1 5 Cµ2 .

9.2.4 C design When t \$ ts , we have 2

3 z2 _ 2 5 4 T1 z1 1 T1 T4 ξ 1 5 5 A1 μ1 1 A2 µ2 5 ðA1 C 1 A2 Þµ2 ; µ ξ2

2

0 where A1 5 0 0 1 Τ , A2 5 4 T1 0 

ð9:11Þ

3 1 0 0 T1 T4 5. 0 0

To guarantee µ2 -0, A1 C 1 A2 should be Hurwitz, thus we can get μ1 5 Cµ2 -0.

9.2 Sliding Mode Control for an Inverted Pendulum  From μ1 5 ξ 2 ; µ2 5 z1 z2 ξ 1 Τ , we know if t-N, we have z1 -0, _ _ x-0 and x-0. z2 -0, ξ 2 -0 and ξ 2 -0, that is, θ-0, θ-0, 2  A1 C 1 A2 5 0 2

0

 0 1 Τ c1

c2

3

2

0

6 56 40

0

c1

c2

0

0

6 c3  1 6 4 T1

1

0

3

7 0 T1 T4 7 5

0

0

7 6 6 07 5 1 4 T1 c3 0

0 0 3 2 1 0 0 7 6 6 7 0 T1 T4 5 5 4 T1

0

0

c2

0

c1

1

3:

0

7 T1 T4 7 5 c3

The poles of A1 C 1 A2 can be designed by the following:   s    sI 2 ðA1 C 1 A2 Þ 5  2T1   2c 1

21 s 2c2

    2T1 T4   s2c  0

3

: ð9:12Þ

5 s 2 c3 s 2 T1 T4 c1 2 c2 T1 T4 s 2 T1 ðs 2 c3 Þ 3

2

5 s3 2 c3 s2 2 ðc2 T1 T4 1T1 Þs 2 T1 T4 c1 1T1 c3 5 0

From ðs1kÞ3 5 0, k . 0, we have s3 1 3ks2 1 3k2 s 1 k3 5 0; comparing with Eq. (9.12), we can get 8 < 2c3 5 3k 2c T T 2 T1 5 3k2 : : 2 1 4 2T1 T4 c1 1T1 c3 5 k3

To make A1 C 1 A2 Hurwitz, the sliding mode parameters are designed as follows: 8 c3 5 2 3k > > > > 3k2 1T1 < c2 5 2 T1 T4 : > > 3 > k > : c1 5 2 2 T1 c3 T1 T4

ð9:13Þ

9.2.5 Simulation example Considering plant as (9.4), choose M 5 1, m 5 0.10, L 5 0.50, the initial _ 5 0, xð0Þ 5 0:20, xð0Þ _ 5 0, and set states are set as θð0Þ 5 2108, θð0Þ dðtÞ 5 sint. Use controller (9.10), design C by Eq. (9.13), choose k 5 5 and h 5 1.5. Use the saturation function instead of the switch function, and set Δ 5 0.01. We can then obtain the simulation results, which are shown in Figs. 9.19.3.

311

312

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

0.2 th

Angle

0.1 0 –0.1 –0.2

0

5

10

15

20

Time/(s)

Angle speed

0.8 dth

0.6 0.4 0.2 0 –0.2

0

5

10 Time/(s)

15

20

■ FIGURE 9.1 Angle and angle speed of pendulum.

0.3

Cart position

x 0.2 0.1 0 –0.1

0

5

10 Time/(s)

15

20

0.2

Cart speed

dx 0 –0.2 –0.4 –0.6

0

■ FIGURE 9.2 Position and speed of cart.

5

10 Time/(s)

15

20

9.2 Sliding Mode Control for an Inverted Pendulum

2 1 0

Control input u

–1 –2 –3 –4 –5 –6 –7 –8

0

2

4

6

8

10 Time (s)

■ FIGURE 9.3 Control input.

Matlab programs:

1. Simulink main program: chap9_1sim.mdl

12

14

16

18

20

313

314

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

2. S function for controller; chap9_1ctrl.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {1, 2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [ ]; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) g 5 9.8;M 5 1.0;m 5 0.1;L 5 0.5; I 5 1/12*m*L^2;l 5 1/2*L; T4 5 2 m*l/(I 1 m*l^2); T2 5 2 m^2*g*l^2/[(m 1 M)*I 1 M*m*l^2]; T3 5 (I 1 m*l^2)/[(m 1 M)*I 1 M*m*l^2]; T1 5 m*(M 1 m)*g*l/[(M 1 m)*I 1 M*m*l^2] 2 T4*T2; th 5 u(1);dth 5 u(2); x 5 u(3);dx 5 u(4); q1 5 th;q2 5 x; p1 5 dth;p2 5 dx; z1 5 q1 1 m*l/(I 1 m*l^2)*q2; z2 5 p1 1 m*l/(I 1 m*l^2)*p2; kesi1 5 q2; kesi2 5 p2;

9.2 Sliding Mode Control for an Inverted Pendulum

miu1 5 kesi2; miu2 5 [z1 z2 kesi1]'; %%%%%%%%%%%%%%%%%%%%%%; k 5 5; c3 5 2 3*k; c2 5 2 (3*k^2 1 T1)/(T1*T4); c1 5 2 (k^3 2 T1*c3)/(T1*T4); C 5 [c1 c2 c3]; %%%%%%%%%%%%%%%%%%%%%%% sigma 5 miu1 2 C*miu2; dmiu2 5 [z2;T1*z1 1 T1*T4*kesi1;kesi2]; h 5 1.5; fai 5 0.01; if abs(sigma) , 5 fai sat 5 sigma/fai; else sat 5 sign(sigma); end ut 5 1/T3*( 2 T2*z1 2 T2*T4*kesi1 1 C*dmiu2 2 h*sat); sys(1) 5 ut;

3. S function for the plant: chap9_1plant.m function [sys,x0,str,ts] 5 spacemodel(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4; sizes.NumInputs 5 1;

315

316

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 [ 2 10/57.3,0,0.20,0]; %x0 5 [0.01,0,0.020,0]; str 5 []; ts 5 [0 0]; function sys 5 mdlDerivatives(t,x,u) %Single Link Inverted Pendulum Parameters g 5 9.8;M 5 1.0;m 5 0.1;L 5 0.5; I 5 1/12*m*L^2; l 5 1/2*L; t1 5 m*(M 1 m)*g*l/[(M 1 m)*I 1 M*m*l^2]; t2 5 2 m^2*g*l^2/[(m 1 M)*I 1 M*m*l^2]; t3 5 2 m*l/[(M 1 m)*I 1 M*m*l^2]; t4 5 (I 1 m*l^2)/[(m 1 M)*I 1 M*m*l^2]; ut 5 u(1); sys(1) 5 x(2); sys(2) 5 t1*x(1) 1 t3*(ut 1 sin(t));%ddth sys(3) 5 x(4); sys(4) 5 t2*x(1) 1 t4*(ut 1 sin(t));%ddx function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); %th sys(2) 5 x(2); sys(3) 5 x(3); %x sys(4) 5 x(4);

4. Plot program: chap9_1plot.m close all; figure(1); subplot(211); plot(t,x(:,1),'r','linewidth',2); legend('th');xlabel('time/(s)');ylabel('angle'); grid on; subplot(212); plot(t,x(:,2),'r','linewidth',2); legend('dth');xlabel('time/(s)');ylabel('angle speed'); grid on; figure(2); subplot(211); plot(t,x(:,3),'r','linewidth',2);

9.3 Sliding Mode Control for a TORA System

legend('x');xlabel('time/(s)');ylabel('cart position'); grid on; subplot(212); plot(t,x(:,4),'r','linewidth',2); legend('dx');xlabel('time/(s)');ylabel('cart speed'); grid on; figure(3); plot(t,ut(:,1),'k','linewidth',2); xlabel('time(s)');ylabel('control input u'); grid on;

9.3 SLIDING MODE CONTROL FOR A TORA SYSTEM A translational oscillator with rotational actuator (TORA) system has been constructed as a benchmark system to evaluate the performance of various nonlinear controllers.

9.3.1 System description The dynamics of the TORA system are described as z_1 5 z2 2z1 1 εθ22 sin θ1 ε cos θ1 z_2 5 2 v 1 2ε2 cos2 θ1 1 2 ε2 cos2 θ1 ; θ_ 1 5 θ2 ε cos θ1 ðz1 2 εθ22 sin θ1 Þ 1 1 v θ_ 2 5 1 2 ε2 cos2 θ1 1 2 ε2 cos2 θ1

ð9:14Þ

where z1 is the normalized displacement of the platform from the equilibrium position, z2 5 z_1 , θ1 is the angle of the rotor, z2 5 z_1 and v is control input. The control goals are z1 -0, z_1 -0, θ1 -0 and θ_ 1 -0 as t-N.

9.3.2 Model decoupling Apply the decoupling algorithm in Eq. (9.2) to Eq. (9.14), and let 2 z1 1 εθ22 sin θ1 1 2ε2 cos2 θ1 , g2 5 2 1 2ε2 1cos2 θ1 .

f1 5

θ1 g1 5 2 1 2εεcos 2 cos2 θ , 1

We then have

g1 g2

f2 5

ε cos θ1 ðz1 2 εθ22 sin θ1 Þ 1 2 ε2 cos2 θ1

and

5 ε cos θ1 .

Define x1 5 z1 1 ε sin θ1 ; x2 5 z2 1 εθ2 cos θ1 ; x3 5 θ1 ; x4 5 θ2 :

ð9:15Þ

317

318

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

From Eq. (9.15), we can see that the control goals z1 -0, z2 -0, θ1 -0, and θ2 -0 are equivalent to xi -0, i 5 1; 2; 3; 4. Since x_2 5 z_2 1 εθ_ 2 cos θ1 2 εθ22 sin θ1 5

2z1 1 εθ22 sin θ1 ε cos θ1 2 v 1 2 ε2 cos2 θ1 1 2 ε2 cos2 θ1 !   ε cos θ1 z1 2 εθ22 sin θ1 1 1ε 1 v cos θ1 2 εθ22 sin θ1 1 2 ε2 cos2 θ1 1 2 ε2 cos2 θ1

;

2z1 1 εθ22 sin θ1 ε2 cos θ1 ðz1 2 εθ22 sin θ1 Þ 5 1 2 εθ22 sin θ1 2 2 1 2 ε2 cos2 θ1 1 2 ε cos θ1 5

2z1 ð1 2 ε2 cos θ1 Þ 1 εθ22 sin θ1 ð1 2 ε2 cos θ1 Þ 2 εθ22 sin θ1 1 2 ε2 cos2 θ1

5 2z1 5 2x1 1 ε sin x3 ε cos θ1 ðz1 2 εθ22 sin θ1 Þ 2 1 2 ε2 1cos2 θ1 v, i.e., v 5 ε cos θ1 ðz1 2 εθ22 sin θ1 Þ 2 1 2 ε2 cos2 θ1 ð1 2 ε2 cos2 θ1 Þu, from z1 5 x1 2 εsinx3 , we have

let u 5

v 5 ε cos x3 ðx1 2 ð1 1 x24 Þ ε sin x3 Þ 2 ð1 2 ε2 cos2 x3 Þu:

ð9:16Þ

From the above analysis, Eq. (9.14) can be decoupled as x_1 5 x2 x_2 5 f1 ðx1 ; x3 Þ ; x_3 5 x4

ð9:17Þ

x_4 5 u

where f1 ðx1 ; x3 Þ 5 2x1 1 ε sin x3 . In paper [3], a sliding mode controller is designed for a kind of underactuated system, in which f1 ðx1 ; x3 Þ must be satisfied as three assumptions as follows: Assumption 1: f1 ð0; 0Þ-0; @f1 is invertible; Assumption 2: @x 3

Assumption 3: if f1 ð0; x3 Þ-0, then x3 -0.

@f1 Obviously if Eq. (9.17), @x is not satisfied by Assumption 2, we can rede3 fine f1 ðx1 ; x3 Þ as

f1 ðx1 ; x3 Þ 5 2x1 1 ε sin x3 1 11εx3 :

9.3 Sliding Mode Control for a TORA System

@f1 Then @x 5 ε cos x3 1 11ε, and Eq. (9.17) becomes 3

x_1 5 x2 x_2 5 f1 ðx1 ; x3 Þ 2 11εx3 : x_3 5 x4 x_4 5 u

ð9:18Þ

9.3.3 Sliding mode controller design To realize xi -0, define the error equation as e1 5 x1 e2 5 e_1 5 x2 e3 5 f1 ðx1 ; x3 Þ

:

ð9:19Þ

@f1 @f1 e4 5 e_3 5 f_1 ðx1 ; x3 Þ 5 x2 1 x4 @x1 @x3

In the above equation, to prevent singularity in the controller design, we do not let e3 5 e_2 . Design the sliding mode function as s 5 c1 e1 1 c2 e2 1 c3 e3 1 e4 ;

ð9:20Þ

where ci . 0, i 5 1; 2; 3.  @f1 5 0, we have From dtd @x 1 s_ 5 c1 e_1 1 c2 e_2 1 c3 e_3 1 e_4 5 c1 x2 1 c2 ðf1 2 11εx3 Þ 1 c3 e4 1

where dtd



@f1 @x1 x2

1

@f1 @x3 x4

5

@f1 @x1

  ; d @f1 @f1 x2 1 x4 @x3 dt @x1

ð f1 2 11εx3 Þ 1

d dt

 @f1 @x3

x4 1

@f1 @x3

ð9:21Þ

u.

Then s_ 5 c1 x2 1 c2 ðf1 2 11εx3 Þ 1 c3 e4 1

  @f1 d @f1 @f1 x4 1 ðf1 2 11εx3 Þ 1 u dt @x3 @x1 @x3

Let M 5 c1 x2 1 c2 ðf1 2 11εx3 Þ 1 c3 e4 1

@f1 @x1

ð f1 2 11εx3 Þ 1

d dt

 @f1 @x3

x4 , and

design the sliding mode controller as

u5

where η . 0 and k . 0.

@f1 @x3

21

ð2M 2 ηsgns 2 ksÞ;

ð9:22Þ

319

320

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

Substituting Eq. (9.22) into s_, we have s_ 5 2ηsgnðsÞ 2 ks. Design the Lyapunov function V 5 12 s2 , then V_ 5 s_s 52ηjsj 2 ks2 # 0:

9.3.4 Convergence analysis From Eq. (9.19), we have e_1 5 e2 , e_2 5 e3 1 11εx3 , e_3 5 e4 . From s_s # 0, under controller (9.22), the system can reach and thereafter stay on the manifold s 5 0 in finite time. On the manifold s 5 0, we have e4 5 2c1 e1 2 c2 e2 2 c3 e3 . 2

Define

0 A54 0 2c1

1 0 2c2

3 0 1 5 2c3

and design ci to guarantee that A is

Hurwitz; we then get the error state equation as e_1 5 e2 e_2 5 e3 2 11εx3 : e_3 5 2c1 e1 2 c2 e2 2 c3 e3

ð9:23Þ

 Defining E5 e1 e2 e3 T , d2 5 211εx3 , from e3 5 f1 ðx1 ; x3 Þ 5 2x1 1 εsin x3 1 11εx3 , then d2 5 211εx3 5 2 e3 2 x1 1 εsin x3 . Considering sin x3 , x3 , we then have jd2 j 5 11εjx3 j 5 j2e3 2x1 1 ε sin x3 j # je3 j 1 je1 j 1 εjx3 j:

Then 10εjx3 j # je3 j 1 je1 j, and jd2 j 5 11εjx3 j 5 1:1 3 10εjx3 j # 1:1ðje3 j 1 je1 jÞ # 2:2jjEjj2 :



Let D 5 0 we have

d2

0 T ; we have jjDjj2 # γjjEjj2 , γ 5 2:2. From Eq. (9.23), _ 5 AE 1 D: E

ð9:24Þ

 To guarantee that E 5 e1 e2 e3 T -0, A must be Hurwitz, i.e., the real part of the characteristic value of A must be negative. From

  2λ  jA 2 λIj 5  0  2c1

1 2λ 2c2

    5 λ2 ð2 c3 2 λÞ 2 c1 2 c2 λ 5 2 λ3 2  2c3 2λ  0 1

c3 λ2 2 c2 λ 2 c1 5 0, i.e., λ3 1 c3 λ2 1 c2 λ 1 c1 5 0. From ðλ1aÞ3 5 0, we have λ3 1 3aλ2 1 3a2 λ 1 a3 5 0.

9.3 Sliding Mode Control for a TORA System

If we choose c1 5 a3 , c2 5 3a2 , c3 5 3a, and let a . 0, then A will be Hurwitz. Defining Q 5 QT . 0, there exists a Lyapunov equation AT P 1 PA 5 2Q, P 5 PT . 0. Design the Lyapunov function as V1 5 ET PE, then we have _ T PE1ET PE5 _ ðAE1DÞT PE1 ET PðAE1DÞ V_ 1 5 E 5 ET AT PE1DT PE1ET PAE 1ET PD5 ET ðAT P1PAÞE1DT PE1ET PD 52ET QE1 DT PE1 ET PD# 2λmin ðQÞjjEjj22 12λmax ðPÞγjjEjj22

;

5 ð2λmin ðQÞ12λmax ðPÞγÞjjEjj22

where DT PE 1 ET PD # 2λmax ðPÞγjjEjj22 , λmin ðQÞ is the minimum eigenvalue of positive definite matrix Q and λmax ðPÞ is the maximum eigenvalue of positive definite matrix P. λmin ðQÞ Let 2λ . γ, then we have V_ 1 , 0. max ðPÞ

If we let Q 5 I3 , we have λmin ðQÞ 5 1, λmax ðPÞ 5 λmin ðQÞ 2λmax ðPÞ

1 2λleft ð2 AÞ,

then

. γ becomes λleft ð2AÞ . γ, which can be guaranteed by A

design.

 Since A is Hurwitz, then E 5 e1 e2 e3 T -0 will be satisfied, i.e., e1 -0, e2 -0 and e3 -0; moreover, from s-0, we have e4 -0. From e1 -0 and e2 -0, we can get x1 -0, x2 -0, from e3 5 f1 ð0; 0; x3 Þ-0, Assumption 3 and Eq. (9.19), we can get x3 -0, x4 -0.

9.3.5 Simulation example For a TORA system as z_1 5 z2 2z1 1 εθ22 sin θ1 ε cos θ1 z_2 5 2 v 1 2 ε2 cos2 θ1 1 2 ε2 cos2 θ1 ; θ_ 1 5 θ2 ε cos θ1 ðz1 2 εθ22 sin θ1 Þ 1 2 v θ_ 2 5 1 2 ε2 cos2 θ1 1 2 ε2 cos2 θ1

 the initial states are set as 1 0 π 0 . To satisfy λleft ð2AÞ . γ, choose a 5 3:0, then we have c1 5 a3 and c2 5 3a2 , c3 5 3a. Using control law (9.16) and Eq. (9.22), set k 5 5.0, η 5 0.50, use the saturation function instead of the switch function and let Δ 5 0.10. The simulation results are shown in Figs. 9.49.6.

321

322

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

1

z1

0.5 0 –0.5 –1

0

10

20

30

40

50 60 Time (s)

70

80

90

100

0

10

20

30

40

50 60 Time (s)

70

80

90

100

1

dz1

0.5 0 –0.5 –1

■ FIGURE 9.4 Response of z1 and _z 1 .

4

th1

2 0 –2 –4

0

10

20

30

40

50 60 Time (s)

70

80

90

100

0

10

20

30

40

50 60 Time (s)

70

80

90

100

5

dth1

0 –5 –10 –15

■ FIGURE 9.5 Response of θ1 and θ_ 1 .

9.3 Sliding Mode Control for a TORA System

50

0

v

–50

–100

–150

–200

–250

0

10

20

30

■ FIGURE 9.6 Control input. Matlab programs:

1. Simulink main program: chap9_2sim.mdl

40

50 Time (s)

60

70

80

90

100

323

324

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

2. S function for controller; chap9_2ctrl.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 3, sys 5 mdlOutputs(t,x,u); case {2,4,9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 0; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 1; sizes.NumInputs 5 4; sizes.DirFeedthrough 5 1; sizes.NumSampleTimes 5 1; sys 5 simsizes(sizes); x0 5 []; str 5 []; ts 5 [0 0]; function sys 5 mdlOutputs(t,x,u) epc 5 0.1; z1 5 u(1); z2 5 u(2); theta1 5 u(3); theta2 5 u(4); x1 5 z1 1 epc*sin(theta1); x2 5 z2 1 epc*theta2*cos(theta1); x3 5 theta1; x4 5 theta2; f1 5 2 x1 1 epc*sin(x3) 1 11*epc*x3; f1_x1 5 2 1; f1_x3 5 epc*(cos(x3) 1 11); dt_f1_x1 5 0; dt_f1_x3 5 2 epc*sin(x3)*x4;

9.3 Sliding Mode Control for a TORA System

e1 5 x1; e2 5 x2; e3 5 f1; e4 5 f1_x1*x2 1 f1_x3*x4; a 5 3.0; c1 5 a^3;c2 5 3*a^2;c3 5 3*a; s 5 c1*e1 1 c2*e2 1 c3*e3 1 e4; M 5 c1*x2 1 c2*(f1 2 11*epc*x3) 1 c3*e4 1 f1_x1* (f1 2 11*epc*x3) 1 dt_f1_x3*x4; k 5 5;xite 5 0.5; fai 5 0.10; if abs(s), 5 fai sat 5 s/fai; else sat 5 sign(s); end ut 5 1/f1_x3*(2 M 2 k*s 2 xite*sat); v 5 (1 2 epc^2*(cos(theta1))^2)*ut 2 epc*cos(theta1)* (z1 2 epc*theta2^2*sin(theta1)); sys(1) 5 v;

3. S function for the plant: chap9_2plant.m function [sys,x0,str,ts] 5 s_function(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts] 5 mdlInitializeSizes; case 1, sys 5 mdlDerivatives(t,x,u); case 3, sys 5 mdlOutputs(t,x,u); case {2, 4, 9} sys 5 []; otherwise error(['Unhandled flag 5 ',num2str(flag)]); end function [sys,x0,str,ts] 5 mdlInitializeSizes sizes 5 simsizes; sizes.NumContStates 5 4; sizes.NumDiscStates 5 0; sizes.NumOutputs 5 4;

325

326

CHAPTER 9 Sliding mode control for underactuated system with decoupling algorithm

sizes.NumInputs 5 1; sizes.DirFeedthrough 5 0; sizes.NumSampleTimes 5 0; sys 5 simsizes(sizes); x0 5 [1;0;pi;0]; str 5 []; ts 5 []; function sys 5 mdlDerivatives(t,x,u) z1 5 x(1); theta1 5 x(3); theta2 5 x(4); epc 5 0.1; v 5 u(1); den 5 1 2 epc^2*(cos(theta1))^2; dz2 5 ( 2 z1 1 epc*theta2^2*sin(theta1) 2 epc*cos(theta1)*v)/den; dth2 5 (epc*cos(theta1)*(z1 2 epc*theta2^2* sin(theta1)) 1 v)/den; sys(1) 5 x(2); sys(2) 5 dz2; sys(3) 5 x(4); sys(4) 5 dth2; function sys 5 mdlOutputs(t,x,u) sys(1) 5 x(1); sys(2) 5 x(2); sys(3) 5 x(3); sys(4) 5 x(4);

4. Plot program: chap9_2plot.m close all; figure(1); subplot(211); plot(t,x(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('z1'); subplot(212); plot(t,x(:,2),'r','linewidth',2); xlabel('time(s)');ylabel('dz1'); figure(2); subplot(211); plot(t,x(:,3),'r','linewidth',2);

References 327

xlabel('time(s)');ylabel('th1'); subplot(212); plot(t,x(:,4),'r','linewidth',2); xlabel('time(s)');ylabel('dth1'); figure(3); plot(t,ut(:,1),'r','linewidth',2); xlabel('time(s)');ylabel('v');

REFERENCES [1] R.O. Saber, Global configuration stabilization for the VTOL aircraft with strong input coupling, IEEE Trans. Autom. Control. 47 (11) (2002) 19491959. [2] R.O. Saber, Normal forms for underactuated mechanical systems with symmetry, IEEE Trans. Autom. Control. 47 (2) (2002) 305308. [3] X. Rong, U. Ozguner, Sliding mode control of a class of underactuated systems, Automatica 44 (2008) 233248.