Algorithms for solving reachability problems in 2-link planar arms using Gröbner bases

AbstractIt is a crucial problem to study the reachability of planar arms inside convex obtuse polygons. In this paper, we studied the reachability problem for 2-link planar arms inside a circle, a general polygon with (without) some holes in it and presented several algorithms for them. Furthermore, we proposed some algorithms for a special case where the shoulder of an arm moves along a given segment or passes through a certain path. It is essential to mention that our approach is based on the Gröbner bases technique
.


Introduction
A linkage is a collection of rigid rods called links. The endpoints of various links are connected by joints, each joint connecting two or more links. The links are free to rotate around the joints.
An arm is a simple type of linkage consisting of a sequence of links joined together consecutively with the location of one end fixed which is called shoulder and the other mobile end called hand; see Fig. 1.
For an arm C constrained to lie in a confining region R, given a point p 2 R and an initial configuration of C inside R, the reachability problem for C is to determine whether C can be moved in R so that the hand of C reaches p.
Reachability problem has been studied independently by several researchers. In Pei [11], has studied the reachability problem for a planar chain within two type of confining regions: convex obtuse polygons and circles, and the reachability problem for a planar arms inside a convex obtuse polygon has to be investigated by readers.
The method of Gröbner bases is meanwhile well established as one of the fundamental algorithmic tools in polynomial algebra and algebraic geometry; see [5] and [6].
Gröbner bases enable us to solve problems about polynomial ideals in an algorithmic or computational fashion. In its basic version, it deals with multivariate polynomials over a field k. It assigns to any finite set F R ¼ k½x 1 ; . . .; x n another such set G (a Gröbner bases) such that G and F generate the same ideal in R, and such that many problems related to F and its zeros in an algebraically closed extension field " k can be solved algorithmically using G. Thus the computation of G serves as a preprocessing step (of potentially high complexity) in the solution of these problems. The construction of G depends on F and on a term-order \ on R; see [12]. If G is taken minimal in a suitable sense (i.e., G is a reduced Gröbner bases) then G is even uniquely determined by the ideal generated by F and order lessthan. For example, the Gröbner basis of the following system of polynomials: with respect to the lexical order is: The produced Gröbner bases has the remarkable and useful property that it is ''triangularized'', that is, its third equation depends only on z and by substituting the values of z into the second and first equations, they can be solved uniquely for y and x, respectively. Thus by [Proposition 9, 5], we have found all solutions of the original equations. Of course, in this simple example, the solution could also be derived by a reasonably skillful analysis. However, the Gröbner bases algorithm works in all situations and always results in a ''triangularized'' system [7]. Buchberger in [7] and Cox et al. in [9] considered a recent application of concepts and techniques from algebraic geometry in areas of computer science. It has developed a systematic approach that uses algebraic varieties to describe the space of possible configuration of mechanical linkages such as robot arms and used this approach to solve the forward and inverse kinematic problems of robotics for certain types of robots. In other words, the inverse kinematic problem for the planar robot arm is defined as the reachability problem for that arm in computational geometry.
Although the computation of Gröbner bases is known to be EXPSPACE-complete problem [2], in this paper we use Gröbner bases to effectively solve several reachability problems only for 2-link planar arms. In the course of computing Gröbner bases by Buchberger's algorithm, one has to compute and reduce numerous so called S-polynomials. Since these reductions are costly and the number of S-polynomials may be quite large and may, in fact, increase in the course of the algorithm, the overall computation time may be quite high. In fact, in [3] and [4], some criteria are given by which the number of S-polynomials to be considered in the course of the algorithm is reduced drastically. All practical implementations of Buchberger's algorithm make heavy use of these criteria. To be precise let f and g be two polynomials and m be the lcm of their leading monomials, then the S-polynomial of f and g is denoted by Sðf ; gÞ and defined as Sðf ; gÞ :¼ m LTðf Þ f À m LTðgÞ g.
In the univariate case, Sðf ; gÞ corresponds to the first step in the Euclidean division of f by g.
Buchberger proved in his Ph.D thesis (in 1965) that this algorithm terminates and produces Gröbner bases. One of the main difficulties with an actual implementation is that the reduction steps often produce 0 and a lot of time is wasted during these useless reductions. Fortunately, there are many strategies to pick elements in S and predict useless reductions in advance.
Throughout this paper we use the following notations: The procedures we include in this work are encoded in the Computer Algebra package CoCoA [8].
The organization of this paper is as follows. In the following section, we present a general view of our algorithm for the reachability problem for the 2-link planar arm and call appropriate partial algorithms. Then we study our partial algorithms more briefly followed by the reachability problem for 2-link planar arms without confining region. The next sections are devoted to the reachability problem for 2-link planar arms inside the circle, the reachability problem for 2-link planar arms when its shoulder moves and the reachability problem for planar arms inside a general polygon. The final section consists of conclusions and future works.

