## 3 Procedure to Synthesize the IKM Using Groebner Basis
### Sixth Step: Final IKM Algorithm  
The last step of the developed procedure consists of transforming the triangular polynomial equation system of the calculated Groebner Basis in an algorithm that implements the final IKM. As was shown in the previous step, this triangular equation system can be solved in a staggered way, solving one new variable in each equation, so it is just a matter of implementing a procedure that transforms this set of equations into an executable algorithm. Table 5 shows all the possible polynomial equations that can be encountered by our procedure when computing the final IKM. The maximum possible degree of this polynomial equations is four because the Inverse Kinematic Problem of the positioning of non-redundant open-chain robotic systems has at most four solutions, as it was shown in Section 2.2. The lineal and quadratic equations that our procedure encounters are solved by the very well known algorithms for these types of polynomials. The bi-quadratic polynomial equation is solved as two concatenated quadratic equations. In addition, finally, the quartic equations that the developed procedure may encounter are solved using [PERSON]'s algorithm [30]. It is important to highlight that is not necessary to prepare for the appearance of cubic equations because the solutions of the IKP of open-chain robotic systems always come in pairs [3]. As was stated before, the variables of the obtained solution correspond to either a prismatic DoF (\(q_{j}\)) or a pair sine-cosine of a rotational DoF (\(s_{i}\) and \(c_{i}\)). Therefore, to finish the IKM synthesis of the analyzed robot, it is only necessary to compute the final value of the rotational DoFs, using the corresponding expression of the form presented in Equation (28):  
\[q_{i}=\text{atan2}\left(s_{i},c_{i}\right) \tag{28}\] \begin{table}
\begin{tabular}{c c c} \hline \hline
**Type** & **Degree** & **Polynomial** \\ \hline Lineal & 1 & \(a_{1}x+a_{0}=0\) \\ Quadratic & 2 & \(a_{2}x^{2}+a_{1}x+a_{0}=0\) \\ Bi-Quadratic & 4 & \(a_{4}x^{4}+a_{2}x^{2}+a_{0}=0\) \\ Quartic & 4 & \(a_{4}x^{4}+a_{3}x^{3}+a_{2}x^{2}+a_{1}x+a_{0}=0\) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Possible types of polynomial equations that can be encountered when solving the final basis. The output of this last step is the algorithm of the systematically generated IKM that solves all the polynomial equations obtained in the fifth step, implemented in two different languages: C++, as compiled code ready to be used in the robot's microcontroller, and MATLAB(r) script (R2017b, MathWorks(r), Natick, MA, USA). This IKM can be used directly in the robot's control system, as the generator of the references for the multi-axis control (see Figure 1), or to simulate the robot's behavior. The developed procedure can be used to synthesize the IKM in all the following types of open-chain robots [31]:  
* Cartesian robotic systems. * SCARA robots. * Non-redundant robotic manipulators that satisfy the in-line wrist condition, like the PUMA 560 presented in this work. * Non-redundant open-chain robot whose IKM should only solve the positioning problem, as is the case of most multi-legged walking robots. To demonstrate the application of this procedure to multi-legged walking robots, it was also used to synthesize the IKM of a leg of the hexapod robot shown in Figure 2. As it was said before, the user just has to give as inputs the D-H parameters of the hexapod, presented in Table 3, the restrictions of its actuators and a lexicographic order for the monomials. The selected lex order for this IKM is the one presented in Equation (29), that constitutes the same order in which the variables were solved in Section 2.2.2. \[s_{2}>c_{2}>s_{3}>c_{3}>s_{1}>c_{1} \tag{29}\]  
When the developed procedure is applied to the hexapod's leg, the output of the fifth step is the Groebner Basis presented in Equations (30) to (35).