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 \(\Gamma \) constrained to lie in a confining region \(R\), given a point \(p\in R\) and an initial configuration of \(\Gamma \) inside \(R\), the reachability problem for \(\Gamma \) is to determine whether \(\Gamma \) can be moved in \(R\) so that the hand of \(\Gamma \) 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].

Fig. 1
figure 1

a A planar linkage. b An arm in the plane

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\subseteq R = k[x_1,\ldots , 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 \(\bar{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 :

$$\begin{aligned} {\left\{ \begin{array}{ll} x^2+y^2+z^2=1, \\ x^2+z^2=y, \\ x=z \end{array}\right. } \end{aligned}$$

with respect to the lexical order is:

$$\begin{aligned} {\left\{ \begin{array}{ll} x-z=0, \\ -y+2z^2=0, \\ z^4+\frac{1}{2}z^2-\frac{1}{4}=0. \end{array}\right. } \end{aligned}$$

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):=\frac{m}{LT(f)}f-\frac{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’s Algorithm:

1:

Initialization: \(B:=\{\}, S:=\{f_1,\ldots , f_s\}\).

2:

While \(S\ne \{\}\) do

3:

      -pick \(f\in S, S:=S\setminus \{f\}\);

4:

      -reduce \(f\) w.r.t. \(B\)

5:

      -call \(g\) the resulting polynomial;

6:

      -if \(g\ne 0\) then put \(S:=S\cup _{b\in B}S(g,b)\); add \(g\) to \(B\)

7:

Return \(B\).

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: \(s_i=\sin \theta _i, c_i=\cos \theta _i, s=\sin \theta , c=\cos \theta \) and \(t=\tan \theta \). 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:

Main Algorithm:

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).

Fig. 2
figure 2

A planar 2-link arm with it’s global and local coordinate systems

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 \(c_i^2+s_i^2-1=0,\;i=1,2\).

2:

Find all the values of \(\theta _1\) and \(\theta _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_1c_2-s_1s_2)+l_1c_1 , l_2(s_1c_2+c_1s_2)+l_1s_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:

$$\begin{aligned} {\left\{ \begin{array}{ll} l_2(c_1c_2-s_1s_2)+l_1c_1=a, \\ l_2(s_1c_2+c_1s_2)+l_1s_1=b, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0. \end{array}\right. } \end{aligned}$$
(1)

Example 1

For the sake of simplicity in \((1-1)\) let \(l_1=l_2=1\) and \((a,b)=(1,1)\). Hence

$$\begin{aligned} {\left\{ \begin{array}{ll} c_1c_2-s_1s_2+c_1-1=0, \\ s_1c_2+c_1s_2+s_1-1=0, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0. \end{array}\right. } \end{aligned}$$

Now use CoCoA to calculate its Gröbner bases:

$$\begin{aligned} {\left\{ \begin{array}{ll} s_1+s_2-c_1=0, \\ 2s_1+s_2-1=0, \\ s_2^2+c_2-1=0, \\ \frac{1}{4}c_2=0. \end{array}\right. } \end{aligned}$$

Thus:

$$\begin{aligned} c_2=0\quad {\text { and}} \end{aligned}$$
$$\begin{aligned} (s_1=0,\,\,s_2=1 \quad {\text{ and }} \quad c_1=1)\,\, {\text { or }} \,\,(s_1=1,\quad {\text{ and }}\quad s_2=-1\quad {\text{ and }} \quad c_1=0). \end{aligned}$$

As a result \((\theta _1=90^{\circ }\quad {\text {and}} \quad \theta _2=270^{\circ })\) or \((\theta _1=0^{\circ }\quad {\text {and}} \quad \theta _2=90^{\circ })\).

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 the origin of the circle

To reach a point in the circle, joint 2 and hand (Fig. 2) must be inside the circle. Thus for the given circle with radius \(m>0\), there are two certain constraints:

$$\begin{aligned} {\left\{ \begin{array}{ll} l_1\le m,\\ (l_2(c_1c_2-s_1s_2)+l_1c_1)^2+(l_2(s_1c_2+c_1s_2)^2\le m^2. \end{array}\right. } \end{aligned}$$

Thus we have to add the following equation to (1) with \(t\ge 0\), to find all the values of \(\theta _1\) and \(\theta _2\) (if there exist any).

$$\begin{aligned} l_1^2+l_2^2+2l_1l_2(s_1(s_1c_2+c_1s_2)+c_1(c_1c_2-s_1s_2))-m^2+t=0 \end{aligned}$$

with \(t\ge 0\) to find all the values of \(\theta _1\) and \(\theta _2\).

Reachability when the shoulder is not the origin of the circle

Let the vector \(\vec {v}\) 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:

Fig. 3
figure 3

The shoulder of arm and the origin of circle are not the same

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:

$$\begin{aligned} {\left\{ \begin{array}{ll} l_2(c_1c_2-s_1s_2)+l_1c_1=a, \\ l_2(s_1c_2+c_1s_2)+l_1s_1=b, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0,\\ l_1^2+l_2^2+2l_1l_2(s_1(s_1c_2+c_1s_2)+c_1(c_1c_2-s_1s_2))-m^2+t=0. \end{array}\right. } \end{aligned}$$
(2)
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:

$$\begin{aligned} {\left\{ \begin{array}{ll} l_2(c(c_1c_2-s_1s_2)-s(s_1c_2+c_1s_2))+l_1(cc_1-ss_1)=a, \\ l_2(s(c_1c_2-s_1s_2)+c(s_1c_2+c_1s_2)+l_1(sc_1+cs_1)=b,\\ c_1^2+s_1^2-1=0,\\ c_2^2+s_2^2-1=0, \\ l_1^2+2l_1|\vec {v}|c_1+|\vec {v}|^2-m^2+t_1=0,\\ l_1^2+l_2^2+2l_1|\vec {v}|c_1+2l_2|\vec {v}| (c_1c_2-s_1s_2) \\ \quad +2l_1l_2(c_1^2c_2-c_1s_1s_2+cs(s_2-s_1)(c_1c_2-s_1s_2)+(s_1c_2+c_1s_2) (s^2s_1+c^2s_2) \\ \quad +|\vec {v}|^2-m^2+t_2=0. \end{array}\right. } \end{aligned}$$
(3)

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\ge 0, |\vec {v}|, c\) and \(s\) are given and \(s_1,c_1,s_2\) and \(c_2\in {\mathbb {R}}\) are variables. Using the Gröbner bases, we can find the values of \(\theta _1\) and \(\theta _2\).

Example 2

Let C be a circle with radius 3 and \(\Gamma \) be a 2-link arm with \(l_1=1\) and \(l_2=2\) and \((a,b)=(1,1)\). Then the system to be solved is:

$$\begin{aligned} {\left\{ \begin{array}{ll} 2(c_1c_2-s_1s_2)+c_1-1=0, \\ 2(s_1c_2+c_1s_2)+s_1-1=0, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0, \\ 4+4(s_1(s_1c_2+c_1s_2)+c_1(c_1c_2-s_1s_2))-9+t=0. \end{array}\right. } \end{aligned}$$

CoCoA calculates its Groebner basis as follows:

$$\begin{aligned} {\left\{ \begin{array}{ll} -\frac{1}{2}c_1+\frac{1}{2}s_1+s_2=0, \\ s_1+s_2+\frac{1}{4}=0, \\ s_2^2+\frac{1}{2}c_2-\frac{1}{16}=0, \\ \frac{1}{2}c_2-\frac{3}{8}=0, \\ -\frac{1}{4}t+2=0. \end{array}\right. } \end{aligned}$$

Example 3

In Fig. 3, suppose that \(l_1=1, l_2=2, \theta =0^{\circ }, |v|=0.5, (a,b)=(1,1)\) and \(m=4\):

$$\begin{aligned} {\left\{ \begin{array}{ll} 2(c_1c_2-s_1s_2)+c_1-3=0, \\ 2(s_1c_2+c_1s_2)+s_1-3=0, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0, \\ c_1+t_1-14.75=0,\\ c_1+5+2(c_1c_2-s_1s_2)+4(c_1^2c_2-s_1s_2c_1)+s_2(s_1c_2+c_1s_2)+t_2-15.75=0. \end{array}\right. } \end{aligned}$$

Gröbner bases now gives the following easy system:

$$\begin{aligned} {\left\{ \begin{array}{ll} c_1+t_1-\frac{59}{4}=0, \\ \frac{3}{2}s_1+s_2+\frac{3}{2}t_1-\frac{177}{8}=0, \\ -\frac{9}{4}s_2-\frac{9}{4}c_2-\frac{27}{4}t_1+\frac{1575}{16}=0, \\ s_2+3t_1-\frac{81}{2}=0, \\ \frac{29}{32}t_1-\frac{1}{4}t_2-\frac{1475}{128}=0, \\ \frac{64}{841}t_2^2-\frac{364}{841}t_2+\frac{11289}{6728}=0. \end{array}\right. } \end{aligned}$$

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, \(\theta \) is constant but distance between 0 and point 1 can vary between 0 and \(|L|\) 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 \(|\vec {v}|\) into \(u\) and consider \(u\) as a variable.

Reachability when the shoulder can move along a known path

In this case it suffices to parameterize the path in the \((x,y)\)-coordinate where the shoulder of the arm has to move along it. On the other hand, if the equation of the path is of the form \(y=f(x)\), the coordinate of point 1 (shoulder), point 2, and the end point 3 (hand) of the arm in the \((x,y)\)-coordinate system are respectively as follows:

$$\begin{aligned} (x,y)=(x,f(x))=(r\cos \theta , f(r\cos \theta )), \end{aligned}$$
$$\begin{aligned} (x,y)=(l_1\cos (\theta +\theta _1)+ r\cos \theta , l_1\sin (\theta +\theta _1)+f(r\cos \theta ), \end{aligned}$$
$$\begin{aligned} \left( x,y \right) = \left( \sum_{i=1}^{3}l_i\cos \left( \theta+\sum_{j=1}^i \theta_j \right)+r \cos \theta , \sum_{i=1}^3 l_i\sin \left( \theta+\sum_{j=1} ^ {i} \theta_{j} \right) +f \left( r \cos \theta \right) \right). \end{aligned}$$

It is clear that by using the parametrization \(x=r\cos \theta \) and \(y=r\sin \theta \) and \(y=f(x)\), one can compute \(r\) with respect to \(\theta \) 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 parabola

For the sake of simplicity take the path \(y=x^2\), so by using parametrization, we have \(r=\frac{sin\theta }{cos^2\theta }\) and thus the coordinate of point 1 is \((x,y)=(x,x^2)=(\tan \theta , \tan ^2\theta )\), the coordinate of point 2 is \((x,y)=(l_1\cos (\theta +\theta _1)+ \tan \theta , l_1\sin (\theta +\theta _1)+\tan ^2\theta )\) and the coordinate of point 3 is \((x,y)=(l_2\cos (\theta +\theta _1+\theta _2)+l_1\cos (\theta +\theta _1)+ \tan \theta , l_2\sin (\theta +\theta _1\theta _2)+l_1\sin (\theta +\theta _1)+\tan ^2\theta )\). Therefore \(\tan \theta \) and \(r\) are new variables that must be substituted with \(x, y\) (the previous variables); see Fig. 4.

Fig. 4
figure 4

A 2-link arm when shoulder can move along the parabola \(y=x^2\)

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\ne 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.

Fig. 5
figure 5

A 2-link arm when shoulder can move along the circle C

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

$$\begin{aligned} {\left\{ \begin{array}{ll} l_2(c(c_1c_2-s_1s_2)-s(s_1c_2+c_1s_2))+l_1(cc_1-ss_1)=a, \\ l_2(s(c_1c_2-s_1s_2)+c(s_1c_2+c_1s_2))+l_1(sc_1-cs_1)=b, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0. \end{array}\right. } \end{aligned}$$
(4)

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:

$$\begin{aligned} {\left\{ \begin{array}{ll} l_2(c(c_1c_2-s_1s_2)-s(s_1c_2+c_1s_2))+l_1(cc_1-ss_1)=a, \\ l_2(s(c_1c_2-s_1s_2)+c(s_1c_2+c_1s_2))+l_1(sc_1-cs_1)=b, \\ ct-s=0, \\ t-rc=0, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0. \end{array}\right. } \end{aligned}$$
(5)
3:

If the joint can move along a circle, then the new system to be solved is:

$$\begin{aligned} {\left\{ \begin{array}{ll} l_2(c(c_1c_2-s_1s_2)-s(s_1c_2+c_1s_2))+l_1(cc_1-ss_1)=a, \\ l_2(s(c_1c_2-s_1s_2)+c(s_1c_2+c_1s_2))+l_1(sc_1-cs_1)=b, \\ c^2+s^2-1=0, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0. \end{array}\right. } \end{aligned}$$
(6)

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:

$$\begin{aligned} {\left\{ \begin{array}{ll} 2(c_1c_2-s_1s_2)+c_1-2=0, \\ -2(s_1c_2+c_1s_2)-s_1-2=0, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0. \end{array}\right. } \end{aligned}$$

Using CoCoA we calculate its Gröbner bases as follows:

$$\begin{aligned} {\left\{ \begin{array}{ll} s_1+s_1+c_1=0, \\ 2s_1+s_2+\frac{5}{4}=0, \\ \frac{1}{2}s_2^2+c_2-\frac{31}{32}=0, \\ -\frac{1}{2}c_2+\frac{3}{8}=0. \end{array}\right. } \end{aligned}$$

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 2-link 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 \(|V|\). We choose an order on \(V\) by rotative plane sweep. Define \(D_i\) to be the segment between \(q\) and the \(i\)-th element of the ordered set \(V\), let \(m_i\) be the inclination of \(D_i\) and also define \(\alpha _i\) to be the angle between \(D_i\) and \(D_{i+1}\) in \(q\), i.e. \(\alpha _i=\tan ^{-1}\left( \frac{m_i-m_{i+1}}{1+m_im_{i+1}}\right) \). Then \(\sum _{i=1}^{|V|} \alpha _i=2\pi \), 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:

Fig. 6
figure 6

\(P\) with a given point \(q\) inside (in the left) and a 2-link arm inside \(P\) (in the right)

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,\ldots , |V_1|\), 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,\ldots , |V_2|\), do

6:

   Compute \(m^{\prime }_i\), the inclination of \(D^{\prime }_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_i^2+s_i^2-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:

$$\begin{aligned} {\left\{ \begin{array}{ll} l_2(c_1c_2-s_1s_2)+l_1c_1=a, \\ l_2(s_1c_2+c_1s_2)+l_1s_1=b, \\ c_1^2+s_1^2-1=0, \\ c_2^2+s_2^2-1=0,\\ \sum _{i=1}^{|V|} \tan ^{-1}\left( \frac{m_i-m_{i+1}}{1+m_im_{i+1}}\right) =2\pi ,\\ \sum _{i=1}^{|V|} \tan ^{-1}\left( \frac{m_i^{\prime }-m_{i+1}^{\prime }}{1+m_i^{\prime } m_{i+1}^{\prime }}\right) =2\pi . \end{array}\right. } \end{aligned}$$
(7)

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=\{\}\) 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.

Fig. 7
figure 7

A polygon \(P\) with a hole, \(p\) is inside \(P\) and \(q\) is in 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].