The Inverse Solution Algorithm and Trajectory Error Analysis of Robotic Arm Based on MQACA-RBF Network

In order to improve the position accuracy and trajectory accuracy of a 6R robotic arm, a robot arm inverse solution algorithm based on the MQACA- (improved quantum ant colony-) RBF network is proposed. This algorithm establishes the prediction model through the neural network and uses the quantum ant colony algorithm to optimize the output weight. In order to solve the problem that the quantum ant colony algorithm has low convergence precision and easy to fall into the local optimal solution in the inverse solution algorithm of the multifreedom robotic arm, improved measures such as 2-opt local optimization and maximum minimum pheromone limit and variation are adopted. By comparing the simulation results of the 6R robotic arm simulation results and the simulation results based on ACA, QACA, and RBF neural networks on the position and motion trajectory of the space point, the advantages in precision are obvious. This proves the feasibility and eﬀectiveness of the scheme.


Introduction
In modern manufacturing, the robotic arm is a more important electromechanical integration device. It has a wide range of applications. e proportion of 6R robotic arms in these robotic arms is about 90% [1]. In order to adapt to different trajectory planning tasks, the robotic arm will be adjusted accordingly, which is closely related to the diversification of production. On the basis of dynamics and kinematics theory, the accuracy of the inverse solution [2] is a decisive factor for the accuracy and efficiency of the trajectory planning of the robot arm. e inverse solution of the 6R robot arm is the basis and premise of the robot arm trajectory planning. Because the inverse solution equations have high dimensional and nonlinear characteristics, the solution is complex, and it is difficult to find accurate solutions. Traditional inverse solution can be roughly divided into algebraic methods [3][4][5][6][7] and geometric methods [8,9]; due to poor results, it has been rarely used. In the more popular numerical iterative method at this stage [10][11][12][13], evolutionary, bionic and simulated annealing, neural networks, and other algorithms are more common intelligent algorithms [14][15][16]. Although these methods have achieved remarkable results, they are still unsatisfactory and limited in terms of convergence effect and accuracy of solutions. erefore, they need to be further explored and improved.
In the intelligent algorithm, the RBF neural network is a very important algorithm, which can approximate any nonlinear function within a finite set and arbitrary precision. Some scholars have realized the importance of the neural network and used it to solve the inverse solution of the 6R robotic arm to obtain a relatively ideal effect [17][18][19]. In this paper, an algorithm based on the MQACA-(improved quantum ant colony-) RBF network is proposed to optimize the output weight of the improved quantum ant colony, and good results are obtained.

6R Mechanical Arm Kinematics Model
For the ZrARM arm, the number of degrees of freedom is six, and the joints are all rotating joints. e forward kinematics problem is solved and the ZrARM arm improved DH model coordinate system as shown in Figure 1 [20].
From [21], it can be seen that the coordinate conversion matrix of the manipulator end joint coordinate system relative to the base coordinate system is [p x , p y , p z ] T in this matrix represents the position of the end of the manipulator in the base coordinate system. e RPY Euler angle can be described by the following formula [21][22][23]: β � arctan a x cos a + a y sin a, a z , c � arctan − n x sin a + n y cos a, o y cos a − o x sin a . (4) From the above formula, it can be seen that since the variables in (1) are all functions of the joint angle θ i , the end position p � [p x , p y , p z , α, β, c] can be obtained in the case of θ i determination.

Establishment of Prediction Model of Inverse
Solution Based on MQACA-RBF Network

