Control of Robot Arm Motion Using Trapezoid Fuzzy Two-Degree-of-Freedom PID Algorithm

: Symmetries play very important in the dynamics of robot systems. The relevant control of robot arm motion with fault diagnosis including the optimized fuzzy algorithm based on the error rate adjustment P, I, D value (Fuzzy PID algorithm) model relies on symmetry principles. A robot is a kind of mechanical device that can program and perform certain operations and mobile tasks under automatic control. The manipulator is a very complex multi-input multi-output non-linear system and the main actuator of the robot. This paper focuses on the design of a control algorithm for a two-degree-of-freedom (2-DOF) manipulator. First, the mathematical model of a 2-DOF articulated manipulator is established, that is, the functional relationship between the input driving force vector and the output rotation angle vector of a 2-DOF manipulator. Then, a set of trajectory planning algorithms are designed by using gradient model control, which can calculate the trajectory of the end-e ﬀ ector of a 2-DOF manipulator according to the user’s task requirements. The experimental results verify the e ﬀ ectiveness of the proposed algorithm.


Introduction
A robot is a machine capable of carrying out certain operations and moving tasks automatically [1]. As the main actuator of the robot, the robot arm has attracted great attention from engineers and technicians. It involves many disciplines such as materials science, control technology, sensor technology, computer technology, microelectronics technology, communication technology, artificial intelligence, and bionics [2,3]. A robot arm system mainly includes four parts: mechanical, hardware, software, and algorithms. When it comes to specific design, these parts need to consider structural design, control system design, kinematics analysis, dynamics analysis, trajectory planning research, path planning research, and kinematics dynamics simulation [4]. In addition, for the development of a portable manipulator, these parts should be closely linked and coordinated with each other. As the times advance, the application of robotic arm technology has become increasingly popular, and has gradually penetrated into various fields such as military, aerospace, medical, daily life, education, and entertainment [5]. Being fixed on the base, most robot arms currently used can only be operated at a certain position, and thus their application range is limited to repetitive work in industrial production. Hence, in the actual production, there is an urgent need for a mobile robot that has great working capacity and flexibility in various complicated environments and tasks. Due to these advantages, there are increasing studies on them. However, many of these robots are mobile, and there is no controllable arm, so they cannot grab objects. To make the mobile robot perform simple tasks, it is especially necessary to install two light robotic arms for service [6,7]. This paper focuses on the design of a control algorithm for the two-degree-of-freedom (2-DOF) robot arm. First, the mathematical model of the 2-DOF articulated robot arm is established, which is the functional relationship between the input vector of the drive force of the 2-DOF robot arm and the output vector of the rotation angle. Then, the gradient model is used to control and design a set of trajectory planning algorithms for robot arms. Thus, the trajectory of the terminal actuator of the 2-DOF robot arm can be obtained according to the user's job task requirements.

