Two Optimized General Methods for Inverse Kinematics of 6R Robots Based on Machine Learning

,


Introduction
For 6R robots, most configurations satisfy the Pieper criterion; that is, the adjacent three axes are parallel or intersect at one point, and there is analytical solution, which can be solved with high speed and high precision.Part of the configuration does not meet the Pieper criterion and has no analytical solution due to special operating requirements, so it needs to be solved by the general solution method.To meet the requirements of smoothness, higher speed, and higher precision, some new general methods and optimization methods are still being explored and studied.Among numerous methods, the elimination method is time-consuming and complex, but it has the highest precision and can get all the solutions under the same terminal posture. is paper optimized the elimination method to improve the solving speed and make the algorithm more complete.On the basis of the Gaussian damped least-squares method, this paper introduced the variable step-size coefficient, studied the influencing factors of the coefficient, and determined the coefficient through the regression algorithm of machine learning.
e speed is superior to other iterative optimization methods.e average number of iterations is only 4 to 5 times, which effectively improves the solving speed and basically approximates the speed of analytical solutions.For inverse kinematic problems, there are three main categories of algorithms: iterative algorithm, numerical and geometric methods, and soft computing methods.
e Jacobian matrix pseudoinverse method is proposed in [1], and it is the most commonly used method of robot inverse kinematics.e algorithm is unstable when the robot approaches the singular configuration.Four Jacobian-based methods of solving the inverse kinematics are evaluated in [2].A novel formula for calculating the pseudoinverse is introduced for a class of redundant robots in [3].e optimal approximation of the Jacobian pseudoinverse algorithm by the extended Jacobian algorithm is described in [4].On the basis of the pseudoinverse method, the damped leastsquares (DLS) method [5,6] introduces the damping factor to balance the solution accuracy and the joint velocity near the singular configuration, so as to make the motion more stable.e DLS method is used to analyse the inverse kinematics of the 7R 6-DOF robots with the hollow nonspherical wrist in [7].Based on different damping factor selection strategies, the selectively damped least-squares (SDLS) method is proposed in [8].e Gaussian damped least-squares (GDLS) method is described in [9].Based on the Gaussian distribution of the damping factor, the Gaussian function is applied to determine the damping factor, which can continuously transition from undamped to damped, making the motion more stable and reducing errors.A deeply learnt damped least-squares method is proposed for solving IK of the spatial snake-like robot in [10].A deep network is built for prediction of the unique damping factor required for each target point.A hierarchical iterative inverse kinematic algorithm is proposed in [11].
An elimination method for inverse kinematics of a 6R robot is proposed in [12,13], which simplifies the inverse kinematics into a 16-degree polynomial problem.en, the matrix eigenvalue decomposition is used to replace the solving equation of higher degree.Inverse iterations of the Jacobian matrix and the elimination method are combined in [14] to study the 6-DOF manipulator and polymers.Literature [15] optimized the elimination method and verified it with an example.A new method for inverse kinematics while considering jerk limits is proposed in [16] to efficiently handle acceleration and jerk constraints.A generalized solution for a subproblem of inverse kinematics based on an exponential formula product is proposed in [16].Conformal geometric algebra is used to develop analytical inverse kinematic solutions for the KUKA Agilus robot and the UR5 robot in [17].In [18], to avoid the problem of singularity, the product of exponentials method based on screw theory is employed for kinematic modeling.In addition, the inverse kinematics is solved by adopting analytical, geometric, and algebraic methods combined with the Paden-Kahan subproblem.Various optimized numerical and iterative methods failed to achieve the same performance as analytical solutions.
Various soft computing methods [19][20][21][22][23][24][25][26] based on the artificial neural network and genetic algorithm are also the research hotspots in recent years.A comparative study between different soft computing-based methods (artificial neural network, adaptive neuro-fuzzy inference system, and genetic algorithms) applied to the problem of inverse kinematics is presented in [19].A genetic algorithm based on extreme learning machine and sequential mutation is presented in [20].A hybrid Taguchi deoxyribonucleic acid (DNA) swarm intelligence for solving the inverse kinematic redundancy problem is presented in [21].In [22], an online adaptive strategy based on the Lyapunov stability theory is presented to solve the inverse kinematics of redundant manipulators.e neural network and genetic algorithms are used together to solve the inverse kinematics of a sixjoint manipulator to minimize the error at the end effector in [23].A neural-network committee machine (NNCM) is designed in [24] to solve the inverse kinematics of a 6R redundant manipulator to improve the precision of the solution.An approach for solving the inverse kinematics of manipulator robots based on soft computing algorithms is introduced in [25].In [26], the inclusion of the current configuration of joint angles in the ANN significantly increased the accuracy of ANN estimation of the joint angle output.Various soft computing methods can achieve accuracy up to the micron level, but the solution speed is still a problem.
Some machine learning regression models are used in this paper.e decision tree (DT) [27] is a prediction model to establish a mapping between object attributes and object values.It has fast speed and easily visualizes the model.e K-nearest neighbor (KNN) [28] algorithm is based on the limit theorem.Decision-making depends on a very small number of nearest samples.e random forest (RF) [29] integrates the set of decision trees with control variance by using the idea of bagging.e gradient boosting decision tree (GBDT) [30] generates a weak classifier in each iteration through multiple iterations.Each classifier trains on the basis of the residual of the previous one.e bagging method constructs a series of predictive functions and combines them into a predictive function.ExtraTreeRegressor (ETR) is similar to the RF and consists of many decision trees.Each decision tree is obtained by using all training samples, and the bifurcation values are obtained completely randomly.

