# Path Planning Based on NURBS for Hyper-Redundant Manipulator Used in Narrow Space
## 4 The Tip-Following B-Spline Path Planning  
The realization of tip-following B-spline trajectory in a continuous path includes five parts: (1) Obtaining the marked points \(P_{1}\cdots P_{n}\) that need to pass according to the working environment. (2) Using the cubic B-spline path curve to fit the marked points, then generate a cubic B-spline path curve. (3) Obtain the working status of each UCR parallel joint according to the base feed. (4) In the B-spline path curve, obtain discrete data points corresponding to the working UCR parallel mechanism. (5) According to the driving equation of the UCR parallel joints, solve the rod length of each joint and output it. The algorithm flow chart is shown in Figure 8.  
Figure 7: Two-URC parallel mechanism. (**a**) Diagram of Two-UCR parallel joint. (**b**) Two-URC parallel mechanism shown in simulation platform. Figure 8: The flowchart of the proposed algorithm. Figure 9: Working situation of hyper-redundant manipulator. For the four-UCR parallel mechanisms, the maximum rotation angle along the \(X\)-axis is 99.36\({}^{\circ}\) and the radius of curvature is 167 mm. The maximum rotation angle along the \(Y\)-axis is 90.57\({}^{\circ}\) and the radius of curvature is 184 mm, as shown in Figure 10.  
B-spline curve is widely used in tool path fitting due to its versatility and easy realization. B-splines can be defined by control points and node vectors. Using them to represent tool paths can simplify code and reduce data storage. In addition, the B-spline itself has high continuity, and the cubic B-spline curve is G2 continuous, and the fitted trajectory  
Figure 10: Four-UCR parallel mechanisms. (**a**) along the \(X\)-axis. (**b**) along the \(Y\)-axis. (**c**) Three-dimensional model of Four-UCR parallel mechanisms. has better smoothness, and the original data points are passed to strictly guarantee the fitting accuracy. The cubic B-spline curve is defined as: \((u)=\sum_{i=0}^{n}N_{i,k}(u)P_{i},u\in[0,1]\). Where \(P_{i}(i=0,1,\cdots,n)\) is the control points. \(N_{i,k}(t)(i=0,1,\cdots,n)\) is the basis functions. \(k=3\). The node vector \(U=\{\underbrace{0,\cdots 0}_{k+1},u_{k+1},\cdots,u_{n},\underbrace{1,\cdots,1}_{k+1 }\}\). We use nonperiodic node vector, which is obtained by using a binary search on the node vector when determining the node interval to which \(u\) belongs. The trajectory of the marked points \(P_{1}\cdots P_{n}\) after fitting by the cubic B-spline curve is shown in Figure 11.  
According to the feed amount \(FD\) of the base, the motion state of each UCR parallel mechanism is sequentially judged. Assume that the end of the robot arm is the starting point of the cubic B-spline spline trajectory, and the initial length of the UCR parallel joint \(InDis\). Then, first calculate the number of UCR parallel joints in the working state: \(Num=ceil(FD/InDis)\), and the function \(ceil()\) means rounding up. Because the robotic arm starts to move from the end, the UCR parallel joint index in the working state is: \(9-Num\cdots 8\) (the index of the UCR joint is 1 to 8, respectively). The tangential direction of a B-spline curve \(c(t)\) at the discrete point is the \(Z\) axis of the point. Assuming that the parameters corresponding to two adjacent discrete points are \(t_{(n-1)}\) and \(t_{n}\), the corresponding discrete points are: \(c(t_{(n-1)})\) and \(c(t_{n})\). Then, \(Z_{(n-1)}\) and \(Z_{n}\) are unit vectors of \(c^{\prime}(t_{(n-1)})\) and \(c^{\prime}(t_{n})\), respectively. The 3D vector rotation represented by quaternion is shown in Figure 11,b. In 3D space, the unit vector n rotate \(2\theta\) can use the quaternion \(q=[\cos\theta,n\sin\theta]=q_{0}+q_{1}i+q_{2}j+q_{3}k\) to describe. Where \(n=\frac{z_{n-1}\times z_{n}}{\left|z_{n-1}\times z_{n}\right|}\), \(2\theta=\arccos(z_{n-1}*z_{n})\). The rotation matrix \({}_{n}^{n-1}R\) represented by rotation quaternion \(q=(q_{0},q_{1},q_{2},q_{3})^{T}\) is:  
\[{}_{n}^{n-1}R=\left[