Literature Review
As production technology develops fast, robots are more widely used in industries. Wheeled robots are widely concerned due to their unique ease of control and strong robustness. Ma et al. (2017), based on the traditional PID control algorithm, adopted the fuzzy BP neural network PID control algorithm to optimize the robot tracking system. The control algorithm integrated the functions of fuzzy control, neural network control, and a traditional PID control algorithm, which made PID control have the ability of logical reasoning and calculation, and improved the stability of the tracking system of the wheeled robot [8]. Angel and Viola (2018) proposed a delta manipulator tracking control based on a fractional-order PID controller and calculated torque control strategy, then established a collaborative simulation model of a delta robot for the identification, design, and verification of control strategy. The robustness of the controller to external disturbances was evaluated by using performance indexes such as joint and space errors, joint torque, and trajectory tracking. The results showed that the fractional-order PID and calculated torque control strategy were robust and automatically disturbance-rejected when applied to the tracking task of a parallel robot. It is usually necessary to coordinate actions when performing operational tasks in the human environment, and the control of robot arm movement also requires smart coordination skills [9].
According to biomechanics, Pedrammehr et al. (2018) studied the description of dual-arm movement tasks based on extended cooperative task space (ECTs) representation and the evaluation of the performance of specified tasks. The experimental results showed that the task specification based on ECTS was intuitive and efficient [10]. Jinjun et al. (2019) proposed a new symmetric, adaptive, variable-admittance control method for position tracking of a dual-arm cooperative robot. To track the desired position and force, for the first time, based on the tracking error, the admittance parameters were adjusted online to compensate for the unknown trajectory deviation, and the symmetrical adaptive variable-admittance control with two arms coordination was realized. The simulation experiment showed that the method could achieve good tracking performance of position and force [11]. Kalamian et al.; proposed an optimal state-dependent Riccati equation based on the controller of secure digital input/output (SDIO). The two main advantages of this method are that it can design controllers for a wider range of nonlinear systems, and maintain the system stability, and the observer can continuously estimate the state of the output signal at a time-varying rate at each sampling [12].
In the discussion of robot arm trajectory, the above scholars have made some achievements, but there are rare studies exploring the application of mathematical models to the robot arm trajectory, especially not mature in the control of mechanical motion symmetry. Hence, through the mathematical model of a 2-DOF articulated manipulator, a set of motion trajectory planning is designed by using the trapezoid fuzzy PID algorithm, thus realizing the effective control of the symmetrical motion of the manipulator.

Transmission Structure
The symmetry principle was applied in the modeling method. According to the characteristics of the subject, after referring to the "Typical Industrial Robot Atlas", the following scheme is initially determined as shown in Figure 1. The boom rotates with a planetary gear reducer, the arm rotates with a two-stage synchronous belt, and the telescopic shaft is driven by a screw nut. This kind of scheme mainly considers the simplification of the transmission chain and the structure. The first scheme is characterized by: (1) The first degree-of-freedom adopts a planetary gear reducer, which is suitable for the structural features-high reduction ratio, small volume, light weight, high precision, Symmetry 2020, 12, 665 3 of 10 small backlash, large carrying capacity, low noise, and high efficiency. Furthermore, positioning and installation are easy, and the price is not high due to the use of standard articles. (2) The second degree-of-freedom adopts the two-stage synchronous serrated belt to reduce the speed, which makes full use of the space of the boom, compact structure, constant transmission ratio, large transmission power, and high efficiency. However, there are certain requirements for installation, and some devices need to be adjusted. (3) The third degree-of-freedom is driven by a screw nut. The motor directly drives the screw nut transmission with the function of deceleration. Thus, the rotary motion can be converted into linear motion in one step with high transmission precision. Besides, the screw has a self-locking function for the speed that should not be too high [13,14].
Symmetry 2020, 12, x FOR PEER REVIEW 3 of 10 degree-of-freedom adopts the two-stage synchronous serrated belt to reduce the speed, which makes full use of the space of the boom, compact structure, constant transmission ratio, large transmission power, and high efficiency. However, there are certain requirements for installation, and some devices need to be adjusted. (3) The third degree-of-freedom is driven by a screw nut. The motor directly drives the screw nut transmission with the function of deceleration. Thus, the rotary motion can be converted into linear motion in one step with high transmission precision. Besides, the screw has a self-locking function for the speed that should not be too high [13,14]. The freedom of the industrial robot's arm in spherical coordinates includes the rotation motion of the large arm, the small arm, and the stretching movement above the small arm. To make the robot's large arm rotate, the maximum torque required is when the small arm is horizontal, as shown in Figure 1. The basic technical parameters of the robot arm are as follows: (1) large arm length and its rotation angle: 500 mm, ± 120°, 30°/s; (2) small arm length and its rotation angle: 300 mm, ±90°, 30°/s; (3) small arm movement distance: 300 mm; (4) load weight: 20 Kg; (5) drive mode: DC or Servo motors.

