Optimal Tuning of the SMC Parameters for a Two-Link Manipulator Co-Simulation Control

1 Abstract —This paper presents the trajectory tracking control of a two-link planar robot manipulator using MSC Adams and MATLAB co-simulation which enables the innovative virtual prototyping of the systems without any mathematical expressions. Firstly, the tracking control performance of the planar manipulator is investigated using the Sliding Mode Control (SMC) controller and the Proportional Integral Derivative (PID) controller in terms of the performance analysis. As a result, the SMC demonstrates effective control performances compared to the PID controller according to the required trajectory, settling time, and end position of the system. Then, the SMC controller parameters are determined using the different optimization methods offered as open source by MATLAB/Response Optimization Toolbox and compared to each other. In the virtual co-simulation, the trajectory tracking control performance is observed to be improved by optimizing the parameters of the SMC controller using Simplex Search (SS) method. All control results are examined and presented with graphics and international error standards.


I. INTRODUCTION
The planar manipulators have easy installation, easy usage, high mobility, and broad working areas; hence, they are more advantageous than other manipulator structures [1]. In the literature, two or three degrees of freedom (DOF) manipulator systems are commonly used for different applications [2], [3]. Studies on systems with 4 or more DOFs have also been reported in [4] for more complex and more important applications. However, their use is minimal because of the complex dynamic structures and kinematic calculations. In addition, there have been studies about the control of different robot manipulator systems. Generally, herein, important issues, such as trajectory planning of robot manipulators [5], analysis of robot kinematics [6], implementation of different controller structures, and comparison of the controller performances [7], are emphasized.
On the other hand, the simulation implementations have a critical role for robotics applications, especially in modelling physical systems. It aids in understanding reality and all complexities of systems. Various simulation software platforms are already in use for robotic systems widely. Thanks to these software platforms, researchers can evaluate the research results and develop models to save money and time and to decrease errors. In the literature, it is seen that different simulation programs, such as RoboAnalyzer [8], SolidWorks [9], MATLAB/Simulink [9], and CATIA [10], are used for robotic systems. In this study, unlike the abovementioned ones, MSC Adams, which is software used to build and simulate multi-body dynamics of platforms, will be used to model the robot manipulator. In addition, our former studies [11]- [15], which provided a background for the development of this paper, present an improvement of a multi-body simulation model using MSC Adams software.
The two-link manipulators play an essential role in sensitive works, such as pick and place and material handling, among others. Therefore, the desired position control of the two-link manipulators has become a critical duty. Researchers have investigated and discussed the trajectory tracking control problem for years now. To cope with this problem, researchers have focused on studies about controller design, such as proportional integral derivative (PID), fuzzy logic control, sliding mode control (SMC), time-delay control, etc. [16], [17]. Furthermore, it is seen that different controller structures are used in a hybrid way to increase the controller performance in [18]- [23].
The SMC used in this study was started to introduce in the 1950s. First study is reported by Emelyanov in the 1960s. In 1977, Utkin [24] made a study regarding this, and his books and articles are presented all over the world. Then, this control methodology was applied for the linear and nonlinear control system. The SMC is a robust control technique due to its ability to handle uncertainties, parametric changes, and external disturbances in the control system [25], [26]. Furthermore, the SMC has some advantages, such as stability, quick response, and good Optimal Tuning of the SMC Parameters for a Two-Link Manipulator Co-Simulation Control transient performance [27].
In the literature review, it is seen that the modelling of the robotic arms and the manipulators is generally investigated with the mathematical expressions or equations of motion. There is a lack of the studies about virtual prototyping. Thus, the MSC Adams simulation software is used to simulate the manipulator in the scope of this study. The physical and dynamical properties of the proposed manipulator are selected according to demonstrate the controller performances. A numerical Adams model is created and exported to MATLAB software to compare the model validation according to the inverse kinematics and perform controller design works. The most important feature of this virtual model is that it completely transfers the dynamics behaviours of the manipulator to MATLAB environment. Thus, the changes in the structure or linear/non-linear additions are updated on the model rapidly. This provides great convenience in terms of engineering solutions rather than updating mathematical equations. The equations of the kinematics of the manipulator, especially inverse kinematics, are manually calculated. These equations are embedded in MATLAB/Simulink to validate the virtual model.
Firstly, the virtual numerical model is separately controlled using the SMC and the PID controllers. For the SMC, the second-order transfer functions are obtained using the system inputs and outputs through the MATLAB/System Identification Toolbox. Also, the controller coefficients of the SMC method are obtained using the MATLAB/Response Optimization Toolbox. The SMC and the PID controller performances are both graphically and numerically investigated according to the required trajectory, settling time, and end position of the system. Then, the five-position trajectory tracking control implementation is realized to investigate the different optimization methods offered as open source by MATLAB/Response Optimization Toolbox effect on the SMC controller and compared under the same conditions. These methods are, namely "Gradient Descent (GD)", "Pattern Search (PS)", and "Simplex Search (SS)" offered by MATLAB/Response Optimization Toolbox. According to the comparison, the tracking control performance is increased by optimizing the parameters of the SMC controller using Simplex Search (SS) method. Moreover, some studies on the optimization of the controller parameters in the literature are also examined [28]- [34].
This paper is organized as follows. The introduction is given in Section I. In Section II, the system modelling is reported. In Section III, Implementation of the SMC and the PID, optimal tuning for SMC controller parameters is presented. Co-simulation control results are given in Section IV. Finally, conclusions are reported in Section V.