Establishment of the Prediction Model of Mechanical Arm
Inverse Solution. In order to find the inverse solution of the robot arm, the inverse solution prediction model of the RBF neural network is established. In order to further improve the inverse solution accuracy, the output weight value is optimized by improving the quantum ant colony algorithm, so that the error between the output and the actual output of the network is minimized. As a kind of the neural network learning algorithm, the structure of the RBF neural network includes the input layer, hidden layer, and output layer. Figure 2 shows the structure diagram of the RBF neural network of the n-dof manipulator [20]. In the figure, it is assumed that the input of the RBF neural network is the end position variable x, x � p x p y p z α β c T , and the output variable is the inverse solution of the robot arm, that is, n joint angles y, y � θ 1 θ 2 · · · θ j · · · θ n T ∈ R n , where yis an n-dimensional vector, and the relationship between x and y is where where x k -type k sample input parameters; c i -the node center of the ith hidden layer function; h-number of nodes; ω ij -weight from the implicit layer to output layer; y n -the actual output of the n degree of freedom; and σ-variance of hidden layer functions. Quantum Ant Colony Optimization Algorithm (QACA) is an operation that enables all ants to implement quantum bit coding method and updates by quantum revolving door. erefore, its population number is relatively small, the algorithm performance is relatively high, and the convergence rate is fast. In addition, the optimization ability of the quantum ant colony is significantly enhanced, and the number of iterations is significantly reduced. erefore, its vitality and scientific research values are very strong [24,25]. Although its advantages are very prominent, there are still some problems in optimization efficiency, robustness, and convergence speed, which are closely related to large coding space and complex calculation.
In this paper, QACA and RBF neural networks are combined to complement each other's advantages and make full use of the efficient optimization capability of the quantum ant colony, and improvement measures are proposed to form the inverse solution algorithm of the mechanical arm based on the MQACA-RBF network. MQACA is used to optimize the output weight of the RBF neural network. Improvements to QACA include: (1) using the 2-opt local optimization algorithm to increase the diversity of path selection of the ant colony in the grid; (2) using maximum and minimum pheromone constraints to increase the feasibility of searching for better solutions and ensure the inspiration of experience for the ant colony; (3) on the basis of the optimal path of each group of ant colony, the mutation operation of the genetic algorithm is used to improve the quantum ant colony algorithm to avoid local optimum and ensure the accuracy and convergence of the algorithm.  e training sample of the inverse solution algorithm of the robotic arm can be obtained by positive kinematics formulas, as long as any joint angles θ 1 , θ 2 , θ 3 , θ 4 , θ 5 , and θ 6 are known, through formulas (1)- (4). You can get the corresponding position variables p x , p y , p z , α, β, and c. en, using the idea of MQACA theory [26][27][28], the output weight of each working area is sought, and the sample selection is based on this.

Coding Scheme.
In order to improve the randomness of population initialization coding, the following coding scheme is used to obtain a set of digital codes for each grid point [29]. Let m ants arrive at the end point from the starting point to get the solution of the output weight value ω n . e established decoding formula is where i � 1, 2, . . . , 9, j � 1, 2, . . . , (d × n + 2). Combine the output weight ω n obtained by decoding to obtain a set of solutions for ω � ω 1 ω 2 ω 3 · · · ω n T . In this group solution, n represents the spatial dimension (6R robotic arm n � 6), when the size of the ant colony does not change, and if the space occupied by the ant increases, the search space can be doubled and the convergence speed can be greatly increased [30].

Status Transfer Rule.
In the grid established at each output weight of the RBF network, qubits can represent the quantum pheromones of the nodes in the quantum ant colony algorithm, and their conversion can be completed by the quantum rotation gate. e adjustment form of the quantum rotation gate can be defined as [31] In the formula, i � 1, 2, . . . , m, [α t+1 i , β t+1 i ] T is the probability amplitude of the ith qubit of the t iteration, and θ i is the rotate angle of the ith qubit. e probability of ant k moving from node i to j [29] is defined as where i, r � 1, 2, . . . , 9; c � j + 1; j � 1, 2, . . . , (d × n + 2); τ (i,j;r,c) is the amount of pheromone that exists between the ω (i,j) cell point and the ω (r,c) cell point of the ant k; e information heuristic factor is represented by α(α ≥ 0), which reflects the importance of the trajectory relative to the path. e more paths the ant goes, the greater the value of α(α ≥ 0) in general is. e network node is represented by μ (r,c) . e quantum information intensity can be expressed as θ (r,c) . e following is its expression: In this expression, |α r,c | 2 represents the probability that the quantum state of the j qubit collapses to |0〉 [32].

Determine the Fitness Function.
It corresponds to a given training sample set (x k1 , x k2 , . . . , x kn ) ⟶ (t k1 , t k2 , . . . , t kn ), k � 1, 2, . . . , n, where the training sample number is represented by K. In order to determine the fitness function, it is necessary to calculate the mean square root error of the actual output and expected output of the neural network first and to determine the adaptability function, i.e., where K-total number of training samples; d ki , y ki -target output and network operation results for unit i of sample k.