The Inverse Solution in Kinematics of the 2-DOF Robot Arm
Known: the connecting rod length of the Joints 1 and 2; the coordinates of the point at the end of the joint connecting rod in the planar coordinate space: Solution: remembering the joint values as 1 q and 2 q , which are shown in Figure 2. The freedom of the industrial robot's arm in spherical coordinates includes the rotation motion of the large arm, the small arm, and the stretching movement above the small arm. To make the robot's large arm rotate, the maximum torque required is when the small arm is horizontal, as shown in Figure 1. The basic technical parameters of the robot arm are as follows: (1) large arm length and its rotation angle: 500 mm, ± 120 • , 30 • /s; (2) small arm length and its rotation angle: 300 mm, ±90 • , 30 • /s; (3) small arm movement distance: 300 mm; (4) load weight: 20 Kg; (5) drive mode: DC or Servo motors.

The Inverse Solution in Kinematics of the 2-DOF Robot Arm
Known: the connecting rod length of the Joints 1 and 2; the coordinates of the point at the end of the joint connecting rod in the planar coordinate space: Solution: remembering the joint values as q 1 and q 2 , which are shown in Figure 2. As shown in the figure above, the following equation is obtained without considering the Singularity point: Thus, the inverse solution calculation of kinematics is: x y is a mathematical function used to calculate the tangent value of x y (in radians).
In addition, regarding the inverse kinematics, it can be obtained that it is a nonlinear system. As shown in the figure above, the following equation is obtained without considering the Singularity point:

Algorithm Structure
Thus, the inverse solution calculation of kinematics is: a tan(x, y) is a mathematical function used to calculate the tangent value of x/y (in radians). In addition, regarding the inverse kinematics, it can be obtained that it is a nonlinear system.

