Modelling and Simulation of Fuzzy-based Coordination of Trajectory Planning and Obstacle Avoiding for RRP-Typed SCARA Robots

A R T I C L E I N F O A B S T R A C T Article history: Received: 14 April, 2021 Accepted: 13 August, 2021 Online: 26 August, 2021 In this article, a fuzzy-based solution of coordination between behaviors of trajectory planning and obstacle avoiding in a RRP-typed SCARA robot control is presented. The first idea of the proposed solution is to divide a robot's complex behavior into simpler parallel behaviors. The second key idea is a fuzzy-based coordination between these behaviors to make smooth robot motions without collision. The modelling and simulation on Matlab are executed to test the performance of the proposed solutions under basic circumstances.

In the basic group of 3-DoF industrial robots, there are many different categories of kinematic structures including articulated manipulators [9], Spherical manipulators [10], SCARA manipulators [11], cylinder manipulators [12], cartesian manipulators [13]. Among these categories, RRP-typed SCARA robots have been strongly invested because of flexible trajectory planning solutions with rapidly exploring random algorithms.
Fuzzy logic is an intelligent control tool that simplifies the complexity of nonlinear control through IF-THEN rules. Thanks to this advantage, many fuzzy logic solutions are proposed for controlling 3-DoF SCARA robot such as trajectory tracking control [2], position control [14], path planning control [15], obstacle avoidance [16], [17]. The Matlab simulation results of [2] show that it is possible to apply fuzzy logic for the RRP-typed SCARA controller to reduce the loop trajectory errors. From the result in [14], it is proven that the designed fuzzy logic controller help the RRP SCARA robot move smoother for tracking trajectory but without obstacle avoidance. Similarly, the proposed design in [15] confirms that fuzzy logic application makes the RRP-typed SCARA robot movement faster than the conventional PD controller in path planning. Furthermore, [16] and [17] proposed fuzzy-based solutions for obstacle avoidance of the robotic manipulators. The simulation results demonstrate that fuzzy-based obstacle avoidance provides SCARA robots better solutions of local planning without any collisions. The computational complexity, however, increases due to the repeated use of the nonlinear functions of the fuzzy logic. Different to the above-mentioned results, in [18] a fuzzy-based basic solution is proposed for coordinating obstacle avoidance and path planning behaviors of 6-DoF humanoid mobile robots. The main ideas of the solution is to divide a complex robot behavior into simpler behaviors and organize the behaviors in a hierarchical chart so that an upper class behavior consists of some behaviors in the lower class. The main ideas in [18] is reused in this research but for a 3-DoF robot to reduce the computational complexity of the robot control system. The proposed fuzzy-based coordination between parallel behaviors makes the robot movement smooth according to the changing obstacle distance. The article is presented as follows: First, the kinematic structure of RRP-typed SCARA robot is introduced. Then, a hierarchical chart of behaviors of trajectory planning and obstacle avoidance are analyzed. After that, a modular diagram of SCARA robot control system is given with the separable modules for trajectory planning and collision avoidance and fuzzy-based coordination. Finally, the Matlab simulations are analyzed to test the system performance.

Kinematic structure
The structure of RRP-typed SCARA robot with 3-DoF includes 2 revolute (R) (or rotating joints) and one prismatic (P) (or translating joint) as shown on the left side in Fig.1.
These joints are operated by 3 independent actuators to control the pose (including position and direction) of the End-Effector (E) following a desired trajectory.
The basic structure of RRT-typed SCARA robot consists of 4 parts: Base B0, revolute joint R1, revolute joint R2 and prismatic joint P3 as shown on the right side in Fig. 1.
The kinematic parameters in Fig. 2 are defined as follows: + d0 is the height from base B0 to joint R1 along Z0 axis; + a1 and a2 are the lengths of the arms 1 and 2 along axes X1 and X2, respectively; + θ1 and θ2 are the rotation angles of joints R1 and R2 around axes Z1 and Z2, respectively; + d3 is the distance from joint P3 to the end-effector E.

Homogeneous transformation
According to the Denavit-Hartenberg (D-H) of homogeneous transformation rules in [19], the D-H parameters of the SCARA robot can be setup in the table shown in Table 1. Using the D-H parameter table, the transformation matrices are as follows: To calculate the homogeneous transformation matrix from the origin 0 O to the end-effector E, we perform the matrix multiplication as follows: The detail computation of equation (4) is carried out as follows: ,, T R p are transformation matrix, orientation matrix, and position matrix of the end-effector E in comparison with base B0.
-E E E ,, x y z are respectively the coordinates of the end-effector E projected on the axes X, Y, Z of 0 OXYZ .

Inverse kinematic computation
According to [20], the inverse kinematics problem consists of the determination of the joint variables corresponding to a given end-effector position and orientation. The solution to this problem is of fundamental importance in order to transform the motion specifications, assigned to the end-effector in the operational space, in to the corresponding joint space motions that allow an execution of the desired motion.
In this study, the inverse kinematics problem requires to find out the 2 joint variables concerning angles 12 , and the displacement d3 based on the given pose of the end-effector E, that means 0 3 p and 0 3 R are known. To solve this problem, the top-viewed projections of the SCARA robot, as shown in Figure 3, allows formula (10) to mathematically express in a different way as follows: x y a c a c a s a s  To calculate angle 1 , the geometric calculation method can be used under the projections on the plane OXYZ0 as follows: Let consider triangle O0O2E and use mathematic computations:

()
Using the bottom expression in formula (10) we get: () Let draw from equations (15), (13) and (16)  In summary, based on formula (17) it is possible to simulate RRT-typed SCARA robot movement by giving the coordinates of waypoints (or path points) to form a desired trajectory.
In the next section, the calculation based on these waypoints for planning trajectory is presented. After that, the calculation for avoiding obstacle is analyzed. Based on these calculations, both kinds of behaviors concerning planning trajectory and avoiding obstacle are organized in a hierarchical chart before applying fuzzy logic for coordinating them.

Planning trajectory
According to [19], to reduce the complexity of motion control, a complex path can be replaced with a sequence of n waypoints to ensure motion along the desired trajectory 1 .. , .. Let briefly depict the computation by interpolating polynomials in a segment of trajectory between two adjacent waypoints , ij pp at two instants of time ti and tj as follows: It is noticed that, if the order of interpolating polynomials increase, the nature of the desired trajectories is reduced and the numerical accuracy for computation polynomial coefficients decreases. For this reason, cubic polynomials are chosen in the following computation.
The generic equation of interpolating polynomials with velocity constraints at the two waypoints are: where + s(t) is a cubic polynomial of the path; + v(t) is a cubic polynomial velocity respected to s(t); + ki, i = 0...3, are polynomial coefficients depended on the arbitrary motion parameters at the two considering waypoints.
To solve the polynomials, the user has to specify the desired velocities at each points as follows: Equations (18) and (19) are defined as follows: Expressing equations from (20) to (23) in a matrix form, we have the following matrix: (25) Equation (25) enables the control system planning the desired trajectory independently in pairs of waypoints. The computed velocity command at the waypoints has the following form: where -T v is linear velocity for tracking the planned trajectory.
-T is angular velocity for tracking the planned trajectory.
The detail calculation of the velocities at the given waypoints can be seen in [20].

Avoiding obstacle
In the scope of educational goal, let consider an obstacle with a cylinder shape shown in Figure 4. The obstacle stays in segment of path assuming , ij pp . In this situation, the obstacle have to be avoided by following an additional path to make a suitable curvature in segment , ij pp . Let note the distance to the left obstacle edge L be dL, the distance to the right edge R be dR. and the angle deviation β from the direction to pj to the nearest obstacle edge.
The actuating command for avoiding obstacle are follows:

Modelling the system with fuzzy-based coordination
Let call the behaviors be planning trajectory PT and avoiding obstacle AO. Then, the AO behavior is divided into 2 simpler behaviors Turning-Left (TL) and Turning-Right (TR) to control the end-effector avoiding a collision by moving to the left or the right edge, respectively. These behaviors are organized in a hierarchical chart shown in Figure 5 and the robot control system can be designed in modules as the block diagram shown in Figure6.
Module PT defines a behavior for planning trajectory and provides a motion command vT to module FC.
Module AO selects a suitable behavior between behavior TL and TR based on the results of obstacle detection and measurement in module DM. Then, an actuating command vA for avoiding obstacle is computed and sent to module FC.  Module FC carries out a fuzzy-based coordination between two behaviors vT and vA to give a suitable actuating command so that the end-effector can avoid the obstacle and reach to path point pj.
The fuzzy-based behavioral coordination mechanism is computed as follows: where kT and kC are weights of tracking trajectory and avoiding collision, which are determined by the fuzzy rules as in Table 2. In the next section, the simulations on Matlab are executed under the guide in [21] and [22] to test the control system with the fuzzy-based coordination.

GUI interface of simulation
The robot system is tested by a simulation on Matlab. The robot's motions concerning trajectory and obstacle are tracked and displayed on the GUI interface shown in Figure7.
The left area on the GUI interface displays the coordinates of the three joints concerning the motion and obstacle parameters relative to position and dimensions of height h, long diameter r1 and short diameter r2. The middle area of the GUI interface is a 3D illustration of a truth-based trajectory. The right area is a 2D view of the robot's workspace and control buttons. The five control functions are: + "Setting waypoints" button is used for setting the coordinates of each waypoint. + "Setting obstacle" button is used for setting the position and dimensions of the obstacle. + "Coordination mode" button is used for selecting a coordination mode including conventional coordination without fuzzy logic rules and fuzzy-based coordination. + "Reset" button is used for resetting all parameters. + "Run" button is used for starting the program.

Simulation goals and results
Two simulation goals are to test the conventional coordination without fuzzy rules to avoid obstacles and to test the capability of obstacle avoidance under the fuzzy-based coordination. N. Mai / Advances in Science, Technology and Engineering Systems Journal Vol. 6, No. 4, 348-354 (2021) www.astesj.com 353 Figure 8: Avoiding obstacle without fuzzy-based coordination The first simulation results are shown in Figure 8. During following the given waypoints, the robot avoids the obstacle without fuzzy-based coordination. The second simulation results are shown in Figure 9. During following the given waypoints, the robot avoids the obstacle without fuzzy-based coordination.
It is noticed that, the recoded trajectories in Figure 8 are not smooth at the points for changing from a behavior of trajectory planning to a behavior of obstacle avoiding. Otherwise, the recoded ones in Figure 9 become smooth at the points for changing from a behavior of trajectory planning to a behavior of obstacle avoiding due to the fuzzy-based coordination. The simulation results in Figure 9 prove that the fuzzy-based coordination make the robot motions non-stop before avoiding obstacle. That means the singularity problem of robotic manipulators can be avoided.

Conclusion
The proposed fuzzy-based coordination help the robot safely move and avoid the singularity problem of robotic manipulators.
Matlab simulations are performed to test the performance of the proposed system. Simulation results demonstrate that fuzzybased coordination helps the robot move more smoothly to eliminate singularity that may appear at dead-points.
In further research, the proposed solution will be tested on a real robot to evaluate the accuracy of trajectory planning after applying the fuzzy-based coordination.