Optimized Gaussian Damped Least-Squares Method
2.1.Gaussian Damped Least-Squares Method.e Jacobian matrix pseudoinverse method, which was proposed by Whiteney [1], is most frequently used to solve inverse kinematics.Based on the known speed of the end effector, the robot joint speed is determined as where J + denotes the pseudoinversion of the Jacobian matrix.It can minimize the joint speed norm _ θ 2 and tracking error _ X − J _ θ 2 by adopting the Jacobian matrix pseudoinverse method.However, this method is unstable near the singular points.e Jacobian matrix is SV D decomposed as follows: where S is a diagonal matrix comprising singular values of J, which are arranged in the descending order as σ 1 ≥ σ 2 ≥ . . .σ m , and then the joint speed is When the robot is close to the singular configuration, the minimum singular value is approximate to 0 and joint speed is infinitely great, which is the reason why the pseudoinverse method is unstable.e damped least-squares (DLS) method incorporates the damping factor λ on this basis to minimize _ , and as a result, as the robot approaches the singular configuration, the solving accuracy and joint speed are balanced, and then the joint speed is 2 Mathematical Problems in Engineering Based on the DLS method, according to different strategies for damping factor selection, many methods have been developed.e Gaussian damped least-squares (GDLS) method allows for Gaussian distribution characteristic of the damping factor; the damping factor is determined through the following Gaussian function: where λ max is the maximum value of the damping factor and ε is a scalar quantity indicating the region of singularities.In comparison with other methods which take constant or piecewise function as the damping factor, the GDLS method includes a better strategy for selecting the damping factor.On the one hand, when the robot approaches the singular configuration, the joint speed transitions from the undamped into the damped state in a continuous way so that the motion is steadier.On the other hand, each singular value corresponds to a damping factor, so the damping only acts on the singular vectors, thus avoiding unnecessary damping and reducing the error.λ max , ε can be determined through the genetic algorithm, the details of which are given in literature [9].

Variable
Step-Size Coefficient

Concept and Distribution of Variable
Step-Size Coefficient.In order to elevate the solving speed, the variable step-size coefficient k and optimal variable step-size coefficient k _ optimal are introduced based on the GDLS method.
Definition.In the iteration process, θ cur � θ cur + dθ is changed into θ cur � θ cur + kdθ so that the iteration proceeds rapidly towards convergence and k is called the variable step-size coefficient.As shown in Figure 1, the number of iterations changes with k.When k is a certain value, the number of iterations is minimized, and the k value is defined as the optimal variable step-size coefficient k _ optimal.
It can be seen from Figure 1 that when k is close to k _ optimal, the number of iterations presents a continuous k-dependent change and gradually decreases.Hence, the number of iterations will approach the minimum value as long as k is close to k _ optimal.
In order to investigate k _ optimal distribution and the range of the minimum number of iterations, 10 4 poses are randomly selected, and they satisfy the following: D-H parameters are arbitrary, the iterative convergence error is E rr � 10 − 4 , and initial and target joint angles are controlled within |θ ini − θ end | ≤ 5 °. e GDLS method is used to solve inverse solution, and k _ optimal is obtained each time.Based on the statistics of data, the probability distribution of k _ optimal and minimum number of iterations are shown in Figure 2.
As shown in Figure 2, k _ optimal is mainly distributed within [20,120].Statistical data show that, for 95.4% of the poses, the minimum number of iterations corresponding to k _ optimal can be controlled under 20.