Algorithm Structure
After the solution of the robot arm in kinematics is obtained, it is necessary to design its motion path when it moves toward the target trajectory. Here are the two-path planning algorithms in the rectangular coordinate space and the path planning in the joint space.
The joint value is the ultimate control of the motion of the end of the arm. If the trajectory in the joint space can be designed, the speed caused by the singularity of the Jacobian matrix can be effectively prevented from being out of control, and the calculation time can be greatly reduced [15]. However, in most cases, the joint coordinate space is nonlinearly related to the Cartesian coordinate space. Hence, direct planning in the joint space can only be an operation that does not require a fixed Symmetry 2020, 12, 665 5 of 10 path. For example, a continuous arc welding operation requiring higher for the motion path must be designed only in the Cartesian coordinate space. Then, the trajectory sequence in the Cartesian coordinate space obtained by the design is solved by the corresponding inverse solution algorithm, as shown in Figure 3.
After the solution of the robot arm in kinematics is obtained, it is necessary to design its motion path when it moves toward the target trajectory. Here are the two-path planning algorithms in the rectangular coordinate space and the path planning in the joint space.
The joint value is the ultimate control of the motion of the end of the arm. If the trajectory in the joint space can be designed, the speed caused by the singularity of the Jacobian matrix can be effectively prevented from being out of control, and the calculation time can be greatly reduced [15]. However, in most cases, the joint coordinate space is nonlinearly related to the Cartesian coordinate space. Hence, direct planning in the joint space can only be an operation that does not require a fixed path. For example, a continuous arc welding operation requiring higher for the motion path must be designed only in the Cartesian coordinate space. Then, the trajectory sequence in the Cartesian coordinate space obtained by the design is solved by the corresponding inverse solution algorithm, as shown in Figure 3. If necessary, the path interpolation in the joint coordinate space is performed on the joint variable spatial sequence obtained by inverse kinematics. Generally, when the motion controller performs motion axis servo control, it will interpolate the joint specified variables [16][17][18]. There are two ways to interpolate the rate curve, which are trapezoidal graphic mode and S-shaped graphic mode.
In the Cartesian coordinate space, the path space curve equation of the 2-DOF arm end object is: In the above equation, "x", "y", and "z", respectively, represent the position coordinate values of the robot arm in the three-dimensional Cartesian coordinate space, and "t" is time. To facilitate the actual control, the curve expression represented by the arc length parameter is usually selected, and the curve function that knows the initial value of the starting point A s is: In the above equation, "S" is expressed as the arc length parameter, and the integral equation is: ( ) t t s = is obtained and substituted into Equation (12), and the curve function achieved is shown in Equation (13).
Recording t Δ as the update time of the motion trajectory, that is, an interpolation point, is generated every t Δ time. T is the expected motion time of the trajectory, then the length of the obtained trajectory interpolation sequence is: If necessary, the path interpolation in the joint coordinate space is performed on the joint variable spatial sequence obtained by inverse kinematics. Generally, when the motion controller performs motion axis servo control, it will interpolate the joint specified variables [16][17][18]. There are two ways to interpolate the rate curve, which are trapezoidal graphic mode and S-shaped graphic mode.
In the Cartesian coordinate space, the path space curve equation of the 2-DOF arm end object is: In the above equation, "x", "y", and "z", respectively, represent the position coordinate values of the robot arm in the three-dimensional Cartesian coordinate space, and "t" is time. To facilitate the actual control, the curve expression represented by the arc length parameter is usually selected, and the curve function that knows the initial value of the starting point s A is: In the above equation, "S" is expressed as the arc length parameter, and the integral equation is: t = t(s) is obtained and substituted into Equation (12), and the curve function achieved is shown in Equation (13).
Recording ∆t as the update time of the motion trajectory, that is, an interpolation point, is generated every ∆t time. T is the expected motion time of the trajectory, then the length of the obtained trajectory interpolation sequence is: When the arc length gives the rate shift curve segment and the increment of each interpolation arc length ∆s = s/n is known, the trajectory interpolation sequence expression can be obtained: In the trapezoidal velocity curve mode (the path segment is composed of deceleration, constant velocity, and acceleration), the acceleration and deceleration are equal, and the times of acceleration Symmetry 2020, 12, 665 6 of 10 and deceleration are the same, see Figure 4. t a is taken as the time of acceleration and deceleration, and the path length is expressed as: When the arc length gives the rate shift curve segment and the increment of each interpolation arc length / s s n Δ = is known, the trajectory interpolation sequence expression can be obtained: In the trapezoidal velocity curve mode (the path segment is composed of deceleration, constant velocity, and acceleration), the acceleration and deceleration are equal, and the times of acceleration and deceleration are the same, see Figure 4. a t is taken as the time of acceleration and deceleration, and the path length is expressed as: After the coordinate values of the trajectory interpolation sequence are solved, the trajectory interpolation speed may be performed by using a differential approximation of the adjacent position sequence points during the operation due to the shortness of the trajectory update period t Δ

Fuzzy PID Control
PID control is a controller composed of proportion, integral, and differential [19]. PID controller is a kind of linear controller, and it has control deviation formed according to the set value ( ) i t and the actual output value ( ) o t : The proportion coefficient p K , integral time constant I T , and differential time constant D T of the deviation are adjusted and combined to form the control quantity. The proportional coefficient reflects the proportional relationship formed by the output and input errors of the controller. Increasing the proportional coefficient can reduce the steady-state error of the system to improve the steady- When the time points are different, following the different segments of the path of Equation (14), and substituting the result s i into Equation (5), the coordinate values of the sequence after the trajectory interpolation can be solved.
After the coordinate values of the trajectory interpolation sequence are solved, the trajectory interpolation speed may be performed by using a differential approximation of the adjacent position sequence points during the operation due to the shortness of the trajectory update period ∆t