Local Search 2-Opt
Algorithm. e 2-opt local optimization algorithm is used to increase the diversity of ant colony and accelerate the convergence rate of the quantum ant colony algorithm. e 2-opt algorithm is an abbreviation of 2-optimization. In simple terms, it is the optimization of two elements, also known as 2-exchange [33]. e main purpose of the 2-opt algorithm is to randomly select an interval segment for optimization.
is optimization is only about the optimization of the current situation, not the optimization of the global. e steps of the algorithm are shown in Figure 3 e approach obtained by this algorithm is locally optimal, that is, it is based on the number of iterations. Different results may occur. erefore, it is not an absolutely accurate result. It is only a relatively correct result after optimization.

Global Update of Pheromones Based on Maximum and
Minimum Pheromones. In the process of convergence, the ant colony algorithm may show that the pheromones on one path are much larger than the rest of the paths, resulting in convergence to the local optimal solution. e maximum and minimum pheromone ant colony algorithm limits the amount of information on each path to[τ min , τ max ], which can effectively avoid local stagnation in the search process [34].
Scientific setting τ max and τ min is crucial to the maximum and minimum pheromone ant colony algorithm. In the search process, the maximum pheromone growing on each iteration path is 1/f(ki), where f(ki) can represent the current global optimal moderate function, in other words, the mean square root error of the real output and the desired output. When the optimal solution changes in the iterative process, τ max and τ min will change at the same time. e Journal of Robotics 3 inverse proportional relationship between τ max and f functions and ρ, in contrast, is a positive proportional relationship with "elite ants". It can be seen that dynamic adjustments can be made to τ max and τ min using the following method. e adjustment strategy is divided into the following steps: (a) Before the initial moment pheromones are not updated, the adjustment strategy is as follows: (b) After the pheromones are updated, the adjustment strategy is as follows: In the formula, σ represents the number of "elite ants."

Variation Operation.
On the basis of the maximum minimum pheromone limit and the optimal path of each ant colony, the genetic algorithm (mutation operation) is used to reduce the local optimal solution problem in the search process of the quantum ant colony algorithm. e ant colony algorithm is improved by using genetic algorithm variation [35]. In the process of variation, a certain q node of the ant path is randomly selected to mutate, and q is gradually reduced as the number of iterations increases to ensure the convergence of the ant colony algorithm. Let the number of path nodes of the ant be n, then there is In this formula, the current number of iterations is represented by t, and the maximum number of iterations is represented by t max . e variation method is to randomly take a 0-9 integer from the selected series of nodes. If the result of the mutation is better than the original, the mutated ant path is replaced by the current path.

MQACA-RBF Network Algorithm
Steps. In summary, induction of the MQACA-RBF network algorithm to determine ω and the corresponding steps are as follows: Step 1: QACA algorithm population initialization.
Step 2: the initial value of the number of evolutions is t � 1.
Step 3: by coding, the RBF neural network is modeled according to ω, c, and σ, and the joint angle prediction accuracy of each group of parameters is obtained.
Step 4: update the rotation angle of the quantum rotation door, update the quantum pheromones at different nodes, achieve quantum initialization, and adjust the pheromone content on different paths.
Step 5: probability transition formula (9) needs to be chosen to proceed to the next lattice point. When ant k comes to the termination point, it can calculate the f value and then return to step (4) by decoding the formula.
Step 6: if k � m, then enter step 7.
Step 7: the optimal adaptation function f and optimal solution ω * in the current ant population are selected, and the global pheromones are updated according to the maximum and minimum pheromones.
Step 8: local search 2-opt optimization, mutation, and other measures were carried out for ω * .
Step 9: assuming that the optimal adaptive function value and the maximum number of iterations of the ant population have not changed too much, the optimal model parameters can be obtained, and then enter step (11).
Step 10: the number of iterations is added by 1, that is, Iter � Iter + 1 and then return to step (4).
Step 11: ω, c, and σ were calculated as the optimal parameter (the optimal parameter of each joint angle prediction model).
Step 12: e MQACA-RBF neural network is modeled on ω, c, and σ and predicts the test set. For this reason, the joint angle prediction value can be obtained through the output model.
According to the steps above, the flow chart of the MQACA-RBF inverse solution algorithm is obtained as shown in Figure 4.

Normalization of Sample Parameters.
In the process of calculating the data through the model, due to the influence of many factors, the problem of data overflow may be caused. erefore, it is necessary to standardize the sample parameters to ensure the computational efficiency of the prediction model. e sample parameters are normalized to range from 0 to 1. e normalization formula is where z-parameters before normalization; z min -minimum parameter; z max -maximum parameter; and z′-normalized parameters.