II. MODELLING OF A TWO-LINK PLANAR ROBOT MANIPULATOR
The MSC Adams, which is a software used to build and simulate the multi-body dynamics of platforms, is used herein to obtain the dynamic model of the manipulator. The manipulator parameters from our previous work [14] are used in MSC Adams. Figure 1 shows the system model for the manipulator. The manipulator can move in the x-y plane. In other words, the Adams model has two inputs (i.e., torques of actuators) and four outputs (i.e., angle of the 1 st joint, angle of the 2 nd joint, and x-y components of the end effector position). After the MSC Adams process, the designed manipulator is exported to MATLAB/Simulink to carry out the controller implementations. For the manipulator control, the angles of the joints (θ 1 and θ 2 ) are separately controlled with appropriate torque inputs (T 1 and T 2 ). A second-order transfer function (e.g., a mass-damper-spring system), which expresses the relationship between the related inputs and outputs (θ 1 -T 1 and T 2 -θ 2 ) separately, is required to implement the proposed SMC controller.
The transfer functions (second order) are determined using the MATLAB/System Identification Toolbox. As a result of this operation, the transfer functions of the system are obtained as (1) and (2)

A. PID Control Method
The PID is a commonly used control method because of its comfortable design. It is composed of three parameters, These parameters should be regulated to obtain the desired system performance.
The controller response of the system is slow if these parameters are not accurately adjusted. Moreover, the settling time and the overshoot are increased. The suitable PID parameters (K p , K i , and K d ) are obtained herein by using a trial-and-error method to compare the SMC. For θ 1 , K p , K i , and K d are determined as -8, -2, and -3, respectively. Likewise, they are -20, -3, and -5 for θ 2 .

B. SMC Control Method
For the 1 st joint, (4) and (5) are obtained if the inverse Laplace transform is applied, and some simplifications are made in (1) to return to the time domain: Moreover, the sliding surface can be determined in (6)  The derivative of the sliding surface is shown in (7)           The first and second derivatives of θ 1d (t) are zero if θ 1d (t) is assumed constant. Therefore, (7) is rewritten as (8) The T 1 (t) control signal will be produced in (10) if (5) is substituted in (8) and the coefficients, which are seen in (1), are also substituted in (9):

T t t t K sign s
The T 2 (t) control signal will be produced as in (11) 10 .