Fuzzy PID Control
PID control is a controller composed of proportion, integral, and differential [19]. PID controller is a kind of linear controller, and it has control deviation formed according to the set value i(t) and the actual output value o(t): The proportion coefficient K p , integral time constant T I , and differential time constant T D of the deviation are adjusted and combined to form the control quantity. The proportional coefficient reflects the proportional relationship formed by the output and input errors of the controller. Increasing the proportional coefficient can reduce the steady-state error of the system to improve the steady-state accuracy. The integral part eliminates the steady-state error of the system, and the differential part improves the stability performance of the system. By adjusting the above parameters, the controlled object can be controlled. The PID control law of the controller is as follows: The core content of PID control is to adjust the parameters, and finally determine a set of fixed parameters to control, so that the characteristics of the controller match the controlled object, thereby achieving the most satisfactory control effect.
In a conventional two-dimensional fuzzy controller, the input variables are the changes of deviations and the input variables. Thus, in general, this controller is considered to have both fuzzy proportional and differential control functions, but lacks the function of fuzzy integral control. However, the integral control of the linear control theory offsets the stable deviation, but the dynamic operation response is slow; the proportional control function has a fast-dynamic response speed. What's more, the high steady-state accuracy and the fast-dynamic response can be achieved by the proportional-integral control function. Therefore, the fuzzy controller adds a PID control strategy to form PID compound control. Except for the considerable improvement of dynamic and static performance, there are also other advantages like fast-dynamic response speeds, small overshoot, and low deviation of stable disturbances. Determining the parameters is the key part of the PID control. This method determines the parameters through fuzzy control, that is, using the rate of error change ec and system error e. Parameters can be modified online and fuzzy control rules can be applied, which aim to realize the connection between each parameter and the rate of error change and error e, detecting them from the experiment. The various physical parameters are modified online so that different user's requirements for the control parameters can be met when e and ec are different. Consequently, the control target can be equipped with various advantages such as good dynamic or static performance, small calculation procedure, and easy to be realized by the single-chip microcomputer. The principle block diagram is shown in Figure 5.
The core content of PID control is to adjust the parameters, and finally determine a set of fixed parameters to control, so that the characteristics of the controller match the controlled object, thereby achieving the most satisfactory control effect.
In a conventional two-dimensional fuzzy controller, the input variables are the changes of deviations and the input variables. Thus, in general, this controller is considered to have both fuzzy proportional and differential control functions, but lacks the function of fuzzy integral control. However, the integral control of the linear control theory offsets the stable deviation, but the dynamic operation response is slow; the proportional control function has a fast-dynamic response speed. What's more, the high steady-state accuracy and the fast-dynamic response can be achieved by the proportionalintegral control function. Therefore, the fuzzy controller adds a PID control strategy to form PID compound control. Except for the considerable improvement of dynamic and static performance, there are also other advantages like fast-dynamic response speeds, small overshoot, and low deviation of stable disturbances. Determining the parameters is the key part of the PID control. This method determines the parameters through fuzzy control, that is, using the rate of error change ec and system error e . Parameters can be modified online and fuzzy control rules can be applied, which aim to realize the connection between each parameter and the rate of error change and error e , detecting them from the experiment. The various physical parameters are modified online so that different user's requirements for the control parameters can be met when e and ec are different. Consequently, the control target can be equipped with various advantages such as good dynamic or static performance, small calculation procedure, and easy to be realized by the single-chip microcomputer. The principle block diagram is shown in Figure 5. The fuzzy self-tuning PID controller takes the error e and the error change rate e' as the input. First, the fuzzy control rules are determined according to the actual operation experience to form the fuzzy rule table. The system obtains the increment of K p , K I , and K D , by querying the table according to e and e' obtained by sampling, that is, ∆K p , ∆K I and ∆K D The final output value of fuzzy self-tuning PID controller is: According to the current control error E and error change EC, the fuzzy variable A is generated by combining the characteristics and reasoning of the specific controlled process.

Experimental Analysis
According to the analysis and mathematical modeling of the 2-DOF solution in kinematics above, the corresponding relationship between the robot arm from the Cartesian coordinates to the Symmetry 2020, 12, 665 8 of 10 polar coordinates. Then, a basic fuzzy PID control algorithm model of the 2-DOF robot arm can be constructed. Selecting the desired input signal as: The ideal output trajectory given by the input signal is set to an elliptical trajectory with a long half axis of 0.7, a short half axis of 0.3, and a focus on the axis y. Using the Simulink simulation diagram to run the program built above, a given trajectory curve, a tracking trajectory curve, and an error trajectory curve can be obtained.
The 2-DOF robot arm is a dual-input and dual-output system, so two sets of fuzzy control functions must be established to adjust the parameters ∆k P , ∆k I , ∆k D from the arm L1 and L2. The interval between each sampling is 1 ms, and the gradient model is selected to control the spiral curve tracking. The operations are performed as below: (1)