Our algorithm for reachability problem for 2-link planar arms
In this section we present an algorithm for the reachability problem for 2-link planar arms. First we detect the desired partial algorithm and then the appropriate routine is called: If there is no confining region for the 2-link planar arms, then use Partial Algorithm 1.
If the 2-link planar arms is inside the circle, then use Partial Algorithm 2.
If the shoulder of the 2-link planar arms moves, then use Partial Algorithm 3.
If the confining region for the 2-link planar arms is a polygon, then use Partial Algorithm 4. Reachability problem for 2-link planar arms without confining region Consider a general planar robot arm with two joints (see Fig. 2). Using a standard rectangular coordinate system, by ðx 1 ; y 1 Þ, we mean the origin of the coordinate system which is placed at the shoulder of the robot arm. In addition call three local rectangular coordinate systems ðx 2 ; y 2 Þ; ðx 3 ; y 3 Þ and ðx 4 ; y 4 Þ at shoulder, joint 2, and hand respectively. This coordinate system changes as the position of the arm varies. Take the positive x 2 -axis to be the direction of link 1 and the positive x 3 -axis and x 4 -axis to be the direction of link 2. Then the positive y 2 -axis, y 3 -axis and y 4 -axis are determined to form normal right-handed rectangular coordinate systems. Note that the ðx 2 ; y 2 Þ coordinate of joint 2 is ðl 1 ; 0Þ, where l 1 is the length of link 1 and the ðx 3 ; y 3 Þ and ðx 4 ; y 4 Þ coordinates of hand is ðl 2 ; 0Þ and ð0; 0Þ, where l 2 is the length of link 2.
Partial Algorithm 1: Task: Reachability for 2-link planar arms without confining region. Steps: 1 Find the ðx 1 ; y 1 Þ coordinate of hand which is a function of c i and s i subject to the constraints Find all the values of h 1 and h 2 that cause the hand of arm to reach the given point p ¼ ða; bÞ: For this we need to know if p can reach to ðl 2 ðc 1 c 2 À s 1 s 2 Þþ l 1 c 1 ; l 2 ðs 1 c 2 þ c 1 s 2 Þ þ l 1 s 1 Þ. This is done by solving the system of equations in the next step. 3 Apply Groebner basis to solve the following system of equations: Example 1 For the sake of simplicity in ð1 À 1Þ let l 1 ¼ l 2 ¼ 1 and ða; bÞ ¼ ð1; 1Þ. Hence Now use CoCoA to calculate its Gröbner bases: Thus:

Reachability problem for 2-link planar arms inside the circle
We study this problem in two subcases when the shoulder is the origin of the circle and when it is not.  Reachability when the shoulder is not the origin of the circle Let the vector ṽ be the translation vector from the point 0 (the origin of the circle) to point 1 (the shoulder of the arm), we use the above-mentioned argument stated in 1 to the new coordinate system ðx; yÞ with the origin 0 (see Fig.  3). We summarize this observation in the following: Partial Algorithm 2: Task: Reachability when the shoulder is (or is not) the origin of a circle with radius m [ 0. Steps: 1 If the 2-link planar arms is inside the circle and the shoulder is the origin of the circle, then apply Groebner basis to solve the following system of equations: 2 If the 2-link planar arms is inside the circle and the shoulder is not the origin of the circle, then apply Groebner basis to solve the following system of equations: l 2 ðcðc 1 c 2 Às 1 s 2 ÞÀsðs 1 c 2 þc 1 s 2 ÞÞþl 1 ðcc 1 Àss 1 Þ¼a; l 2 ðsðc 1 c 2 Às 1 s 2 Þþcðs 1 c 2 þc 1 s 2 Þþl 1 ðsc 1 þcs 1 Þ¼b; c 2 1 þs 2 1 À1¼0; c 2 2 þs 2 2 À1¼0; l 2 1 þ2l 1 jṽjc 1 þjṽj 2 Àm 2 þt 1 ¼0; l 2 1 þl 2 2 þ2l 1 jṽjc 1 þ2l 2 jṽjðc 1 c 2 Às 1 s 2 Þ þ2l 1 l 2 ðc 2 1 c 2 Àc 1 s 1 s 2 þcsðs 2 Às 1 Þðc 1 c 2 Às 1 s 2 Þ þðs 1 c 2 þc 1 s 2 Þðs 2 s 1 þc 2 s 2 Þ þjṽj 2 Àm 2 þt 2 ¼0: The last condition is obtained after some simplifications for considering the translation vector from the point 0 (the origin of the circle) to point 1. Note that for t 1 ; t 2 ! 0; jṽj; c and s are given and s 1 ; c 1 ; s 2 and c 2 2 R are variables. Using the Gröbner bases, we can find the values of h 1 and h 2 .
Example 2 Let C be a circle with radius 3 and C be a 2link arm with l 1 ¼ 1 and l 2 ¼ 2 and ða; bÞ ¼ ð1; 1Þ. Then the system to be solved is: CoCoA calculates its Groebner basis as follows: Example 3 In Fig. 3, suppose that l 1 ¼ 1; l 2 ¼ 2; h ¼ 0 ; jvj ¼ 0:5; ða; bÞ ¼ ð1; 1Þ and m ¼ 4: Gröbner bases now gives the following easy system: Reachability problem for 2-link planar arms when its shoulder moves We study three special cases: The shoulder of the 2-link planar arms moves along a segment.
The shoulder of the 2-link planar arms moves along a parabola.
The shoulder of the 2-link planar arms moves along a circle.
Reachability when the shoulder can move along a segment Suppose that point 1 (the shoulder) can move along a segment L. Define a global coordinate system at the first point of the segment L. Then as in Fig. 4, h is constant but distance between 0 and point 1 can vary between 0 and jLj along L, which we call u. Thus u is another variable that must be added to previous variables. Hence the system for solving is the same as (1), just we have to change jṽj into u and consider u as a variable.
It is clear that by using the parametrization x ¼ r cos h and y ¼ r sin h and y ¼ f ðxÞ, one can compute r with respect to h and then use it in the above equations.
Here we show this in two important cases and the idea for the general case will follow.

Reachability problem for 2-link planar arm when the path is a circle
For a 2-link planar arm whose shoulder can move along the circle C with radius r 6 ¼ 0, the problem would be reduced to the 3-link planar arm that its shoulder is the origin of ðx; yÞ-plane (see Fig. 5). Hence we have the following algorithm.
Partial Algorithm 3: Task: Reachability when the shoulder can move. Steps: 1 If there is no confining region around the arm, and the joint 1 can move along segment L, then we have the following system Now we can apply Partial Algorithm 2. 2 If the joint can move along a parabola, then the new system to solve the reachability of the hand of arm to a given point p ¼ ða; bÞ is: 3 If the joint can move along a circle, then the new system to be solved is: Example 4 For a 2-link arm with l 1 ¼ 1 and l 2 ¼ 2 which moves along the line x ¼ 0 in order to reach the point ða; bÞ ¼ ð2; 2Þ we have to solve the following sysytem: Using CoCoA we calculate its Gröbner bases as follows: Reachability problem for planar arms inside a general polygon We study this problem in two steps: 1. The confining region for the 2-link planar arms is a polygon without hole. 2. The confining region for the 2-link planar arms is a polygon with holes. Reachability when the confining region is a polygon without any hole Suppose that the confining region is a polygon P, the 2link arm (Fig. 2), the global coordinate system ðx 1 ; y 1 Þ, the local coordinate systems ðx 2 ; y 2 Þ; ðx 3 ; y 3 Þ and ðx 4 ; y 4 Þ are defined as in section ''Reachability problem for 2-link planar arms without confining region''. Further assume that p ¼ ða; bÞ in ðx 1 ; y 1 Þ system is given. Let q be a point somewhere inside P and V be the set of vertices of P which are visible from q, as usual its cardinal is denoted by jVj. We choose an order on V by rotative plane sweep. Define D i to be the segment between q and the ith element of the ordered set V, let m i be the inclination of D i and also define a i to be the angle between D i and 1þm i m iþ1 . Then P jVj i¼1 a i ¼ 2p, which we call it Visibility Condition in the following. One can independently write this conditions for joint 2 and hand and do the same as before (see Fig. 6). Hence we have the following algorithm: Partial Algorithm 4: Task: Reachability for 2-link planar arms inside a polygon without holes. Steps: 1 Find V 1 , the set of vertices that are visible from joint 2.
2 Find V 2 , the set of vertices that are visible from hand (joint 3). 3 For each i ¼ 1; . . .; jV 1 j, do 4 Compute m i , the inclination of D i (the segment between joint 2 and the i-th element of V 1 ). 5 For each i ¼ 1; . . .; jV 2 j, do 6 Compute m 0 i , the inclination of D 0 i (the segment between hand and the i-th element of V 2 ). 7 Find the ðx 1 ; y 1 Þ coordinate of hand which is a function of c i and s i subject to the constraints c 2 i þ s 2 i À 1 ¼ 0; i ¼ 1; 2. 8 Add the visibility conditions to the system of equations in (1). 9 Apply Groebner basis to solve the following system of equations: Reachability when the confining region is a polygon with some holes We explain the problem for polygon P with only one hole. It is easy to check that this method can be used for polygons with more than one hole. Suppose that the confining region is a polygon P with a hole. For any point p in P, we define V to be the set of all vertices in P that are visible from p and are not on the boundary of the hole. It is obvious that if p is in the hole (like q), then it can not see any vertex of the boundary of P except the hole boundary, so in this case V ¼ fg and we do not meet the condition of section ''Reachability when the shoulder can move along a segment'' (see Fig. 7). Otherwise we are able to find all the arm joints that are in P. Hence in this case Partial Algorithm 4 can be applied directly except that V 1 (resp. V 2 ) are defined as the set of all vertices in P that are visible from joint 2 (resp. hand) and are not on the boundary of the hole.

Conclusions and future works
We studied and presented several algorithms for the reachability problem inside the circle, a general polygon with/without some holes for 2-link planar robot arms. Also we considered the case that the shoulder of arm can move along a given segment, circle, parabola or a certain path.
For an unknown path it should be work out more seriously. Furthermore the method could be extended to a 3-dimensional space when joints are spherical by using Euler matrix [1].
Acknowledgments The authors are grateful to the referee for his/ her comments and suggestions. The second author is also thankful to the Elite National Foundation of Iran for partial financial support.
Open Access This article is distributed under the terms of the Creative Commons Attribution License which permits any use,