Inverse Dynamics Based Optimal Fuzzy Controller for a Robot Manipulator via Particle Swarm Optimization

This paper endeavors to contribute to the field of optimal control via presenting an optimal fuzzy Proportional Derivative (PD) controller for a RPP (Revolute-Prismatic-Prismatic) robot manipulator based on particle swarm optimization and inverse dynamics. The Denavit-Hartenberg approach and the Jacobi method for each of the arms of the robot are employed in order to gain the kinematic equations of the manipulator. Furthermore, the Lagrange method is utilized to obtain the dynamic equations of motion. Hence, in order to control the dynamics of the robot manipulator, inverse dynamics and a fuzzy PD controller optimized via particle swarm optimization are used in this research study. The obtained results of the optimal fuzzy PD controller based on the inverse dynamics are compared to the outcomes of the PD controller, and it is illustrated that the optimal fuzzy PD controller shows better controlling performance in comparison with other controllers.


Introduction
In the recent years, the robotic arms have been used in the industrial applications, to name but a few, assembly lines [1], painting operation via spray [2,3], and welding [4] for the wide use of 24/7.Indeed, many robots and mechanical arms have been inspired from humans' arms and characteristics.The structure of this kind of robots involves rigid bodies which are connected through sets of different joints.As a matter of fact, the RPP robot is a kind of the robots being called series robots.While series robots benefit from appropriate characteristics such as large workspace [5], the end effector is attached to the base, which is opposite to the characteristics of the parallel robots [6].As mentioned, while this gives a vast workspace, it causes that the load is not distributed on all the kinematic chains and the stiffness of the robot is also diminished.
One of the most crucial problems raised in the study of the direct kinematics of the robot is how the robot's framework is changed when moving [7][8][9].The Denavit-Hartenberg approach was utilized to obtain the kinematic equations of the robot.Moreover, the inverse kinematics were employed to determine the amount of changes in the joints' variables with regard to the position and the orientation of the end effector [10][11][12][13][14].The approach used to gain the dynamics of the robot is the Lagrange method [15][16][17][18].As these robots have been introduced as a controllable system, various approaches including classic, intelligent, and combinatory control methods were proposed and examined.The examples of the classic control methods are Proportional Derivative (PD) and sliding mode control [19][20][21][22][23].Moreover, the instances of the intelligent control approaches involve fuzzy control and neural control methods [24,25].
In order to control the challenging dynamics of the robots, the nonlinearity in the dynamics must be turned into linearity via using techniques such as inverse dynamics.Afterwards, by choosing an appropriate controller, such as PD control, it is feasible to control the challenging dynamics with high precision [19,20,[26][27][28][29][30].A proper controller not only provides a superior performance in tracking the desired trajectory but also diminishes the negative effects of disturbances, the clearance of joints, and the elasticity of the links or joints.In order to augment the efficacy of the control approach, researchers used the benefits of the fuzzy controllers in association with other controllers.A number of research studies have been conducted on the design of the fuzzy logic controllers (FLC).For instance, the parameters of FLC were optimized via particle swarm optimization to control a robot following a trajectory [31][32][33]; the Lyapunov synthesis was employed to design FLC in order to address the adjustment of the output of an actuator with nonlinear backlash [34][35][36].
Particle swarm optimization (PSO) is a smart swarmbased technique introduced by Kennedy and Eberhart [37], where the algorithm based upon swarm intelligence uses random population and adaptive optimization inspired from the social behavior of the bird flocks and swarm fish.Indeed, PSO presents high quality solutions in a vast searching area and in a short time with a fast convergence compared to other random optimization techniques [38][39][40][41][42][42][43][44][45][46][47][48][49][50][51][52][53][54][55].As some recent notable applications of PSO on a wide range of controllers, the following research studies can be reviewed.Cheng et al. [56] designed the iterative learning control and iterative feedback tuning via formulating into one constrained optimization problem based upon particle swarm optimization and the stabilizing projection.The effectiveness of the method was provided via simulations on a four-room building control test-bed system.Vijay and Jena [42] proposed the control method for two-degrees-offreedom rigid robot manipulator based upon the coupling of artificial neurofuzzy inference system as well as sliding mode control.Particle swarm optimization was utilized to tune the parameters of the sliding surface via minimizing quadratic performance indices.Ye et al. [41] utilized an enhanced particle swarm optimization algorithm to search for the optimal proportional-integral-derivative controller gains of the nonlinear hydraulic system.Furthermore, selection and crossover operators were proposed for the standard PSO algorithm.By comparing enhanced PSO, standard PSO, and Phase Margin tuning approaches, it was shown that the enhanced PSO algorithm provides a superior performance in PID control for positioning of nonlinear hydraulic system.Vinodh Kumar et al. [57] introduced an adaptive particle swarm optimization approach to gain the elements of Q and R matrices in optimal linear quadratic regulator control.Moreover, to augment the convergence speed and precision of the PSO, an adaptive inertia weight coefficient was proposed in the velocity equation of PSO.Sadeghpour et al. [58] proposed PSO-based multivariable control, where two or more control parameters were tuned concurrently either in a single or in multiple control inputs in order to stabilize the 1-cycle fixed points of the Logistic map, the Hénon map, and the chaotic Duffing system.Sedghizadeh and Beheshti [59] employed PSO based fuzzy gain scheduling approach to optimally update the subspace predictive control gains directly with no need to apply persistently excitation signals.Marinaki et al. [49] used PSO with a combination of continuous and discrete variables for the optimal design of the fuzzy controller, which is an appropriate tool for the systematic development of active control methods and can be properly tuned if no experience exists.Soon et al. [60] found the control parameters of the sliding mode control and PID control using PSO and compared the results with the outcomes of the Ziegler-Nichols algorithm which showed the superiority of the PSO algorithm.Wang et el.[61] proposed a novel fuzzy neural network sliding mode control approach for an overhead crane using PSO.The simulation results proved the proper performance of the controller.Jeyalakshmi and Subburaj [62] proposed the particle swarm optimizationbased fuzzy logic controller design for the load frequency control in a two-area interconnected hydrothermal power system.In fact, effective control method was gained through using a combination of PSO and fuzzy logic technique.Al-Mamun and Zhu [63] introduced a fuzzy logic controller for steering control of a single wheel robot with the aid of fuzzy membership functions optimized using the PSO algorithm.Martinez et al. [64] utilized the PSO approach to gain the parameters of the membership functions of a type-2 fuzzy logic controller in order to minimize the state error for linear systems.Indeed, PSO was employed to gain the optimal Type-2 FLC to achieve regulation of the output and stability of the closed-loop system.Simulation results showed the feasibility of the proposed method.In the performance assessment on the designed PID sliding surface, the controller parameter is first obtained through conventional tuning method known as Ziegler-Nichols (ZN), which is then compared with the particle swarm optimization (PSO) computational tuning algorithm.
This paper introduced an inverse dynamics based optimal fuzzy Proportional Derivative (PD) controller for a RPP (Revolute-Prismatic-Prismatic) robot manipulator optimized via particle swarm optimization.The Denavit-Hartenberg and Lagrange approaches were utilized for deriving the kinematic and dynamic equations of the manipulator.In order to stabilize the links of the robot, the inverse dynamics approach and proportional-derivative controller were used in this research study.For the gain tuning of the designed controllers, the particle swarm optimization was successfully implemented.The obtained results of the optimal fuzzy PD controller based on the inverse dynamics were compared to the outcomes of the PD controller, and it was illustrated that the optimal fuzzy PD controller shows better controlling performance in comparison with other controllers.
The structure of the paper is as follows.The kinematics and dynamics of the RPP robot manipulator are presented in Section 2. Section 3 provides the control of the RPP robot manipulator.The optimization of the parameters using particle swarm optimization is discussed in Section 4. Section 5 presents results and discussion.Finally, Section 6 provides the conclusions and future work.

The Kinematics and Dynamics of the RPP Robot Manipulator
The RPP robot has three degrees of freedom, which involves one degree of the revolute joint and two degrees of prismatic joint (RPP), where the degree of freedom of the end effector is not considered.The most common method to address the direct kinematic problems is the Denavit-Hartenberg approach.In this method, each member is assigned a number from 0 to , where the link 0 is a fixed base (ground) and Table 1: The Denavit-Hartenberg parameters with regard to each joint.
the final link is the end effector.It is assumed for this kind of robots that there exist  − 1 links and  joints.For each joint, a separate coordinate system is defined with regard to the reference coordinate system (ground).The position of the  ℎ joint is shown with   .The position is considered in radian for the revolute joints and in meter for prismatic joints.Figure 1 illustrates how the coordinate system is placed on each joint.Moreover, the Denavit-Hartenberg parameters with regard to each joint are provided in Table 1.According to Figure 1, the coordinate system of  0  0  0 is considered as the reference system.
The homogenous transformation matrix is gained through the required transformations and using (1)-( 2), as illustrated in (3).
Due to avoiding the computational complexity and providing simplification for nonlinear dynamic equations, the Lagrange method is employed in this study.In the Lagrange approach, the scalar quantities of the kinematic energy and potential energy are calculated and expressed with respect to the general coordinates.Finally, by utilizing the Lagrange approach according to (4), the dynamic equations of the system are obtained through (5).

𝐿 (𝑞, q
) =  (, q ) +  () where  represents the Lagrange function,  denotes the kinematic energy, and  illustrates the potential energy.Moreover,  is the generalized vector of the coordinate of joints, q represents the generalized vector of the velocity of the joints, and  shows the generalized vector of the torques and forces.Therefore, the dynamic equations of a robot with  links where there is no flexibility in interacting with other objects are obtained according to  () q +  (, q ) q +  () = where q ∈ R n represents the position vector of joints, D(q) ∈ R n×n is the inertia matrix of the robot, C(q, q ) is the Coriolis force vector, G(q) ∈ R n dentoes the vector of the gravitational torque, and  ∈ R n illustrates the vector of torques applied to the manipulator's joints.By substituting each of the parameters into (6), the governing dynamic equations for each of the links are obtained as follows.

The Control of the RPP Robot Manipulator
The dynamics of the manipulator's arm is extremely nonlinear, and, hence, designing an efficient controller is a complicated task and of great importance.One of the appropriate approaches to enhance the tracking efficiency of the manipulator's arm is the control method of the computed torque.By using the computed torque control, the linear closed-loop equations are gained, and if the coefficients of the control approach are chosen properly, the stability of the controller would be guaranteed.The required control torque, which is  considered as the calculated force produced by an actuator, is computed according to  () q +  (, q ) q +  () =  (10) where () represents the inertia matrix of the robot and the motor.
The inverse dynamic control approach is a crucial method for the control of the mechanical arms.The inverse dynamic control rule is defined as follows.

𝑢 = 𝑀 (𝑞) 𝑎 𝑞 + 𝐶 (𝑞, q
) q +  () (11) where   is a function of  and its derivative.Furthermore,   is independent of the movement of other links and is only affected by the  of its own link.
The selected reference input is as follows: The tracking error is defined as () = −  which guarantees that the steady-state error equals zero.
In order to address this problem straightforwardly, the coefficients of  0 and  1 are considered as the proportional coefficient   and the derivative coefficient   , respectively.
The adjustment and determination of these design parameters are a key issue to design PD controllers.Hence, the fuzzy logic approach is applied to calculate the gains adaptively as follows.

K𝑃 = 𝐾
where û 1 and û 2 are the fuzzy variables.   and    are base variables and    and    are regulation variables.The base and regulation variables can be obtained by the try and error process.However, one of the best solutions to find these to have an optimal controller is the use of the optimization approaches such as particle swarm optimization algorithm.
The fuzzy system selected for û 1 and û 2 has the following characteristics: (I) The inference product engine (II) The fuzzifier and the trapezoidal membership function in the beginning and end of the range and a triangle in the middle of the range (III) The defuzzifier of the average of the centers Therefore, the input membership function is selected as Figure 2 and Table 2.
The fuzzy rules of the system are adjusted via setting up the above-mentioned parameters in the MATLAB and using Table 2.
Results and discussions are conducted through the outcomes of the fuzzy PD controller and substituting the outcomes into the inverse dynamic equations of (11).The summation of the control gains of the PD controller illustrated in Table 3 and the control gains of the fuzzy system are considered as the control gains of the fuzzy PD controller.Table 4 provides the information of the initial conditions of each of the variables and the desired values of each of the links.
In order to elaborate on the performance of the control approach, a smart optimization method is presented in the following section to optimize the control gains of the fuzzy PD controller.

The Optimization of the Parameters of the Proposed Controller
For the algorithm of the particle swarm optimization, each particle is evaluated among the whole population and if the termination condition is satisfied, the algorithm operation is stopped.However, if the termination condition is not satisfied, the position of each particle is evaluated with respect to its previous position and the position of the best particle among population.In fact, the position and velocity of the particle are being iteratively calculated until the termination condition of the algorithm is satisfied.Consider the general mathematical equations of the PSO as where  →   () and  → V  () describe the position and velocity of the particle  at certain iteration , respectively.Moreover,  1 and  2 are coefficients that express the tendency of the particle to the personal and social successes, respectively,  →  1 and  →  2 are random vectors in interval [0,1], and  illustrates Two stages can be regarded in order to analyze the performance of this optimization algorithm on the control method of the robot manipulator.In the first stage, the gains of the PD controller are optimized.In the second stage, the gains of the fuzzy PD controller are optimized.The initial assumptions of this problem are as follows.
(1) The number of particles in the initial population is NP=10; (2) The maximum number of iterations is MI=100; (3) The impact rate of a particle from its local position is  1 = 2; (4) The impact rate of a particle from the general position of all particles is  2 = 2; (5) The inertia weight is  = 1; By substituting the conditions assumed for each of the links and defining the objective function, the results and analyses will be provided in the next section.

The Results and Analyses
In the fuzzy control, the heuristic fuzzy parameters (   ,    ,    ,    ,  = 1, 2, 3) are required to be chosen properly.Therefore, the particle swarm optimization is used to determine the proper parameters and to eliminate the tedious and repetitive trial-and-error process.Furthermore, the performance of a controlled closed loop system is usually evaluated by variety of goals.In this paper, the integral of the summation of the absolute of the joint variables is considered as the objective functions which have to be minimized.This means that, by selecting various values for the selective parameters, we can make changes in the objective function.Figure 3 depicts the convergence diagram of the PSO algorithm over the iteration number for the best particle and mean value of all particles.Moreover, the obtained design variables and objective function via this optimization process are stated in Table 5.
By regarding and comparing the position, force, and velocity diagrams of each of the links, the obtained results illustrate the superiority of the fuzzy PD controller over the   the real model of the manipulator and its assumed model, it is probable that these controllers show error or instability.First, the position diagrams of each of these controllers are put under analysis.
By comparing the graphs of Figure 4, it can be concluded that the optimal fuzzy PD controller provides a better performance compared to the optimal PD controller by presenting a lower time for achieving the desired position.In this respect, in order to provide a better understanding of the performance of the controllers, the graphs of the controlling force of each of the actuators are compared for the optimal fuzzy PD controller and the optimal PD controller.
As it can be found from Figure 5, the optimal fuzzy PD controller requires nearly the same controlling force as the optimal PD controller; however, the optimal fuzzy PD controller provides a lower time for reaching the desired position compared to the optimal PD controller.
By comparing the graphs of the controlling force for each of the links, it can be found that the forces of the actuators in both cases have some limits, which illustrates the appropriate performance of the fuzzy PD controller.Further, by using the fuzzy PID controller, the desired state is reached in less time compared to the PD controller.
By comparing the velocity diagrams of each of the links (Figure 6), it can be understood that the velocities of the links are higher when using the fuzzy PD controller in contrast to the PD controller.Therefore, the proper performance of the fuzzy PD controller is guaranteed by reaching the desired state in less time than the PD controller.

Conclusions and Future Work
This research study presented an optimal fuzzy PD controller for a RPP robot manipulator based on particle swarm optimization and inverse dynamics.Indeed, the Denavit-Hartenberg method and the Jacobi approach for each of the arms of the robot were utilized to obtain its kinematic equations.Moreover, the Lagrange approach was used to gain the dynamic equations of the manipulator.By comparing the results, it was found that the fuzzy PD controller provides a lower settling time and a near-zero steady state error, which resulted in the superiority of the fuzzy PD controller over the PD controller.
The use of classic controllers for the control of the smart autonomous vehicles requires complete knowledge of all the forces and torque.These forces and torque are required to obtain the differential reciprocal and rotational movements.In fact, to obtain these equations, it is needed to address complex equations in a high amount of time or conduct experiments to gain the coefficients.
Future Works.(1) By combining the robust control approach and computational torque, it is feasible to eliminate the weakness of unrobustness in this type of controllers.( 2 By utilizing a PID controller, it is possible to diminish the disturbances within the system and make them fairly zero. (3) By using a fuzzy controller which is independent of the inverse dynamic, it is feasible to receive the output feedback in every instant and so adjust the inputs of the system based upon that.

Figure 1 :
Figure 1: The position of the coordinate systems on each of the joints.

Figure 2 :
Figure 2: The input membership function.
The objective function () is considered as the integral of the summation of the absolute of the joint variables as follows.= ∫ (     1     +      2     +      3     )

Figure 3 :
Figure 3: Convergence diagram of the PSO algorithm over the iteration number.

Figure 4 :
Figure 4: The position diagram of each of the links controlled via optimal fuzzy PD and optimal PD controllers, (a) the position of the first link (revolute), (b) the position of the second link (prismatic), and (c) the position of the third link (prismatic).

Figure 5 :
Figure 5: The comparison of the controlling force for optimal fuzzy PD and optimal PD controllers, (a) the controlling force of the first link (revolute), (b) the controlling force of the second link (prismatic), and (c) the controlling force of the third link (prismatic).

Figure 6 :
Figure 6: The comparison of the velocity diagrams, (a) the velocity of the first link (revolute), (b) the velocity of the second link (prismatic), and (c) the velocity of the third link (prismatic).

Table 2 :
The fuzzy rules of the system.

Table 3 :
The assumed parameters of the PD controller.

Table 4 :
The initial conditions of the location and velocity and the desired values (q d ) of each of the links.

Table 5 :
Design variables and objective functions found by the particle swarm optimization algorithm.PD controller.It is crucial to note that the input parameters of the controllers and the input coefficients are assumed in an ideal status in this study, and if there exist differences between