Influence Factors of k _ optimal.
rough the analysis of the iterative process, it is estimated that the possible influence factors of k _ optimal include the iterative convergence error E rr , the difference e between the current pose T cur and the target pose T end , the initial iterative value θ i , and singularity.
e difference between the current pose T cur and the target pose T end is e � f(e x , e y , e z , e ϕ , e θ , e ψ ), where e x , e y , e z belong to position errors, e ϕ , e θ , e ψ belong to Euler angular direction errors, and e �  6 i�1 |e i |.Generally, the minimum singular value σ m of the Jacobian matrix or the operand w � . .σ m is adopted to characterize the singularity.
When the other conditions remain unchanged, the changes of k _ optimal and minimum number of iterations with e, E rr , θ i , σ m , and w are worked out, as shown in Figure 3.
It can be seen from Figure 3 that when E rr ≤ 0.01, E rr does not affect k _ optimal.When e is small, the effect on k _ optimal is minor.Within a certain range, the effect on k _ optimal can be great.When e exceeds a certain value, that is, when the current pose and target pose are quite different, the iteration will not converge.e initial iteration value θ i has a great influence on k _ optimal, and different joint angles can exert different effects on k _ optimal.
e minimum singular value and operand have no direct influence on k _ optimal.On the whole, the main factors influencing k _ optimal are θ i and e.

Determination of k _ optimal Based on Machine Learning.
e analysis of influence factors of k _ optimal shows that the goal is to determine k _ optimal through θ i and e. ough all kinds of methods are tried, it is very difficult to directly obtain their function expressions.erefore, with θ 1 ∼ θ 6 and   4 Mathematical Problems in Engineering e as the input and k _ optimal as the output, the machine learning regression method is selected.10 5 poses are randomly selected.When other conditions are unchanged, θ 1 ∼ θ 6 and e are changed to obtain the corresponding k _ optimal which acts as original data for training and testing.ree frequently used statistical indicators, that is, root mean square error (RMSE), coefficient of determination (R 2 ), and mean absolute error (MAE), are used to evaluate the model performance: e regression models are frequently adopted in machine learning; 6 effective models are selected and compared, and the performance analysis is shown in Table 1.A total of 1,000 groups of data are selected by adopting four methods to generate the regressive fitting curves in Figure 4.
As shown in Table 1, training effects of the decision tree and ExtraTree on the training samples are good.e effects of the random forest and bagging on test samples are better.It can be intuitively seen from Figure 4 that the random forest and bagging generate better fitting results.rough a comprehensive comparison, the random forest brings the best result.Meanwhile, the trained random forest model is used to predict k _ optimal, and the average prediction time is only 0.9735 μs, which can be neglected in comparison with solution time.

Flowchart of Optimized Method.
e flowchart of the optimized GDLS method is shown in Figure 5.

Case of Optimized GDLS Method.
A randomly selected 6R robot is taken as an example for the test, and D-H parameters are listed in Table 2. e optimized method is named "E-GDLS," and inverse solution is solved according to the flow in Figure 5. λ max � 0.09, ε � 0.05, and the iterative convergence error is set as E rr � 0.0001.
In Table 3, IK results of 4 random data points of this method in the robot working space are summarized, and the number of iterations of the method before and after optimization is compared, as shown in Figure 6.
e test results of four arbitrary data points show that the E-GDLS method can effectively predict k _ optimal; the solving accuracy meets the requirements; the number of iterations is all within 10. e GDLS method needs about 200 iterations to converge to the error threshold in the same situation.is method can greatly reduce the number of iterations to improve the solving speed.ree trajectories are randomly selected in this study.Trajectory 1 only displays the position increment, while trajectory 2 displays increments of both the position and the Euler angular direction.Firstly, the number of iterations before and after the optimization is compared, and accuracy and stability of the optimized method are analysed through the changes of the spatial joint angle and trajectory tracking error.Trajectory 3 represents the status when the initial pose is approximate to a singular configuration, and it is mainly adopted to analyse the controlling effect of the optimized method on the joint speed relative to the Jacobian matrix pseudoinverse method.It can be seen from Figures 7 and 8 that the number of iterations of the optimized method in this paper is obviously reduced compared with that of the GDLS method, so it can effectively improve solving speed.e joint angle in the joint space changes steadily with a minor trajectory tracking error, so stability and accuracy of the motion are guaranteed.As shown in Figure 9, when the robot is approaching the singular configuration, compared with the Jacobian matrix pseudoinverse method, the optimized method can still effectively control joint speed just as other damping methods.
In order to further analyse the solving performances of different methods, 10 6 poses are randomly selected, the iterative convergence error is set as E rr � 0.0001, the maximum number of iterations is i limit � 500, and the difference value between the initial pose and the target pose is controlled within a certain range.
e test environment is 3.2 GHz CPU, 8 GB RAM, and python.e Jacobian matrix pseudoinverse methods J T , DLS, and GDLS and the optimized method E-GDLS in this paper are adopted to solve the inverse solution, respectively.e average number of iterations, the average solving time, and the proportion of failed convergence due to exceeding maximum number are calculated for each method.e results are listed in Table 4.
From Table 4, it can be found that the optimized method in this paper can effectively reduce the number of iterations and the average solving time and make iterative convergence faster so as to improve the method's convergence performance.Mathematical Problems in Engineering

