**6.2 Modeling and simulation of A two-link (2-DOF) planar robot manipulator**

A manipulator consists of an open kinematic chain of rigid links. Power is supplied to each degree of freedom of the manipulator by independent torques. The *An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

**Figure 12.** *Tracking error under SMC of the position control system.*

**Figure 13.** *Torque vs. speed curve under SMC of the position control system.*

dynamical equations of motion of an *n*-link (i.e., *n*-degree-of-freedom) robot manipulator using the Lagrangian formulation has already been described in Section 3 by the Eq. (8). The robot model there is characterized by the following structural properties which are important for our sliding mode controller design of the tracking problem [27]:

**Property 1.** *A vector α*∈*R<sup>m</sup> with components that depend on manipulator parameters (masses, moments of inertia, etc.) exists, such that*

$$\mathbf{M}(\boldsymbol{q})\dot{\boldsymbol{\nu}} + \mathbf{C}(\boldsymbol{q},\dot{\boldsymbol{q}})\boldsymbol{\nu} + \mathbf{G}(\boldsymbol{q}) = \boldsymbol{\Phi}(\boldsymbol{q},\dot{\boldsymbol{q}},\boldsymbol{\nu},\dot{\boldsymbol{\nu}})\boldsymbol{a},\tag{85}$$

*where Φ* ∈*Rnxm is called the regressor, v*∈*R<sup>n</sup> is a vector of smooth functions. This property implies that the dynamic equation can be linearized according to a specially selected manipulator parameter set, hence constituting the basis for the linear parameterization approach.*

**Figure 14.** *Sliding mode surface under SMC of the position control system.*

**Figure 15.** *Control input under SMC of the position control system.*

**Property 2.** *Both M q and C q*, *q*\_ *in Eq. (8), using a properly defined matrix C q*, *q*\_ *, satisfy*

$$\mathbf{x}^T(\dot{\mathbf{M}} - \mathbf{2C})\mathbf{x} = \mathbf{0}, \ \forall \mathbf{x} \in \mathbf{R}^n \tag{86}$$

*with <sup>x</sup><sup>T</sup> the transposition of <sup>x</sup>: That is, <sup>M</sup>*\_ � <sup>2</sup>*<sup>C</sup> is a skew-symmetric matrix. Property 2 simply states that the so-called fictitious forces, defined by C q*, *q*\_ *q*\_*, do not work on the system.*

*An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

**Figure 16.** *Phase trajectory under SMC of the position control system.*

**Figure 17.** *Position tracking under PD control of the position control system.*

The model given in **Figure 23** is known as a two-Link (2-DOF) planar robot, as it corresponds to the two-dimensional special case, where *n* ¼ 2 is taken in the *n*-link robot manipulator [27].

The dynamic model chosen for the simulations is given by

$$\mathbf{M}(\boldsymbol{\theta})\ddot{\boldsymbol{\theta}}\_r + \mathbf{F}(\boldsymbol{\theta}, \dot{\boldsymbol{\theta}}\_r)\dot{\boldsymbol{\theta}}\_r + \mathbf{G}(\boldsymbol{\theta}) = \boldsymbol{\pi},$$

and the dynamic equation is given by

$$
\begin{bmatrix} M\_{11} & M\_{12} \\ M\_{12} & M\_{22} \end{bmatrix} \begin{bmatrix} \ddot{\theta}\_{1} \\ \ddot{\theta}\_{2} \end{bmatrix} + \begin{bmatrix} -F\_{12}\dot{\theta}\_{2} & -F\_{12}(\dot{\theta}\_{1} + \dot{\theta}\_{2}) \\ F\_{12}\dot{\theta}\_{1} & 0 \end{bmatrix} \begin{bmatrix} \dot{\theta}\_{1} \\ \dot{\theta}\_{2} \end{bmatrix} + \begin{bmatrix} G\_{1}\mathbf{g} \\ G\_{2}\mathbf{g} \end{bmatrix} = \begin{bmatrix} u\_{1} \\ u\_{2} \end{bmatrix},
$$

where

$$M\_{11} = (m\_1 + m\_2)r\_1^2 + m\_2r\_2^2 + 2m\_2r\_1r\_2 \cos\left(\theta\_2\right)$$

$$M\_{12} = m\_2r\_2^2 + m\_2r\_1r\_2 \cos\left(\theta\_2\right)$$

$$M\_{22} = m\_2r\_2^2$$

**Figure 18.** *Speed tracking under PD control of the position control system.*

**Figure 19.** *Tracking error under PD control of the position control system.*

*An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

**Figure 20.** *Torque vs. speed curve under PD control of the position control system.*

