# Head-Raising of Snake Robots Based on a Predefined Spiral Curve Method
## 2 Modeling of Head-Raising Motion
### Shape-Fitting and Phase-Shifting Methods  
In this section, a shape-fitting and phase-shifting algorithms are developed, and the former ensures that the snake robot adhere to the predefined spiral curve and the latter drive the robot move along with the curve. Figure 4 shows the concepts of these methods. In Figure 4, two links of robot are shown; the red one represents the robot posture at time \(t_{i}\) and the black one corresponds to the robot posture at time \(t_{i+1}\). The robot moves from posture at time \(t_{i}\) to posture at time \(t_{i+1}\), and this process is called phase-shifting. Two links contain three points; that is, the length between adjacent points equals the length of the robot links. Therefore, the snake links are calculated by point sets and represented by line segments. This process is called shape-fitting. Figure 3: Spiral curves: (**a**) the regular spiral curve, and (**b**) the predefined spiral curve used in this study. The details of how the shape-fitting and phase-shifting algorithms work are described in the following steps. Step 1: Initialization  
The parameters \(a\), \(b\), \(c\), \(n_{c}\), \(n\), \(l_{link}\), \(\hat{t}_{1}\), \(\hat{t}_{2}\), \(\hat{t}_{3}\), \(\varphi_{0}\), and \(\varphi_{base}\) are initialized. The following constraint equation is used to ensure that line segments model of the robot do not get away from the ground. \[ \begin{array}{c}S_{1}+S_{2}=\int\limits_{t=\hat{t}_{1}}^{t=\hat{t}_{2}}\sqrt {\dot{s}_{s}(t)^{2}+\dot{y}_{s}(t)^{2}+\dot{z}_{s}(t)^{2}}dt+\\ \int\limits_{t=\hat{t}_{2}}^{t=\hat{t}_{3}}\sqrt{\dot{s}_{s}(t)^{2}+\dot{y}_{s}( t)^{2}+\dot{z}_{s}(t)^{2}}dt<nl_{link}\end{array}  \tag{3}\]  
where \(S_{1}\) and \(S_{2}\) represent the arc lengths of BS and RS, respectively. Step 2: Determination of basic posture  
The snake robot is represented by line segments and the corresponding coordinate system. This section describes how the line segments of the basic posture are determined. The succeeding portion discusses the rules of building the coordinate system. The point sets used to construct the line segments are defined as follows:  
\[ \begin{array}{c}{{}^{i}P_{snk}=[{{}^{i}P_{1},{}^{i}P_{2},...,{}^{i}P_{j},.., {}^{i}P_{n+1}}]}\\ {{}^{i}P_{j}=({{}^{i}x_{snk\_j},{}^{i}y_{snk\_j},{}^{i}z_{snk\_j}})}\end{array}  \tag{4}\]  
where \({{}^{i}P_{j}}\) is the position of point \(j\) at step \(i\) of phase-shifting. \(n_{step}\) is the number of phases shifted and satisfies Equation (5). \[\sum\limits_{i=1}^{i=n_{step}}\Delta S_{i}=S_{1}+S_{2} \tag{5}\]  
where \(\Delta S_{i}\) is the arc length at step \(i\) of phase-shifting and defined as \"phase\" in this study. Therefore, shape-fitting reduces to find the point set \({{}^{i}P_{snk}}\) at step \(i\), and phase-shifting reduces to move all line segments by changing the position of \({{}^{i}P_{snk}}\) along with the predefined spiral curve. Figure 4: Concepts of shape-fitting and phase-shifting. The basic posture is considered the initial configuration before the phase-shifting begins, as shown in Figure 5 and calculated as follows. We set \(i=1\) to indicate that the line segments are in the basic posture without phase-shifting such that the point sets of the basic posture satisfy Equation (6). \[{}^{1}P_{snk}=\left[ \begin{array}{ccc}(x_{s}(\hat{t}_{1})&y_{s}(\hat{t}_{1})+ nl_{link}&0)\\ (x_{s}(\hat{t}_{1})&y_{s}(\hat{t}_{1})+(n-1)l_{link}&0)\\ \ldots&\ldots&\ldots\\ (x_{s}(\hat{t}_{1})&y_{s}(\hat{t}_{1})+(n-j+1)l_{link}&0)\\ \ldots&\ldots&\ldots\\ (x_{s}(\hat{t}_{1})&y_{s}(\hat{t}_{1})&0)\end{array}