Algorithm Description.
e process of the elimination method is as follows: by reversible transformation of the matrix, it is obtained that where T end � l x m x n x p x l y m y n y p y l z m z n z p z 0 0 0 1 , in which the elements in columns 3 and 4 of the right and left matrices are equal, and 6 equations unrelated to θ 6 are obtained as where  Table 2: D-H parameters of a 6R robot in the case of the optimized GDLS method. ) Eliminating θ 1 , θ 2 and simplifying the 14 equations e 1 ∼ e 14 , 6 equations irrelevant to θ 1 , θ 2 are obtained.e 6 equations are written in the form of a matrix equation as where v 1 � s 4 s 5 s 4 c 5 c 4 s 5 c 4 c 5 s 4 c 4 s 5 c 5 1   T and  is a 6 * 9 matrix containing only s 3 , c 3 .We convert s 3 , c 3 , s 4 , c 4 , s 5 , c 5 into ) and obtain the matrix equation where T and  ′ is a 6 * 9 matrix containing only x 3 .We multiply each row of the matrix equation by x 4 and merge the equation obtained with the original one, to get the matrix equation is is an overconstrained linear system.In order for this system to have a nontrivial solution, the coefficient matrix  ″ must be singular.e determinant of the coefficient matrix is a 16th degree polynomial in x 3 .e roots of this polynomial give the values of x 3 corresponding to the solutions of the inverse kinematic problem.And it is simplified to find the matrix eigenvalues and eigenvectors. ″ is written as Ax 2  3 + Bx 3 + C, and equation ( 26) is written as A, B, and C are known 12 * 12 matrices.Equation ( 27) is written as 0 e eigenvalue of M is x 3 , and θ 3 is obtained from

Optimization and Supplement of Elimination Method.
e simplification process is given in this paper for the first time.θ 1 , θ 2 are eliminated and 6 equations are obtained through 14 equations e 1 ∼ e 14 .
Expressions of s 1 , c 1 are derived through e 3 , e 6 and then substituted into e 7 , e 8 , e 9 , e 14 to obtain 4 equations.Equations e 1 , e 2 , e 4 , e 5 , e 10 , e 11 , e 12 , and e 13 are simplified through the following two formulas:  Mathematical Problems in Engineering where e final expressions of matrices A, B, and C are derived for the first time so that the one-step solving of the matrix M can be realized in this paper.
e complicated coefficient extraction process of the elimination method results in a large workload, so in most cases in other papers, the known quantities are substituted into the coefficient matrix, followed by extract variables, and the whole solving process should be implemented in multiple steps.In this paper, through the complicated coefficient extraction and simplified operation, the intermediate solving steps are streamlined, and the final expressions of matrices A, B, and C are directly derived, so the whole solving process is simplified as much as possible.One-step solving of the matrix M is realized, and only 1 ms or so is needed.is is the greatest contribution that this paper has made to the simplification of the elimination method.e expressions are not presented because they are too long.For the specific expressions, refer to the uploaded MATLAB code at https://github.com/Wangxiaoqi1031/robot1.
Solving formulas for other joint angles θ 1 , θ 2 , θ 4 , θ 5 , and θ 6 in the simplest forms are given for the first time in this paper, so as to improve the integrity of the whole method.
rough a large number of experiments, x 4 and x 5 are obtained by solving the ratio of large absolute values in the eigenvectors of the matrix M more accurately.rough analysis, it is possible that the maximum values are v 1 , v 3 , v 10 , an d v 12 , and the calculation formulas are as follows: , e flowchart of the optimized elimination method is shown in Figure 10.

