Inverse Kinematics and Trajectory Planning Analysis of a Robotic Manipulator

— In this work, we pretended to show and compare three methodologies used to solve the inverse kinematics of a 3 DOF robotic manipulator. The approaches are the algebraic method through Matlab® solve function, Genetic Algorithms (GAs), Artificial Neural Networks (ANNs). Another aspect considered is the trajectory planning of the manipulator, which allows the user to control the desired movement in the joint space. We compare polynomials of third, fourth and fifth orders for the solution of the chosen coordinates. The results show that the ANN method presented best results due to its configuration to show only feasible joint values, as also do the GA. In the trajectory planning the analysis lead to the fifth-order polynomial, which showed the smoothest solution.


I. INTRODUCTION
In the past years, we can found several approaches to the robotics' research field due to its wide-range applications, such as in industrial production, space exploration and medical surgery (Zou, Hou, Fu, & Tan, 2006).Thus, the study and development of mobile robots, e.g. robotic manipulators, became a recurrent theme in engineering.
A key concept in the research of robotic manipulators is the trajectory planning. To reach a determined coordinate with the smoothest sequence of movements in a plausible solution, and the ability to avoid obstacles in the manipulator's workspace are essential tasks in this application (Zou et al., 2006).
Trajectory planning refers to how a robot goes from one location to another in a controlled manner. Composed of straight-line motions or sequential motions, the use of kinematics and dynamics of a robot is required. In comparison to a simple path, its advantage is the possibility of configuring the trajectory for each portion of the motion segments between the points through desired speed and acceleration (Niku, 2010).
A commonly used methodology of movement analysis of a robotic manipulator is the kinematic study. When this analysis is done, the geometric complexity increases if the manipulator present several DOF, mainly if we use the inverse kinematics method.
Thekinematic study is an important aspect of a manipulator calibration.In this way, two models are used, the direct and inverse kinematics. The inverse kinematics, used in this work, exhibit challenge due to its equations are non-linear, the manipulators present elevate DOF, with the possibility of presenting multiple solutions (Nunes, 2016).
Some traditional methods as geometric, algebraic and numerical-interactive are used for inverse kinematics solution and are from inappropriate usage whenever in a complex manipulator structure (Alavandar & Nigam, 2008). In this way, some alternative approaches in solution and ANNs application can be found in the literature. Hence, its effectiveness to understand the manipulator is due to the flexibility and capability of learning through training.
In order to accomplish a desired purpose, a recurrent methodology is the use of redundant manipulators, which present more degrees of freedom (DOF) than required to a specific task. Otherwise, the manipulator's end-effector will not have the necessary accuracy (Xiao & Zhang, 2014).
In this work, for a two-dimensional (2D) space, a 3 DOF robotic manipulator is used to reach desired points within its workspace. Three different methodologies are used to solve the inverse kinematics of the manipulator: Geometric Equations System through Matlab® solve function, Genetic Algorithms (GAs) and Artificial Neural Networks (ANNs). Thus, the second step is the trajectory planning for a specified point in the manipulator's workspace. In this work, all the manipulator's joints have simultaneous movement in the same crossing time.
Some similar papers can be cited. In work (Tian & Collins, 2004), Tian and Collins propose a GA method for trajectory planning with obstacles in workspace. Polynomials represent the trajectory and are formulated for internal points interpolated with GA parameters. The objective is to search for an optimal solution in the manipulator's workspace.
An intelligent posture calibration method is proposed in (Kuo, Liu, Ho, & Li, 2016) for a robot arm calibration which integrates Particle Swarm Optimization (PSO) and ANN methods. The problem describes an error due to a not ideal mechanism design. The results demonstrated the feasibility and practicability of the proposed method.
In (Savsani, Jhala, & Savsani, 2013), a robotic manipulator trajectory is optimized through Teaching Learning Based Optimization (TLBO) and Artificial Bee Colony (ABC) optimization techniques. The objective was a trajectory planning with less travelling time and distance between joints. The results show better performance of TLBO and ABC in comparison with a GA.
This work is developed as follows: Section II presents the fundamentals of robotic manipulators and the solve, GA and ANN techniques. Section III shows the methodology used and the constructive aspects of the studied manipulator. In Section IV, we show and discuss the obtained results for the three approaches, as the trajectory planning for a desired coordinate. Finally, Section V concludes the paper and addresses future works.

II. BACKGROUND
In this section, we present the concepts of robotic manipulators and three polynomial methods used for trajectory planning. In addition, we briefly discuss the GA and ANN techniques used for the manipulator calibration.