**Figure 21.** *Control input under PD control of the position control system.*

$$F\_{12} = m\_2 r\_1 r\_2 \sin\left(\theta\_2\right)$$

$$G\_1 = (m\_1 + m\_2)r\_1 \cos\left(\theta\_2\right) + m\_2 r\_2 \cos\left(\theta\_1 + \theta\_2\right)$$

$$G\_2 = m\_2 r\_2 \cos\left(\theta\_1 + \theta\_2\right)$$

#### *6.2.1 No boundary layer*

• The desired joint trajectory for each joint (*i*) is given by [27, 28] as:

**Figure 22.** *Phase trajectory under PD control of the position control system.*

**Figure 23.** *A two-link robot manipulator model.*

$$\theta\_d(t) = -\mathbf{90}^\circ + \mathbf{52.5}(1 - \cos\left(1.26t\right))$$

• Initial conditions:

$$\theta\_1(\mathbf{0}) = -4\mathbf{S}^\circ \text{ and } \theta\_2(\mathbf{0}) = -\mathbf{30}^\circ.$$

• The parameter values used are selected as in [27, 28]:

$$m\_1 = 0.5 \text{ kg}, m\_2 = 0.5 \text{ kg}$$

$$r\_1 = 1.0 \text{ m}, r\_2 = 0.8 \text{ m}$$

• Matlab-Simulink implementation options used in the simulations (**Figures 24**–**31**) as in [28]:

*An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

**Figure 24.** *Tracking error of Joint 1 displacement under SMC of the robot manipulator.*

**Figure 25.** *Tracking error of Joint 2 displacement under SMC of the robot manipulator.*

Sampling time *Ts* ¼ 1 kHz, fixed � step, ode5


#### *6.2.2 Introducing boundary layer*

The same parameters and initial conditions for the simulations have been chosen as in Section 6.2.1 except for the following ones which include the boundary layer thickness in particular:


Please note that due to the space constraint, we will be able to give only the figures whose effect is clearly observed, not eight figures as given in Section 6.2.1 (**Figures 32**–**34**).

For tracking a desired trajectory by two-link rigid planar robotic manipulator, PID control strategy will not work well under unknown disturbances and payload changes, and hence will not be represented here. In addition, the values of control input will get

**Figure 26.** *Tracking error of Joint 1 velocity under SMC of the robot manipulator.*

**Figure 27.** *Tracking error of Joint 2 velocity under SMC of the robot manipulator.*

*An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

**Figure 28.** *Torque at Joint 1 under SMC of the robot manipulator.*

**Figure 29.**

*Torque at Joint 2 under SMC of the robot manipulator.*

higher as in the case of DC motor position control and that would complicate the realization of such high gains through the proper actuators. On the other hand, SMC provides robustness against parameter uncertainties and unmodeled disturbances so long as the observed undesirable chattering effect is overcome through some modifications by simply replacing nonlinear signum function with nonlinear saturation function and introducing boundary layer thickness in there as explained in earlier sections. In order to realize this, the boundary layer has been introduced for the first time in Section 6.2.2 simulations, and consequently, no switching or chattering effect has been observed as can be verified by the phase portrait in **Figure 34**.

**Figure 30.** *Phase portrait of Joint 1 under SMC of the robot manipulator.*

**Figure 31.** *Phase portrait of Joint 2 under SMC of the robot manipulator.*

Later, the robustness of the SMC will be analyzed by adding an extra mass of 0*:*5 kg to Joint 2, and we have not observed any performance degradation of the trajectory to be maintained in the sliding surface. Therefore, the controller is said to be robust enough. However, it is expected that switching will reappear to maintain the trajectory in the sliding surface.

As a rule of thumb, It is possible to do tracking with more load by reducing the boundary layer to allow more switching to occur. Now, we reduce the boundary layer thickness from 0.02 to 0.005 and add the extra mass to Joint 2 by 0.75 kg to a final of 1.25 kg and we can still observe that SMC will be able to do the tracking by

*An In-Depth Analysis of Sliding Mode Control and Its Application to Robotics DOI: http://dx.doi.org/10.5772/intechopen.93027*

**Figure 32.** *Torque at of Joint 1 under SMC with a boundary layer.*

**Figure 33.** *Torque at of Joint 2 under SMC with a boundary layer.*

observing the reemerged chattering effect as can be seen in the following simulations (**Figure 35**):


**Figure 34.** *Phase portrait of Joint 1 under SMC with a boundary layer.*

**Figure 35.** *Phase portrait of Joint 1 under SMC with a robustness test including more load.*