Case of Optimized Elimination Method.
A randomly selected 6R robot is taken as an example for the test, and D-H parameters are listed in Table 5.
We evaluate the performance of the methods with two indicators of accuracy and speed.We randomly select 10 5 data points in the working space of the robot and test them under the environment of 3.2 GHz CPU, 8 GB RAM, and MATLAB and use the elimination method before and after optimization to solve IK, respectively.e worst, best, and average cases are calculated separately.e statistical results are shown in Table 7.
e results show that there is not much difference in the accuracy of the method before and after optimization, and the solution speed of the method after optimization decreases from 11-13 ms to 1.4-1.8ms.erefore, it is concluded that the optimization of the elimination method in this paper can effectively improve the solution speed while ensuring high accuracy.
When the elimination method is adopted, the proportion of poses which cannot be accurately solved is 0.086% as the matrix A is singular or the robot is close to the singular configuration, and this can be solved through the following scheme: If A is singular, inverse solving is changed into pseudoinverse solving.e singular region is evaded in the trajectory planning.Poses which cannot be accurately solved can be processed through the iteration method.

Experiment
ere is an ordinary 6R configurational robot experimental platform in the laboratory, as shown in Figure 11.
e processor of the controller is OMAPL-138, a DSP + ARM dual-core processor, the demonstrator is based on WinCE 6.0, and the maximum speed can reach 300 °/s.
In order to compare ordinary analytical methods with the two optimized methods in this paper in terms of their solving performance, 1000 tracks are randomly selected, the iterative convergence error is set as E rr � 0.0001, and the maximum number of iterations is i limit � 500; data calculated from the DSP are shown in Table 8.
It can be seen from Table 8 that the accuracy of the optimized elimination method is approximate to that of the analytical solution, and the solving time of the optimized Gaussian damping method is approximate to that of the analytical solution, too.ere is no analytical solution for the robot configuration which does not   Mathematical Problems in Engineering conform to the Pieper criterion, and then it can be solved through the two optimized universal methods in this paper.e proper method can be selected, or the two methods can be combined according to different accuracy and speed requirements.

Conclusion
is paper optimized the elimination method and the Gaussian damped least-squares method.After optimization, for the elimination method, the average accuracy of 10   12 Mathematical Problems in Engineering can be achieved, and the solution time is 1 to 1.5 ms.For the Gaussian damped least-squares method, the average number of iterations is only 4 to 5, and the solving speed is close to that of the analytical solution.e precision and speed of these two optimized algorithms cannot be achieved by the other optimized algorithms.e elimination method is simplified to the extreme.Time is mainly spent in the calculation of the eigenvalues and eigenvectors of the M matrix.If this step can be improved, the speed of the algorithm can be further improved.
e Gaussian damped least-squares method has the advantage of smooth motion itself.In this paper, by introducing the variable step-size coefficient, the number of iterations is greatly reduced, and the solving speed is effectively improved.Applying the method of machine learning to study the coefficient could achieve better results than the general fitting method.In practical application, if high speed is required, the iteration method can be applied to solve the problem.If high precision is required, the elimination method can be applied, or the two methods can be combined to solve the problem.

Figure 1 :
Figure 1: Number of iterations varying with k.

Figure 4 :
Figure 4: Regression fitting curves of four methods.

Figure 5 :
Figure 5: Flowchart of the optimized algorithm.

Figure 6 :Figure 7 :Figure 8 :
Figure 6: Comparison of the number of iterations.

Figure 9 :
Figure 9: Joint velocities of the two methods near the singular configuration.

Figure 10 :
Figure 10: Flowchart of the optimized algorithm.

Table 1 :
Performance comparison of regression models.

Table 3 :
IK results of the optimized method based on 4 arbitrary data points.

Table 4 :
Performance comparison of four methods.

Table 5 :
D-H parameters of a 6R robot in the case of the optimized elimination method.

Table 8 :
Performance comparison of three methods.

Table 6 :
All groups of real solutions.

Table 7 :
All groups of real solutions.