Experimental Analysis
According to the analysis and mathematical modeling of the 2-DOF solution in kinematics above, the corresponding relationship between the robot arm from the Cartesian coordinates to the polar coordinates. Then, a basic fuzzy PID control algorithm model of the 2-DOF robot arm can be constructed. Selecting the desired input signal as: The ideal output trajectory given by the input signal is set to an elliptical trajectory with a long half axis of 0.7, a short half axis of 0.3, and a focus on the axis y . Using the Simulink simulation diagram to run the program built above, a given trajectory curve, a tracking trajectory curve, and an error trajectory curve can be obtained. The 2-DOF robot arm is a dual-input and dual-output system, so two sets of fuzzy control functions must be established to adjust the parameters   The comparison in above figures shows that: (1) for the output of the control system, it will only be affected by the output interference; (2) the three external error will interfere with the output of the controller G c (s), and the output will have an additive effect; (3) Kp, Ki, Kd all have no effect on the second disturbance, and the trajectory tracking algorithm has no great relationship with the disturbance of the output of the controller; (4) even if one disturbance in the second or third one is positive and the other is negative, the reflection of both disturbances caused by u, Ki, Kd is positive and the other reflections are negative. The comparison in above figures shows that: (1) for the output of the control system, it will only be affected by the output interference; (2) the three external error will interfere with the output of the all have no effect on the second disturbance, and the trajectory tracking algorithm has no great relationship with the disturbance of the output of the controller; (4) even if one disturbance in the second or third one is positive and the other is negative, the reflection of both disturbances caused by u Ki Kd , , is positive and the other reflections are negative.

Conclusion
Through the comprehensive study of the robot arm control system, especially the control of the robot arm, either from the theory or from the principle in many aspects, it is concluded that its trajectory expression in space motion is a nonlinear function. It can only be modeled, studied, and controlled by the fuzzy control theory. In the environment provided by the simulation software of MATLAB, using the gradient model control to study the nonlinear multi-degree-of-freedom robot arm further distinguishes the use of the two theories. To do everything from reality, link theory to reality, and combine simulation and practice together gives people a higher understanding of control learning.
The traditional PID control method is improved to 2-DOF PID control, and the concept of trapezoid fuzzy is introduced. Finally, through the simulation experiment, it is confirmed that the system response speed is faster, the position tracking error is smaller, and the control effect is better. Due to the limitation of personal ability, there are still some deficiencies in the smoothness control of robot arm trajectory, which will be further discussed in the next study.
Funding: This research received no external funding.

Conflicts of Interest:
The author declare no conflict of interest. Figure 7. Ki Adjustment.

Conclusions
Through the comprehensive study of the robot arm control system, especially the control of the robot arm, either from the theory or from the principle in many aspects, it is concluded that its trajectory expression in space motion is a nonlinear function. It can only be modeled, studied, and controlled by the fuzzy control theory. In the environment provided by the simulation software of MATLAB, using the gradient model control to study the nonlinear multi-degree-of-freedom robot arm further distinguishes the use of the two theories. To do everything from reality, link theory to reality, and combine simulation and practice together gives people a higher understanding of control learning.
The traditional PID control method is improved to 2-DOF PID control, and the concept of trapezoid fuzzy is introduced. Finally, through the simulation experiment, it is confirmed that the system response speed is faster, the position tracking error is smaller, and the control effect is better. Due to the limitation of personal ability, there are still some deficiencies in the smoothness control of robot arm trajectory, which will be further discussed in the next study.