# Inverse Kinematics: An Alternative Solution Approach Applying Metaheuristics
## 3 Experiments and Results
### Obtaining the IK for a Point in the Space
#### 3.1.2 Second Experiment  
In this experiment, the trajectory connecting the initial and the desired positions was discretized. So, the final solution was obtained on the basis of a series of \(k\) optimization problems, with each associated with the IK of a small segment of the complete trajectory. The solution for each of these segments was used to generate a biased population that would serve as the initial population to solve the next problem, corresponding to the next segment. For this experiment, it is proposed to establish a linear trajectory that is a common approximation in different fields, which is denoted by (15):  
\[P_{i}= \begin{pmatrix}x_{d,i}\\ y_{d,i}\\ z_{d,i}\end{pmatrix} =P_{0}+i\frac{P_{k}-P_{0}}{k} \tag{15}\]  
In this particular case, the task was divided into \(k=10\) optimization problems, that is, the same number of the runs of the first experiment to verify if it was possible to achieve a better solution with a lower total number of generations in one run with 10 simpler problems. The \(k\) optimization problems are described with (16), where \(x,y,z\) are calculated by the model generated from the homogeneous transformations. \[\min f_{i}(\vec{\theta})=\sqrt{(x(\vec{\theta})-x_{d,i})^{2}+(y(\vec{\theta})- y_{d,i})^{2}+(z(\vec{\theta})-z_{d,i})^{2}},\hskip 28.452756 pti=1,2,\ldots,k \tag{16}\]  
Figure 3: Kinematic chain when the solutions obtained in the first experiment were adopted. Original pose is shown in black, the pose with the greatest similarity in red, and the pose with the lowest error in magenta. The 10 individual results for the total solution in the test run are shown in Table 3, including the number of generations required for the calculation, whereas the corresponding graph is presented in Figure 4. Because of the size order of the values for the objective function, its values are presented in scientific notation. The total solution from the test run met the error criterion, and its distance from the original position was 1.0644, which was lower than any of the solutions obtained with the approach in the first experiment. The approach used in the second experiment produced a better result both in reducing the error when reaching the target point and in maintaining a similarity with the initial pose. In addition, the sum of generations or cycles that takes the algorithm to solve the IKP by this approach is lower than the total required in the first experiment. Figure 5 shows the best solutions generated in both experiments. Figure 4: Kinematic chain when adopting the individual results obtained for the total solution in the test run, for the second experiment. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Problem** & **Generations** & \
\begin{tabular}{c} **Objective Function** \\ **(cm)** \\ \end{tabular} &
\begin{tabular}{c} **Distance to the** \\ **Previous Pose (rad)** \\ \end{tabular} \\ \hline
1 & 7844 & \(2.9576\times 10^{-4}\) & 0.1809 \\
2 & 14,804 & \(8.7079\times 10^{-4}\) & 0.2170 \\
3 & 14,615 & \(9.1547\times 10^{-4}\) & 0.3579 \\
4 & 12,387 & \(8.4897\times 10^{-4}\) & 0.1785 \\
5 & 13,913 & \(5.5925\times 10^{-4}\) & 0.1815 \\
6 & 25,682 & \(6.9012\times 10^{-4}\) & 0.2210 \\
7 & 2800 & \(6.2471\times 10^{-4}\) & 0.1649 \\
8 & 8277 & \(6.2898\times 10^{-4}\) & 0.2034 \\
9 & 8223 & \(8.9564\times 10^{-4}\) & 0.1157 \\
10 & 8449 & \(6.7832\times 10^{-4}\) & 0.1062 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Data of the test run by the second approximation. Due to the stochastic nature of the heuristic techniques, there is a possibility that the solution shown in the test run with the second experiment represents an extraordinary or difficult case to replicate. Considering this, the experiment was replicated 10 times in order to compare the solutions found in new executions with different random values. The results are shown in Table 4 including the mean and the standard deviation. Again, because of the size order of the values for the objective function, they are presented in scientific notation. Figure 6 shows the total solutions found.