Abstract
The solution and a portable implementation of the inverse kinematics computation of a 3 degree-of-freedom (DOF) robot manipulator using Gröbner bases are presented. The main system was written Python with computer algebra system SymPy. Gröbner bases are computed with computer algebra system Risa/Asir, called from Python via OpenXM infrastructure for communicating mathematical software systems. For solving a system of algebraic equations, several solvers (both symbolic and numerical) are used from Python, and their performance has been compared. Experimental results with different solvers for solving a system of algebraic equations are shown.
You have full access to this open access chapter, Download conference paper PDF
Similar content being viewed by others
Keywords
1 Introduction
In robotics, inverse kinematics computation is one of the central topics in motion planning [17]. In the field of computer algebra, methods of the inverse kinematics computation using Gröbner bases have been proposed ([2, 7, 22, 23], and the references therein). After formulating the forward kinematics problem using the Denavit–Hartenberg convention, the inverse kinematics problem is derived as a system of algebraic equations by conversion of trigonometric expressions to polynomials. Then, the system is triangularized by computing the Gröbner basis with respect to the lexicographic ordering and solved by appropriate solvers.
Since methods using Gröbner bases solve the inverse kinematics problem directly, these methods have advantages that one can verify if the given inverse kinematics problem is solvable (with the certification of the solution if needed), and if it is solvable, one can obtain the configuration of parameters for the desired motion of the robot directly, before the actual motion. On the other hand, the computational cost of methods using Gröbner bases tends to be high compared to that of numerical methods, thus it is desired to decrease computational cost for effective computation of solving the inverse kinematics problem using Gröbner bases. Furthermore, for the use of these methods in robotics simulators such as the Robot Operating System (ROS) [9], an implementation that can easily be integrated with these simulators is needed.
In this paper, we present the solution and a portable implementation of the inverse kinematics computation of a 3 degree-of-freedom (DOF) robot manipulator using Gröbner bases. For portable implementation and rapid development, the main program is developed in Python with computer algebra system SymPy [12]. Gröbner bases are computed effectively using computer algebra system Risa/Asir [14], connected to Python with OpenXM infrastructure for communicating mathematical software systems [10]. Then, the system of algebraic equations is solved using an appropriate solver called within Python. As the main focus of our paper, several solvers for solving a system of algebraic equations have been compared: an exact solver included in SymPy, a multivariate numerical solver using the secant method, and a univariate numerical solver with successive substitutions.
The rest of the paper is organized as follows. In Sect. 2, the method of inverse kinematics computation of a 3 DOF manipulator using Gröbner bases is explained. In Sect. 3, the description of the proposed system for solving the inverse kinematics problem is presented. In Sect. 4, the result of experiments is presented.
2 Inverse Kinematics of a 3 Degree-of-Freedom (DOF) Robot Manipulator
In this paper, an example of 3 degree-of-freedom (DOF) manipulator has been built using LEGO® MINDSTORMS® EV3 EducationFootnote 1 (henceforth abbreviated to EV3) (Fig. 1). An EV3 set has a computer (which is called “EV3 Intelligent Brick”), servo motors and sensors (gyro, ultrasonic, color and touch sensors), along with bricks used for constructing building blocks of robots. While a GUI-based programming environment for controlling the robot is available, several programming languages such as Python, Ruby, C, and Java can also be used on the top of other programming environments.
We first solve the forward kinematics problem. Components of the manipulator are defined as shown in Fig. 2. Segments (links) are called Segment i (\(i=1,2,3,4\)) from the one fixed on the ground towards the end effector, and a joint connecting Segment i and \(i+1\) is called Joint i. For Joint i, the coordinate system \(\mathrm {\Sigma }_i\), with the \(x_i\), \(y_i\) and \(z_i\) axes and the origin at Joint i, is defined according to the Denavit–Hartenberg convention [18] (Fig. 2). Note that, since the present coordinate system is right-handed, the positive axis pointing upwards and downwards is denoted by “\(\odot \)” and “\(\otimes \)”, respectively. Furthermore, let \(\mathrm {\Sigma }_0\) be the coordinate system satisfying that the origin is placed at the perpendicular foot from the origin of \(\mathrm {\Sigma }_1\), and the direction of axes \(x_0\), \(y_0\) and \(z_0\) are the same as that of axes \(x_1\), \(y_1\) and \(z_1\), respectively. Also, let Joint 5 be the end effector, and \(\mathrm {\Sigma }_5\) be the coordinate system with the origin placed at the position of Joint 5 and that the axes \(x_5\), \(y_5\) and \(z_5\) have the same direction as the axes \(x_4\), \(y_4\) and \(z_4\), respectively.
Let \(a_i\) be the distance between axes \(z_{i-1}\) and \(z_i\), \(\alpha _i\) the angle between axes \(z_{i-1}\) and \(z_i\) with respect to \(x_i\) axis, \(d_i\) the distance between axes \(x_{i-1}\) and \(x_i\), and \(\theta _i\) be the angle between axes \(x_{i-1}\) and \(x_i\) with respect to \(z_i\) axis. Then, the coordinate transformation matrix \({}^{i-1}T_i\) from the coordinate system \(\mathrm {\Sigma }_{i-1}\) to \(\mathrm {\Sigma }_i\) is expressed as
Since the joint parameters \(a_i\), \(\alpha _i\), \(d_i\) and \(\theta _i\) for EV3 are given as shown in Table 1 (note that the unit of \(a_i\) and \(d_i\) is centimeters) and the transformation matrix T from the coordinate system \(\mathrm {\Sigma }_5\) to \(\mathrm {\Sigma }_0\) is calculated as \(T={}^{0}T_1{}^{1}T_2{}^{2}T_3{}^{3}T_4{}^{4}T_5\), the position \({}^t(x,y,z)\) of the end effector with respect to the coordinate system \(\mathrm {\Sigma }_0\) is expressed as
Next, for solving the inverse kinematics problem, we solve Eq. (1) with respect to \(\theta _1\), \(\theta _2\), \(\theta _3\). With the expansion of trigonometric functions using the trigonometric addition formulas and transformation of trigonometric functions defined as
subject to \(c_1^2+s_i^2=1\), Eq. (1) is transferred to a system of algebraic equations:
Then, by putting the coordinate \({}^t(x,y,z)\) into Eq. (2) and computing Gröbner basis of an ideal \(\langle f_1,\dots ,f_6\rangle \) with respect to the lexicographic (lex) ordering, a “triangularized” system of equations is obtained. By solving the triangularized system of equations, configuration of the joint angles \(\theta _1,\theta _2,\theta _3\) are obtained.
Remark 1
We see that the ideal \(\langle f_1,\dots ,f_6\rangle \) is zero-dimensional for generic values of x, y, z, as follows. By computing the comprehensive Gröbner system [8] of \(\langle f_1,\dots ,f_6\rangle \) with parameters x, y, z and variables \(c_1,s_1,c_2,s_2,c_3,s_3\) in \(\mathbb {R}[x,y,z,c_1,s_1,c_2,s_2,c_3,s_3]\) with respect to lex order with \(c_1\succ s_1\succ c_2\succ s_2\succ c_3\succ s_3\), we have \(\{g_1,g_2,g_3,g_4,g_5,g_6\}\) as the Gröbner basis for the generic caseFootnote 2. In the generic case, we have \(\text {LM}(g_1)=s_3^4\), \(\text {LM}(g_2)=c_3\), \(\text {LM}(g_3)=s_2\), \(\text {LM}(g_4)=c_2\), \(\text {LM}(g_5)=s_1\), \(\text {LM}(g_6)=c_1\), where \(\text {LM}(g)\) denotes the leading monomial of g. This shows that the ideal is zero-dimensional for the generic case [1].
3 Implementation
We have implemented a system for the inverse kinematics computation of the manipulator in SymPy [12] on the top of Python, connecting with the computer algebra system Risa/Asir [14] via OpenXM infrastructure for communicating mathematical software systems [10].
Python (and SymPy) has been chosen for rapid development including the use of the library for solving algebraic equations, and interoperability with the Robot Operating System (ROS) [9] for embedding our present implementation as a simulation environment or an inverse kinematics solver in the future.
OpenXM (which stands for “Open message eXchange protocol for Mathematics”) consists of definitions of protocols and data formats for communication and/or interchange of mathematical information among mathematical software systems. It also includes implementation of interface for various mathematical softwares including Risa/Asir, Kan/sm1 [20], Maple [11], Mathematica [26], MixedVol [3], NTL [16], PHC Pack [25] and TiGERS [4].
Risa/Asir is used for effective computation of Gröbner bases. After receiving input polynomials from Python/SymPy, it first computes the Gröbner basis with respect to the graded reverse lexicographic (grlex) ordering. Then, it converts the basis to the one with respect to lex ordering (with a modular FGLM algorithm [14]) before returning the final result to the host program. Risa/Asir can be called from Python easily using ctypes library [15] with the OpenXM interface library for Risa/Asir.
4 Experiments
We have tested our implementation for inverse kinematics computation for randomly given points within the feasible region.
For solving a system of algebraic equations, the following solvers have been used:
-
1.
a built-in exact solver in SymPy (sympy.solvers.solvers.solve),
-
2.
a numerical solver in Python’s npmath library [6] (mpmath.findroot) using multivariate secant methodFootnote 3 (called by sympy.solvers.solvers.nsolve function in SymPy package),
-
3.
a numerical solver in Python’s NumPy package [24] (numpy.roots) solving univariate algebraic equations with successive substitutions.
For each solver, 10 sets of experiments were conducted with 100 random points given in each set of experiments (thus 1000 random points were given in total).
The computing environment is as follows.
-
Host environment. Intel Core i5-7360U 2.3GHz, RAM 8GB, macOS 10.15.1, Parallels Desktop Lite 1.4.0.
-
Guest environment. RAM 2GB, Linux 4.15.0, Python 2.7.12, SymPy 1.4, mpmath 1.1.0, numpy 1.11.0, OpenXM 1.3.3-1, Asir 20191101.
Remark 2
As shown in Remark 1, if the given point is within the feasible region, the system of algebraic equations \(g_1=\cdots =g_6=0\) has real solution(s) and can be solved rigorously, where \(\{g_1,\ldots ,g_6\}\) is the Gröbner basis of the ideal \(\langle f_1,\ldots ,f_6\rangle \) with respect to lex order.
Remark 3
For the exact computation of Gröbner bases, the coordinates of the sample points are given as rational numbers with the magnitude of the denominator is less than 100.
4.1 The Result with an Exact Solver (solve)
Table 2 shows the result of experiments with the exact solver (sympy.solvers.solvers.solve) [19]. For a system of algebraic equations, the solver computes a Gröbner basis with lex order, solve univariate equations and substitute the roots in the other equations to obtain the other coordinateFootnote 4.
In each test, \(T_\text {GB}\) is the average of computing time of Gröbner basis, \(T_\text {Solve}\) is the average of computing time for solving the system of algebraic equations, \(T_\text {Total}\) is the average of total computing time for inverse kinematics computation, and ‘Error’ is the average of absolute error of the position of the end effector with the configuration of joint angles \(\theta _1,\theta _2,\theta _3\), computed by solving the inverse kinematics problem, from the randomly given position. Note that \(T_\text {Total}\) includes the time for synchronizing received data of Gröbner basis from Risa/Asir (\(\simeq \) 1.5 s) and the time for evaluation of Error. The bottom row ‘Average’ shows the average of the values in each column of the 10 test sets.
In all the test cases, the system of algebraic equations has been rigorously solved with finding appropriate real roots, although it took much time for finding the roots. For finding joint angles \(\theta _1,\theta _2,\theta _3\), the solutions \(s_1,c_1,s_2,c_2,s_3,c_3\) have been approximated by double precision floating-point numbers for efficient use of \(\arctan \) function. We see that, though the approximation of the solution, the position of the end effector has been computed with high precision, compared to the length of the segments (Table 1).
4.2 The Result with the Multivariate Numerical Solver (nsolve)
Table 3 shows the result of experiments with the multivariate numerical solver (mpmath.findroot) [5]. The columns ‘Test’, \(T_\text {GB}\), \(T_\text {Solve}\), \(T_\text {Total}\), ‘Error’, and the bottom row ‘Average’ are the same as those in Table 2. In these sets of experiments, we have observed that the method did not converge in many cases, so the column ‘#Fail’ shows the number of tests in which the method did not converge in each test set. Note that the data in \(T_\text {GB}\), \(T_\text {Solve}\), \(T_\text {Total}\), ‘Error’ and ‘Average’ have been taken for the tests in which the method has successfully converged. The number ‘(564)’ in the ‘Average’ row and the ‘#Fail’ column shows the total number of tests in which the method did not convergeFootnote 5.
The result shows that the method did not converge in approximately half of the test cases, while, in the cases that the method converged, the method is more efficient than the exact root-finding method. It also shows that, in the cases that the method converged, the magnitude of the absolute error of the solution is approximately 10 times larger than those in the case of the exact method, which is sufficiently small for practical useFootnote 6.
4.3 The Result with the Univariate Numerical Solver (roots) with successive substitutions
Table 4 shows the result of experiments with the univariate numerical solver (numpy.roots) [21]. The columns ‘Test’, \(T_\text {GB}\), \(T_\text {Solve}\), \(T_\text {Total}\), ‘Error’, and the bottom row ‘Average’ are the same as those in Tables 2 and 3. The result shows that the method successfully converged and found appropriate solutions with sufficiently small errors in all the tests.
5 Concluding Remarks
In this paper, we have presented a portable implementation of the inverse kinematics computation of a 3 DOF robot manipulator using Gröbner bases. The implementation is made on the top of Python and SymPy with using Risa/Asir for efficient computation of Gröbner bases and symbolic and/or numerical solvers called within Python for solving a system of algebraic equations. Risa/Asir can easily be called from Python via OpenXM infrastructure.
The experiments have shown the following features of solvers used in solving the system of algebraic equations used in the present computation:
-
1.
Symbolic solver can be used for inverse kinematics computation with high accuracy with the certification of real roots, although the computing time increases.
-
2.
Multivariate numerical solver is often unstable, although it can be used to solve the inverse kinematics problem with high efficiency and accuracy in stable cases.
-
3.
Univariate numerical solver with successive substitutions is stable with high efficiency and accuracy for all the tests in the present paper.
Thus, we see that univariate numerical solver with successive substitutions is effective for solving the inverse kinematics problem in the present case, although certification of real roots may be needed.
For future research, we need to improve implementation for calling Risa/Asir from Python via OpenXM in a more sophisticated way for more efficient computation.Footnote 7 Furthermore, we intend to extend our implementation for embedding our solver in robotics simulators such as ROS and/or controlling the actual EV3 manipulators including the one we have built in the present paper.
Notes
- 1.
LEGO and MINDSTORMS are trademarks of the LEGO Group.
- 2.
We have computed the comprehensive Gröbner system on Risa/Asir using an implementation by Nabeshima [13].
- 3.
As the initial values, \((c_1,s_1,c_2,s_2,c_3,s_3)=(1,1,1,1,1,1)\) were given.
- 4.
The solver may not need a Gröbner basis of lex order as an input, but it might be better to compute beforehand for faster computation.
- 5.
We have tested the method with other initial values. With the initial values (1, 0, 1, 0, 1, 0), the number of test cases in which approximate roots do not converge was the same as the test cases with initial values (1, 1, 1, 1, 1, 1). With initial values (0, 1, 0, 1, 0, 1), the approximate roots have never converged to the roots.
- 6.
We have also applied the multivariate numerical solver to the original system of equations with initial values (1, 1, 1, 1, 1, 1), (0, 0, 0, 0, 0, 0), (1, 0, 1, 0, 1, 0) and (0, 1, 0, 1, 0, 1), and found that none of the initial values converge to true roots in all the test cases.
- 7.
At this time Risa/Asir is invoked by sending the command in the text form, with the waiting time (approximately 1.5 s) for synchronizing output data is set. We expect that this process becomes more efficient by using appropriate API for sending/receiving commands and data.
References
Cox, D.A., Little, J., O’Shea, D.: Using algebraic geometry (2005). https://doi.org/10.1007/978-1-4757-6911-1
Faugère, J.C., Merlet, J.P., Rouillier, F.: On solving the direct kinematics problem for parallel robots. Research report RR-5923, INRIA (2006). https://hal.inria.fr/inria-00072366
Gao, T., Li, T.Y., Wu, M.: Algorithm 846: mixedvol: a software package for mixed-volume computation. ACM Trans. Math. Softw. 31(4), 555–560 (2005). https://doi.org/10.1145/1114268.1114274
Huber, B., Thomas, R.R.: Computing Gröbner fans of toric ideals. Exp. Math. 9(3), 321–331 (2000). https://doi.org/10.1080/10586458.2000.10504409
Johansson, F.: mpmath developers: mpmath 1.1.0 documentation: Root-finding and optimization (2018). http://mpmath.org/doc/current/calculus/optimization.html
Johansson, F.: mpmath developers: mpmath: a Python library for arbitrary-precision floating-point arithmetic (version 1.1.0) (2018). http://mpmath.org/. Accessed 20 Mar 2020
Kalker-Kalkman, C.M.: An implementation of Buchbergers’ algorithm with applications to robotics. Mech. Mach. Theory 28(4), 523–537 (1993). https://doi.org/10.1016/0094-114X(93)90033-R
Kapur, D., Sun, Y., Wang, D.: An efficient method for computing comprehensive gröbner bases. J. Symbolic Comput. 52, 124–142 (2013). https://doi.org/10.1016/j.jsc.2012.05.015
Koubaa, A. (ed.): Robot Operating System (ROS). SCI, vol. 625. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-26054-9
Maekawa, M., Noro, M., Ohara, K., Takayama, N., Tamura, K.: The design and implementation of OpenXM-RFC 100 and 101. In: Shirayanagi, K., Yokoyama, K. (eds.) Computer Mathematics: Proceedings of the Fifth Asian Symposium on Computer Mathematics (ASCM 2001), pp. 102–111. World Scientific (2001). https://doi.org/10.1142/9789812799661_0011
Maplesoft, a division of Waterloo Maple Inc.: Maple 2020 [computer software] (2020). https://www.maplesoft.com/products/maple/. Accessed 17 Mar 2020
Meurer, A., et al.: SymPy:symbolic computing in Python. PeerJ Comput. Sci. 3 (2017). https://doi.org/10.7717/peerj-cs.103
Nabeshima, K.: An implementation of GCS algorithm for Risa/Asir. Private communication (2012)
Noro, M.: A computer algebra system: Risa/Asir. In: Joswig, M., Takayama, N. (eds.) Algebra, Geometry and Software Systems, pp. 147–162. Springer, Heidelberg (2003). https://doi.org/10.1007/978-3-662-05148-1_8
Python Software Foundation: The Python Standard Library. Python Software Foundation (2020). https://docs.python.org/3/library/. Accessed 15 Mar 2020
Shoup, V.: NTL: a library for doing number theory [computer software] (version 11.4.3) (2020). http://www.shoup.net/ntl/. Accessed 18 Mar 2020
Siciliano, B., Khatib, O. (eds.): Springer Handbook of Robotics. SHB. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-32552-1
Siciliano, B., Sciavicco, L., Villani, L., Oriolo, G.: Springer. Robotics: Modelling, Planning and Control (2008). https://doi.org/10.1007/978-1-84628-642-1
SymPy Development Team: Sympy 1.5.1 documentation: Solvers (2019). https://docs.sympy.org/latest/modules/solvers/solvers.html
Takayama, N.: Kan/sm1: a system for computing in the ring of differential operators [computer software] (1991–2003), http://www.math.kobe-u.ac.jp/KAN/. Accessed 17 Mar 2020
The SciPy community: Numpy v1.18 manual: numpy.roots (2019). https://numpy.org/doc/stable/reference/generated/numpy.roots.html
Uchida, T., McPhee, J.: Triangularizing kinematic constraint equations using Gröbner bases for real-time dynamic simulation. Multibody Syst. Dyn. 25, 335–356 (2011). https://doi.org/10.1007/s11044-010-9241-8
Uchida, T., McPhee, J.: Using Gröbner bases to generate efficient kinematic solutions for the dynamic simulation of multi-loop mechanisms. Mech. Mach. Theory 52, 144–157 (2012). https://doi.org/10.1016/j.mechmachtheory.2012.01.015
van der Walt, S., Colbert, S.C., Varoquaux, G.: The numpy array: a structure for efficient numerical computation. Comput. Sci. Eng. 13(2), 22–30 (2011). https://doi.org/10.1109/MCSE.2011.37
Verschelde, J.: Algorithm 795: PHCpack: a general-purpose solver for polynomial systems by homotopy continuation. ACM Trans. Math. Softw. 25(2), 251–276 (1999). https://doi.org/10.1145/317275.317286
Wolfram Research Inc: Mathematica, Version 12.1 [computer software] (2020). https://www.wolfram.com/mathematica. Accessed 17 Mar 2020
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
Cite this paper
Horigome, N., Terui, A., Mikawa, M. (2020). A Design and an Implementation of an Inverse Kinematics Computation in Robotics Using Gröbner Bases. In: Bigatti, A., Carette, J., Davenport, J., Joswig, M., de Wolff, T. (eds) Mathematical Software – ICMS 2020. ICMS 2020. Lecture Notes in Computer Science(), vol 12097. Springer, Cham. https://doi.org/10.1007/978-3-030-52200-1_1
Download citation
DOI: https://doi.org/10.1007/978-3-030-52200-1_1
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-52199-8
Online ISBN: 978-3-030-52200-1
eBook Packages: Computer ScienceComputer Science (R0)