## 3 Inverse Kinematics
### Closed-Form Solution for Multiple-GSJ Section
#### 3.3.1 Locations of the GSJs  
Given the desired position and orientation \(\mathbf{T}_{n}^{0}\) of the end-effector, the location of GSJ \(\mathbf{O}_{n-1}\) can be computed using Equation (4) and is given by \(\mathbf{p}_{n-1}=\mathbf{p}_{n}-l_{n}\mathbf{a}_{n}\). The location of GSJ \(\mathbf{O}_{0}\) is constant and is set as \(\mathbf{p}_{i-1}=\left[ \begin{array}{ccc}0&0&0\\ \end{array} \right]^{T}\). To determine the locations of the rest of GSJs \(\mathbf{O}_{i}\) (\(i=1,\cdots,n-2\)), a distance-based algorithm is proposed, as shown in Figure 4. This algorithm introduces two distances \(l_{y,i+1}\) and \(l_{\mathbf{O}_{i}}\) based on this information, where the \(x\), \(y\) and \(z\) coordinates of a three-dimensional point can be determined by three distances between this unknown point and another three known points. As shown in Figure 4, \(l_{v,i+1}\) represents the distance between the unknown \(\mathbf{O}_{i}\) and the known \(\mathbf{O}_{i+2}\), and \(l_{\mathbf{O}_{i}}\) represents the distance between the unknown \(\mathbf{O}_{i}\) and the known \(\mathbf{O}_{0}\). Combining \(l_{v,i+1},l_{\mathbf{O}_{i}}\) with the third known distance \(l_{i+1}\), i.e., link length, gives  
\[ \begin{array}{l}\|\mathbf{p}_{i}-\mathbf{p}_{i+1}\|^{2}=\left(l_{i+1}\right)^{2}\\ \|\mathbf{p}_{i}-\mathbf{p}_{i+2}\|^{2}=\left(l_{v,i+1}\right)^{2}\\ \|\mathbf{p}_{i}-\mathbf{p}_{0}\|^{2}=\left(l_{\mathbf{O}_{i}}\right)^{2}\end{array} . \tag{7}\]  
In fact, Equation (7) provides the basic position information for the location of GSJ \(\mathbf{O}_{i}\) according to the relative distances of four locations of GSJs, i.e., unknown \(\mathbf{O}_{i}\), known \(\mathbf{O}_{i+1}\), \(\mathbf{O}_{i+2}\), and \(\mathbf{O}_{0}\). Further calculation of Equation (7) gives a quadratic equation about the unknown \(p_{i,z}\):  
\[a\Delta(p_{i,z})^{2}+b\Delta p_{i,z}+c=0, \tag{8}\]  
where \(a=1+b_{1}^{2}+b_{2}^{2}\), \(b=-2b_{1}a_{1}-2b_{2}a_{2}\), \(c=a_{1}^{2}+a_{2}^{2}-\left(l_{\mathbf{O}_{i}}\right)^{2}\),  
\(a_{1}=\frac{p_{i+1},q_{1}-p_{i+2},q_{2}}{p_{i+2}x_{i}p_{i+1}y-p_{i+2}p_{i+2}p_ {i+1}}\), \(b_{1}=\frac{p_{i+2},p_{i+1}-p_{i+2},q_{2}p_{i+1}+z}{p_{i+2}x_{i}p_{i+1}y-p_{i+2 }p_{i+1}x}\), \(a_{2}=-\frac{p_{i+1}x_{i}A_{1}-p_{i+2},x_{2}}{p_{i+2}x_{i}p_{i+1}y-p_{i+2}y_{i+ 1}x}\), \(b_{2}=-\frac{p_{i+2}x_{i}p_{i+1}-p_{i+2}x_{i}p_{i+1}x}{p_{i+2}x_{i}p_{i+1}y-p_{ i+2}y_{i+1}x}\), \(A_{1}=\frac{\left(l_{\mathbf{O}_{i+2}}\right)^{2}\left(l_{\mathbf{O}_{i}}\right)^{2}- \left(l_{\mathbf{O}_{i+1}}\right)^{2}}{2}\), \(A_{2}=\frac{\left(l_{\mathbf{O}_{i+1}}\right)^{2}-\left(l_{\mathbf{O}_{i+1}}\right)^{2} }{2}\). Figure 4: Distance-based algorithm for determining the \(x\), \(y\), and \(z\) coordinates \(\mathbf{p}_{i}\) of the GSJs \(i\) (\(i=0,\cdots,n-1\)). Figure 3: Information flow of the proposed closed-form solution. Obviously, \(b_{1}\) and \(b_{2}\) are constant. \(a_{1}\) and \(a_{2}\) are quadratic functions about both \(l_{o,j+1}\) and \(l_{O_{i}}\). Hence, \(a\) is constant; \(b\) and \(c\) are functions about both \(l_{o,j+1}\) and \(l_{O_{i}}\), i.e., \(b=b\big{(}l_{o,j+1},l_{O_{i}}\big{)}\), \(c=c\big{(}l_{o,j+1},l_{O_{i}}\big{)}\). \(a_{1}\), \(a_{2}\), \(b_{1}\) and \(b_{2}\) exist in the situation where \(p_{i+2,x}p_{i+1,y}-p_{i+2,y}p_{i+1,x}\
eq 0\) is satisfied. Further, the \(x\), \(y\) and \(z\) coordinates of the location of GSJ \(\mathbf{O}_{i}\) is given by  
\[ \begin{array}{l}p_{i,z}=\frac{-b\pm\sqrt{\Delta}}{2a}\\ p_{i,x}=a_{1}-b_{1}p_{i,z}\\ p_{i,y}=a_{2}-b_{2}p_{i,z}\end{array} , \tag{9}\]  
where \(\Delta=b^{2}-4 ac\geq 0\), which is a function about \(l_{O_{i}}\) and \(l_{o,j+1}\), i.e., \(\Delta=\Delta\big{(}l_{o,j+1},l_{O_{i}}\big{)}\); the value of \(a\) is always nonzero because \(a\) is equal to \(1+b_{1}^{2}+b_{2}^{2}\).