Robotic Manipulators
Robotic manipulators are devices used in engineering that interact and execute tasks within a workspace, with similar characteristics to the human arms. Several manipulators are installed in industries to handle objects through stations, to welding, assembling etc. (Hexmoor, 2013). Fig. 1 shows an example of robotic manipulator with 2 DOF; l1 and l2 are the joints' lengths, θ1 and θ2 the angles of the first and second joints, and P the desired point. Robots are unable to respond in emergency situations unless through situation prediction and the response is already included in the system. This scenario divides robotics into the fields of programmed and autonomous robotics. The PUMA, Stanford and others known robots are arms mechanical systems exhibit complex kinematics, static and dynamics, which makes difficult its analysis, control (Niku, 2010)and the interaction between the manipulator and environment (Hu & Xiong, 2018).
With the increase in the use of manipulators, their environments present in several forms. Their interaction with non-static environments led to adaptive manipulator's controllers in order to maintain acceptable performance levels. The applications involve changing loads, varying geometry etc. (Zhang & Wei, 2017).
In this way, intelligent systems such as Adaptive Neuro-Fuzzy Inference System (ANFIS), ANNs and GAs have been used in robotics mainly due to the design of autonomous robots and their controllers for unstructured, flexible, and/or partially unknown environments is a very difficult task for a human designer.
Inherent to inverse kinematics is the problem of multiple solutions. In this case, the angles set that lead to the same initial and final points, but with impossible solutions due to the constructive aspect of the manipulator or also through undesirable paths, as also redundant solutions. In addition, the number of possible solutions increases exponentially with increasing DOF. From the position of origin of a manipulator, i.e. the reference of its base represented by O and the desired position at the other end of the manipulator represented by P, multiple solutions could satisfy the joints' angle configuration. Thus, there are redundancies in the inverse kinematics solution, as shown in Fig. 2, for 2 and 3 DOF manipulators, respectively (Nunes, 2016).