C. Optimal Tuning SMC Controller
In addition, to make it a more difficult condition in SMC control, the coordinates of the five determined locations for the robot manipulator to reach are given in Table I. The parameters of the sliding-mode controller (K 1 , K 2 , λ 1 , and λ 2 ), which are designed to enable the robot manipulator to reach these determined positions, have been optimized with various optimization methods. Three different optimization algorithms, namely "Gradient Descent (GD)", "Pattern Search (PS)", and "Simplex Search (SS)" are used to tracking trajectory of the presented five locations.
The parameters of the sliding-mode controller (K 1 , K 2 , λ 1 , and λ 2 ) are initially determined by trial and error, without any optimization, so that the system gives a stable output response. Then, to improve this output performance, the specified parameters are tried to be developed with the optimization methods detailed above. Accordingly, the optimized values of the parameters are given in Table II. In the following section, the results obtained for the twoposition control and the five-position control are discussed through graphics and numerical results. Then, the assessment of the paper is given in the Conclusions section. Figure 2 shows the block diagram, including system modelling and controller design. The SMC and the PID control of the two-link planar robot manipulator is carried out. Performance analysis will be shown in order.  Figure 3 shows the comparison graph between the PID and the SMC concerning the trajectory tracking. Firstly, the manipulator is placed vertically at the origin point. Hence, the position of the endpoint of the manipulator is (0,350 mm) because of the summation of the lengths of the manipulator. This position is named herein as the "Starting Point". In the system, two desired locations (i.e., 200,50 mm and 50,200 mm) are determined for the manipulator to reach in a controlled manner. These locations are called "First Location" and "Second Location", respectively. Figure 3 shows that the SMC reached the determined locations via a shorter route compared to the PID. Although no sharp turns in the SMC route existed, some sharp turns can be seen in the PID route. These types of turns are not desired in the motion of robot manipulators; hence, this is a negative result for the PID controller.  Figure 4 exhibits the comparison graphic of the SMC and the PID for the angle of the 1 st joint. The manipulator route consisted of two parts. The first part starting from the Starting Point to the Location 1 is performed during the first 5 s. The second part starting from locations 1 to 2 is then performed from the 5 th to 10 th second. According to this graphic, the SMC had a better performance concerning less overshoot and fast return to the reference. Notably, the SMC is more effective for fast return to the reference when the reference immediately changed after the 5 th second. In the second part of the movement, a difference of approximately 1 s is clearly found in the settling times of the proposed controllers.  Figure 5 shows the comparison of the SMC and the PID for the angle of the 2 nd joint. At the beginning of the first part of the movement, the PID has a good performance because of the settling time despite its overshoot. However, at the beginning of the second part of the movement, the SMC correctly reacted to the change of the angle of the 2 nd joint. Although a little overshoot is observed in the PID response between the 5 th and 6 th seconds, no change is observed in the SMC response. This result proved that the SMC is sensitive against the systemic changes.  Figure 6 depicts a comparison graphic of the SMC and the PID for the x-component of the end position of the manipulator. The SMC directly inclined towards the reference route at the beginning of the first part of the movement. However, the PID attempted to reach the reference route by making some deviations in the (-) and (+) directions. In the second part of the movement, the SMC has a good response (no overshoot) against the instantaneous change in the reference route. The PID reacted to this change late. Therefore, regarding the settling times, a difference of approximately 2 s for the proposed controllers is obtained. In other words, the SMC is better than the PID, especially in the second part of the movement.  In the first part, while the PID is making some deviations and overshoot, the SMC again directly moved towards the reference without any overshoot. In the second part, the SMC again had a good response concerning less overshoot and fast come again to the reference. This can be seen between the 5 th and 6 th seconds. The PID had a little overshoot, but it is acceptable.   Figure 9 illustrate the errors and the derivative of the errors for the SMC for both joint angles, respectively.