Establishment of a Prediction Model for the Inverse Solution of 6R Robotic Arm.
In order to follow the algorithm steps in Section 3.3 for simulation experiments, according to the MQACA algorithm to optimize the output weight of Figure 2, the ant gets each output weight in the process of passing through each n * d grid [29]. In the work space of the 6R robotic arm, 8000 points are randomly generated, and 1000 points are selected as training samples. After normalization, the input parameters of the RBF network are formed, i.e., x � P x ′ P y ′ P z ′ α ′ β ′ c ′ T . In order to obtain the output parameters of the RBF network, the joint angle (17) needs to be normalized, i.e., y � θ 1 ′ θ 2 ′ θ 3 ′ θ 4 ′ θ 5 ′ θ 6 ′ . Based on this, a prediction model of the 6-input 6-output  Randomly select two different paths of the grid, such as (3,6), at which point the old path is divided into three segments: inverse solution algorithm based on the MQACA-RBF network is established, training in predictive models based on a sample of 1000 points. After determining the position parameters, the number of joint angles between 0 and 1 can be obtained by using the prediction model, and then the reverse normalization is performed, i.e., where θ j ′ -the output joint angle predicted after normalization.

Analysis of Spatial Random Point Errors.
e space point simulation experiment of the ZrARM 6R manipulator is carried out. e DH parameters of the ZrARM arm are shown in Table 1 according to the structural parameters and the external dimensions of the arm.
In the MATLAB software environment, using the modeling in Section 3.1 and the 1000 points in the ZrARM model space as samples, the MQACA-RBF network method is used to simulate, and 100 points are randomly selected. Compared with the inverse solution algorithm simulation results of ACA, QACA, and RBF neural networks in the same operating environment, the position error of the four algorithms is shown in Figure 5 according to the distance between the actual coordinate point position and the target coordinate point position.
It is clearly seen from Figure 5 that the location accuracy of the inverse solution of the MQACA-RBF network is the highest in the four algorithms, and the error is stable and the change is smooth. In order to improve the real-time and convergence speed of the system, the method of online training is used in practice. Figure 6 shows the end of the ZrARM robotic arm, a known elliptical trajectory that is simulated in the established model space.

Selection of Locus Points.
In order to analyze the trajectory error, on this known trajectory curve, according to the trajectory length, 30 feature points are evenly selected as a description of the trajectory. e position of the end of the robot arm corresponding to the selected 30 points is calculated by equations (1)-(4) to obtain 30 sets of known p x , p y , p z , α, β, and c position parameter values and the corresponding 30 sets of known inverse θ 1 , θ 2 , θ 3 , θ 4 , θ 5 , and θ 6 values are obtained, which are used as reference point for trajectory error analysis.

Error Analysis of Inverse Solution of Motion Trajectory.
e 30 selected feature points on the trajectory in Section 4.3.1 are used as inputs. After the inverse solution algorithm based on the MQACA-RBF network is calculated and normalized, 30 sets of predicted output values are obtained. In order to evaluate the prediction effect of the model objectively, absolute error index is used to evaluate it. As shown in Figures 7 and 8, the inverse solution prediction values of 30 sets of joint angles θ 1 to θ 6 corresponding to the selected 30 points are compared with the absolute error of the real    Journal of Robotics values in the same posture. Among them, the minimum absolute error differences of θ 1 , θ 2 , θ 3 , θ 4 , θ 5 , and θ 6 joint angles were 2.1679e − 05 rad, 8.5494e − 05 rad, 3.4619e − 05 rad, 3.1973e − 05 rad, 9.5498e − 05 rad, and 5.8276e − 05 rad, and the maximum absolute error differences were 0.10825 rad, 0.3027 rad, 0.10811 rad, 0.12094 rad, 0.18941 rad, and 0.25166 rad, respectively. According to formula (12), the mean square root errors of joint angle θ 1 , θ 2 , θ 3 , θ 4 , θ 5 , and θ 6 are 0.12147 rad, 0.37941 rad, 0.11798 rad, 0.19206 rad, 0.28645 rad, and 0.38298 rad, respectively. erefore, it can be seen that, in the prediction model of the 6R robotic arm inverse solution based on MQACA-RBF, the accuracy error of angular prediction is small, and the prediction accuracy is high.
In order to compare with other inverse solutions, randomly select points A (spatial coordinates: 10.6601, − 2.0700, and 12.4255) and B (spatial coordinates: 11.5458, − 1.7339, and 11.1018) among the above 30 points, e inverse solutions of point A and point B are obtained by using four algorithms: MQACA-RBF network, ACA, QACA, and RBF network. Tables 2 and 3 show the inverse results of the four algorithms under the same posture conditions. From the specific data comparison, it can be seen that the RBF network algorithm has better results in the inverse solutions of ACA, QACA, and RBF networks. However, the prediction accuracy of the MQACA-RBF network proposed in this paper is the highest, and it is closer to the real value.