International Journal of Advanced Engineering Research and Science (IJAERS)
[  In Fig. 2, θ1 and θ2 are the angles of the first and second joints, a1 and a2 are the joints lengths and P the desired point.

Trajectory Planning
The trajectories are composed by a sequence of displacements of a robotic manipulator. It can be seen as a sequence of points in which the end-point must course. Due to the manipulator's discretized movement, we obtain a continuous trajectory. Thus, the trajectory optimization of robotic manipulators is the identification, the optimal combination and the number of intermediary positions (Pires, 1998).
The trajectory planning is presented generally in two forms, the operating space and joint space. In the first one, the trajectory of end-effectors (the manipulator itself) is trivially described. However, it lead to kinematic singularities and manipulator redundancy. In this way, the joint space approach guarantee the smoothness of the joints movement, but reducesthe position accuracy in the operating space. The joint space is the method used in most cases, and the trajectories have been formed by several interpolation functions such as the polynomials used in this work (Huang, Hu, Wu, & Zeng, 2018).
The general form of the polynomials used in the joint space is given as follows. For joints' speed and acceleration, we trivially derive (1) one time for joint speed and again for joint acceleration.
In (1), t is the time vector, θ(t) represent the angles in time and cn are the constants associated with the n-order polynomial. The n-order polynomial enables the user to choose n+1specifications, such as initial and final speed and positions, a desired acceleration etc.

Genetic Algorithms
The development of computational simulations of genetic systems began in the 50s and 60s through many biologists, with John Holland developing the first researches in the area, in 1975 (Holland, 1992). Since then, they have been applied successfully in several realworld search and optimization problems, like regression, feature selection (Kramer, 2017), classification or machine learning (Goldberg, 1989;Pedrycz, Stach, Kurgan, & Reformat, 2005).
GAs are known as a powerful tool for optimization. It is a model designed to emulate natural selection and genetics (Holland, 1992). It has several benefits over conventional optimization methods. The GA use do not require an entire system model, therefore employed trivially to solve optimization problems. According to (Kramer, 2017), GAs are heuristic research approaches applicable to a wide range of optimization problems, which makes them attractive for various problems in practice.
These algorithms are composed of a population of individuals and a set of operators over the population. A priori, an initial population consisting of random individuals is selected. Each individual into population represents a solution of the optimization problem, which is coded to the parameter set (chromosome). If the population of individuals is large, the algorithm lacks in efficiency and if it is small GA lacks in diversity.
Posteriori the fitness function is defined. In this work, the Euclidean distance is the fitness function. The individuals are crossed and mutated until the most adequate solution is found. According to the evolutionary theories, through which the GA was developed, the better-adapted individuals to its environment are more likely to survive and reproduce, transmitting their genetic material to the new generations.
In this work, it is used to search for the optimal solution for the inverse kinematics of the manipulator (Tian & Collins, 2004). Fig. 3 show a flowchart used for the GA development (Lopes, Rodrigues, & Steiner, 2013).
In Fig. 3, at first, we generate an initial population of possible solutions. Thus, the individuals are evaluated according to the fitness function. Then, we check if the GA stop criterion was reached: if not, the most adequate individuals are selected through a selection or reproduction method. The selected ones are exposed to the genetic operators (crossing, reproduction, mutation) and a new generation is formed from the previous one. This cycle repeats until the stop criterion is reached. At this moment, the algorithm converges presenting the solution found for the problem (Lopes et al., 2013).

Artificial Neural Networks
By a neurobiological analogy, ANNs are based in a fast and powerful brain. In engineering, it as an opportunity to solve complex problems and, to neurobiologists, is a research tool to understand the neurobiology behavior (Haykin, 1998).
The ANNs have a computational power from massively distributed structure and its ability to learn. These two capabilities make it possible for solving complex problems (Haykin, 1998). Thus, ANNs have some capabilities such as nonlinearity, input-output mapping, adaptiveness, evidential response, contextual information, fault tolerance, very-large-scale-integrated (VLSI) implement ability and uniformity of analysis and design (da Silva, Spatti, Flauzino, Liboni, & Alvez, 2017). These concepts are exploited in the next paragraphs.
For nonlinearity, ANNs are a nonlinear structure of artificial neurons distributed throughout the network and are an important figure due to the nonlinearity of input signals (Haykin, 1998).The ANNs also present inputoutput mapping. The synaptic weighs are modified by training the network with a task-determined number of samples randomly picked in order to minimize de difference between output and desired response. The network learns from the examples as mapping the inputoutput problem(da Silva et al., 2017).
To become adaptive, an ANN may react at minimum changes in the environment of study causing changing by the synaptic weights. A more robust performance for a non-stationary environment depends on a greater adaptability of the system. However, adaptiveness and robustness are not always proportional. Another aspect of the ANNs is the evidential response. It can provide information about pattern selection and its confidence.
The objective is for a better performance and pattern classification (Haykin, 1998).
By meanings of a contextual information,the activation and structure of an ANN define the knowledge which affects all neurons in the network by information dealing. In terms of fault tolerance, anANN is a capable of robust computation by adverse conditions. However, it is uncontrollable and the algorithm must be carefully optimized (Haykin, 1998).
The very-large-scale-integrated (VLSI) technologyimplementability means that some complex behavior tasks are well solved due to a parallel computation by the network. In the feature of uniformity of analysis and design,a notation is used in all domains in a network and manifests through neurons, share of theories and algorithms by many applications, and seamless integration of modules building modular networks (Haykin, 1998).

III. MATERIALS AND METHODS
The first step was to determine the joints' physical limitations. In this case, for all the joints we use a maximum angle of 60º.Then, we generate the point cloud considering the first and second quadrants in the xy plane using forward kinematics.
The next step was to choose five test points in order to verify the accuracy of the three methods used to compare them and choose the best method to use in the second phase: the trajectory planning. The point cloud and the test points are shown in Fig. 4. The desired points were (-10,20); (-5,22); (3,25); (10,22); (23,18).

Fig. 4: Point cloud and test points
For the solve method, we used (2) to (4) to describe the(x, y) positions for each manipulator's joints. Each equation describes one of the DOF of the manipulator, with l1, l2 and l3 being the joint lengths, respectively 7, 10 and 14 cm. 1 , 2 and 3 are the angles of joints 1, 2 and 3.

International Journal of Advanced Engineering Research and Science (IJAERS)
[ For the GA method, several heuristic configurations were tested for initial number of individuals, mutation rate and tournament size. The worst and best configurations tested are shown in Table 1. For both GA configurations used in Table 1, we defined a maximum of 500 generations for convergence, simple cross and a 1% mutation. In this work, the second configuration obtained better results, using an initial population of 50 individuals.
For the ANN method, we used a Multilayer Perceptron (MLP) with an offline calibration (training) process. The input layer is composed of two neurons asx and y coordinates of the manipulator end-effector. There are 100 neurons in the hidden layer and two in the output layer representing the calibration angles 1 , 2 and 3 .
The training algorithm used was back-propagation with Levenberg-Marquardt (L-M) method and the sigmoid was used as activation function for the hidden layer and a ramp for the output layer.A limit of 1000 epochs or a network error in order of 10 -6 for the convergence of the ANN was defined. After the training step, the MLP is able to generalize the output within the point cloud of the manipulator's workspace.
To compare the three methods used, we use the Euclidean error. However, since the geometric solve method is exact in this work, it was inconsiderate in the comparisons made. Its use is justified in Section 4.
For the trajectory planning, we chose the method with the lowest relative Euclidean error at the point that presented the smaller error. In this work, due to the offline calibration, the comparison of algorithms' execution times are not discussed. Thus, we show the performance only for the best method in this case.
Once the method has been chosen, the last step is to execute a trajectory planning using the third, fourth and fifth-order polynomials using (1) as reference. In (5) to (13), θ is the angular position of the joint, ̇ is the angular speed and ̈ the angular acceleration.
( ) = 0 + 1 . + 2 . 2 + 3 . 3  Finally, (11), (12) and (13) (13) In this work, in order to obtain a smooth trajectory for the manipulator we design the polynomials to move all the joints simultaneously. For the three cases, we determined initial and final joint speed and position. In the fourth-order polynomial, only the initial acceleration was controlled, while in the fifth-order one both initial and final accelerations were determined.
It is noteworthy that simulation environment is ideal in this work, in other words, it is noise-free, there are no obstacles in the manipulator's workspace and its weight is not considered for the calculations.

IV. RESULTS AND DISCUSSION
In this section, we present and discuss the obtained results for the three methods used for the solution of the robotic manipulator's inverse kinematics and the methods used for its trajectory planning.

Robotic manipulator inverse kinematics
In this comparison step, Tables2, 3 and 4 show the results for solve, GA and ANN methods used. In Table 2, we zeroed the error due to its Matlab® value was in the order of 10 -29 , considered as a memory trash. It is also necessary to point out that in Table 4 the ANN method chosen omits the angles values.   By the analysis of Tables 2, 3 and 4 we conclude that the solve method obtained better results in comparison to GA and ANN. However, its present solution is one among several ones, constituting the multiple solution described in first sections. Hence, this method was discarded since the other methods obtained only one solution.

Fig. 5: Point cloud and reached points
Thus, in this case, the ANN presented errors up to ten times lower than the GA approach. Due to that it was chosen for the trajectory planning comparison between the third, fourth and fifth-order polynomials.

Trajectory planning
In this step of the work, the trajectory chosen was from the initial point (manipulator in the x axis) to Point 2 of Tables2, 3 and 4. The desired trajectory time chosen was 5 s.For all polynomials, we chose initial and final speeds as zero. In the fourth-order one, the final acceleration was designed zero, and in the fifth-order polynomial, both initial and final accelerations are zero.
The angles in discrete time are shown in Tables 5, 6 and 7, respectively for third, fourth and fifth orders. The trajectory planning is shown in Fig. 6. Each joint's angular speed, position and acceleration are seen in Figs. 7(third-order), 8 (fourth-order) and 9 (fifth-order).   In Tables 5, 6 and 7, we can note that the fourth-order polynomial has the highest acceleration and deceleration. In a real scenario, this fact can cause malfunction and/or damage the motors used to control the joints. In Fig. 6, in its initial position, the manipulator are black and, in the final point, it is green. In its analysis, we can note that third and fifth-order polynomials present higher speeds at the intermediate points of the trajectory, but decelerate in a smaller rate compared to the fourthorder one. Figs. 7, 8 and 9 complement the solution visualization. The y-axis represent position (º), speed (º/s) and acceleration (º/s 2 ) of each joint.
In Fig. 7, the first approach presented a linear response in the acceleration, initiating with high values, which can harm the motors in a possible real application.
As seen in Fig. 8, the fourth-order polynomial present values that, in a real prototype, may harm motors' functioning due to the drastic changes in acceleration and higher speeds in comparison to the other two methods used.
Finally, for Fig. 9, the fifth-order polynomial provides a smooth curve due to its full controllability of position, speed and acceleration, generating a continuous trajectory without discontinuities.

V. CONCLUSION
The results provided key-information to future works. Its analysis of the inverse kinematics solution prove that different topologies of MLP can be tested and get feasible results to a three dimensional space and to a more DOF manipulators. It is also noteworthy that this study can be extended to serial and parallel educational and industrial robots.
The fifth-order polynomial trajectory planning results presented the desired smooth curves principally for speed and acceleration, which can be totally user-controlled, that is, assuming values to preserve the components used, e.g. servo or step motors.
This work next step is to use computer vision, through a calibration of a two-camerastereo system in order to use the images to coordinate the robotic manipulator to identify and pick up targets, such as screws, or even execute more complex tasks like welding and cutting operations in three dimensions. The trajectory planning will be done in order to enable the manipulator to avoid