IV. RESULTS AND DISCUSSION
The SMC successfully forced the errors to the origin for both parts of the movements. These conditions for both joint angles, which are seen in different colours, indicated that the error in max value converged to zero and made a loop again under change of the reference route.
The system performance is achieved by means of performance index. In this study, performance index is defined as a criterion to show the system performance of the designed controllers. Using this technique, the optimal controller structures can be designed and the controller parameters in the system can be adjusted to perform the required specification. For the system, there are often three error standards, such as integral squared error (ISE), integral absolute error (IAE), and integral of time-weighted absolute error (IATE), to show the system performance. The error calculations are made according to these standards in Table  III. The better result of the SMC is also expressed in the numerical results. The results in the table show that the SMC is also numerically successful in most of the system's output responses compared to the PID. The SMC provided 36 %, 35 %, and 15 % improvement regarding ITAE, IAE, and ISE standards compared to the PID when the results for the x-component of the end effector position are examined. For the same error standards, the SMC looked better than the PID when the percentage of development of θ 1 and θ 2 is examined from Table III. Unlike the other results, the PID is superior to the SMC when the results for the y-component of the end effector position are examined because of a little steady-state error in the SMC. However, the examination of Fig. 7 showed that the PID is more oscillating than the SMC until the system came to a steady state. This type of oscillation or sudden changes in movement are undesirable in robotic systems. Therefore, a little steady-state error in the SMC seems acceptable for this system.   To investigate the optimization methods' effect on the SMC parameters, the five-position trajectory tracking control implementation is realized and compared under the same conditions. Thus, the graph comparing the optimization methods of the five-position trajectory tracking of two-link robot manipulators is given in Fig. 10. As with the two-position control, the robot manipulator is placed perpendicular to the origin here too. In the system, five points, as shown in Table IV, are determined for the robot manipulator to reach in a controlled manner.    The error calculations based on the international standards (ITAE, ISE, and IAE) are shown in Table IV. As can be seen from the table, it is seen that the Simplex Search (SS) method is more successful in all error criteria in most of the output responses of the system. Unlike the other results, when the second joint angle of the robot manipulator is examined, it is seen that the result obtained without any optimization process in just ITAE criterion is superior. Unlike the other results, when the second joint angle of the robot manipulator is examined, it is seen that the result obtained without any optimization process in just ITAE criterion is superior.

V. CONCLUSIONS
There is a lack of knowledge in simulating and controlling two-link planar robot manipulator systems with Adams and MATLAB co-simulation. Thus, in this study, the simulation modelling of the manipulator is performed in MSC Adams, which does not need the mathematical equations to investigate the controller performances. The SMC and the PID control methods for the trajectory tracking control of a two-link planar robot manipulator are proposed. The joint angles of the two-link planar robot manipulator are controlled to track the positions of the end effector. The controller design procedures are explained with related equations and theories. As a result of the control study, the SMC provided successful results regarding the settling time and a rapid response to the change in the reference route. In addition, the controller efficiency is shown with graphics and numerical results in terms of international error standards, such as ITAE, IAE, and ISE. For instance, the SMC provided 36 %, 35 %, and 15 % improvement regarding ITAE, IAE, and ISE standards compared to the PID in terms of the x-component of the end effector position. Also, the five-position trajectory tracking control implementation is realized in order to the SMC controller parameters are determined using the different optimization methods by MATLAB/Response Optimization Toolbox and compared to each other. According to the results, the Simplex Search (SS) method is more successful for the trajectory tracking control. Thus, this paper presents a fast and practical approach about the controller parameter optimization for the co-simulation studies.

ACKNOWLEDGMENT
This study constitutes a part of the Master thesis of Sinan İlgen. In addition, the authors would like to thank the Konya Technical University, Rac-Lab Research Laboratory (www.rac-lab.com), and the Faculty of Engineering, KTO Karatay University.

CONFLICTS OF INTEREST
The authors declare that they have no conflicts of interest.