Coordinate Point Error
where m-number of feature point; wrepresents x, y, or z coordinates; e wm -absolute error between the actual value x (y or z) of point m coordinates and the true value x (y or z) of the coordinates; p wpm -the actual value of point x (y or z) coordinates; and p wtm -the true value of point x (y or z) coordinates. Figure 9 shows the error comparison of the x, y, and z coordinates of the above four algorithms for the 30 feature points. It can be seen that the MQACA-RBF network algorithm has the smallest error.     From the spatial position point of view, the location error comparison of the four algorithms ACA, QACA, RBF network, and MQACA-RBF network can be obtained by calculating the position error formula of equation (19), as shown in Figure 8. Table 4 shows the data comparison of the spatial positions, maximum, minimum, and average of the four algorithms: where e pm -location error of point m on trajectory.
As can be seen from Figures 9 and 10 and Table 4, the trajectory coordinate error and position error based on the inverse solution algorithm of the MQACA-RBF network are minimal; e average error of x, y, and z coordinates of the actual point position is 0.05269 mm, 0.04109 mm, and 0.04306 mm, respectively. e average error of the actual point position is 0.09144 mm, which is superior to the ACA, QACA, and RBF network algorithms. It can be seen that the coordinate points corresponding to the position error are combined with x, y, and z coordinate points, which best reflect the position error of the end of the manipulator. Based on the inverse solution algorithm of MQACA-RBF network, the fitting error between the end of the robot arm and the set trajectory is minimal, and it is very stable and robust, which proves that the scheme is feasible.

Conclusion
In this paper, a manipulator inverse solution algorithm based on the MQACA-RBF network is proposed. is method effectively synthesizes the characteristics of the RBF neural network and MQACA algorithm and gives play to their respective strengths. From the results of spatial random selection, trajectory simulation experiments, and position error simulation, it can be seen that the inverse solution algorithm using the MQACA-RBF network is compared with the inverse solution algorithm based on ACA, QACA, and RBF networks, and the position error increased by 3.89%, 6.19%, and 0.76%, respectively. It can be seen that the robot arm inverse solution prediction model based on the MQACA-RBF network has higher accuracy and universality, and it has the reference value for other inverse solution methods and further robot arm spatial path planning.

Data Availability
e data used to support the findings of this study are included within the article. e source program used to support the findings of this study is included within the supplementary information file.

Supplementary Materials
Running a file named "main3.m," you can get the motion track error analysis in Section 4.3 of the paper required by the simulation map and data. e folder named "matlab program for continuous function optimization problem based on basic quantum ant colony algorithm" contains the quantum ant colony algorithm for the inverse solution of the manipulator. e file, called "Q_QACA.mat," is the program running in the "matlab program for continuous function optimization problem based on the basic quantum ant colony algorithm" folder generated by the quantum ant Journal of Robotics colony algorithm to solve the manipulator inverse solution of the file. e folder named "basic ant colony algorithm continuous function optimization problem matlab program" contains the ant colony algorithm to solve the inverse solution of the robot arm program. e folder named "Q_ACA.mat" is the program in the process of "basic ant colony algorithm continuous function optimization problem matlab program" folder which generated the ant colony algorithm to solve the inverse solution of the robot arm file. e folder named "MQACA_rbf.mat" uses the RBF toolbox to model, uses quantum ant colony algorithm to optimize the output weight of RBF neural network, and calls the "matlab program for continuous function optimization problem based on basic quantum ant colony algorithm." e folder named "opt2.m" is for 2-opt local optimization. e folder named "update_all_tao.m" is for Max Min pheromone limit, and the document, called "ObjV.m," uses genetic variation and other improvements to improve the system's motion accuracy by further improving its heuristics, increasing the diversity of population and path selection. (Supplementary Materials)