# Optimal Collision-Free Grip Planning for Biped Climbing Robots in Complex Truss Environment
## 5 Gait Interpreter
\(cR\Leftarrow GatisInfo.cR\) ; // The orientation for gripping \(cMem\) \(y\Leftarrow GatisInfo.y\) ; // The gripping position in the landing segment \(x\Leftarrow GatisInfo.x\) ; // The gripping position in the takeoff segment StepLen \(\Leftarrow\) CalculateStepLength(\(GatisInfo,y\)); \(t_{insert}\Leftarrow y+StepLen\); ifCheckKinematics(\(y,x,t_{insert}\)) \(\
eq true\)then \(t_{insert}\Leftarrow y-StepLen\); ifCheckKinematics(\(y,x,t_{insert}\)) \(\
eq true\)then return\(Grips\Leftarrow\emptyset\); else return\(Grips\Leftarrow\) GenerateGrip(\(cR,cMem,y,t_{insert},x\));  end if else return\(Grips\Leftarrow\) GenerateGrip(\(cR,cMem,y,t_{insert},x\));  end if
```
**Algorithm 2**InchwormG Gait: generating grips for the inchworm-like gait

Algorithm 3 is the implementation of the sub-function HybGait, in charge of generating grips for the hybrid gait. To climb with the hybrid gait, two extra grips need to be inserted. According to Section 4.2.1, every hybrid gait contains an inchworm-like gait. Therefore, one of these two grips will be solved firstly, then the function InchwormGait is called to generate another. The direction \(InsDir\) of inserting first grip is firstly initialized. Based on the distance between \(y\) and \(x\), two different strategies are used by the algorithm. If this distance is in the range of \((S_{1},S_{2})\), an offset \(Offset\) is calculated with the function CalculateOffset according to \(GatisInfo\) and \(InsDir\). Then \(t_{insert}\) can be solved easily. The other grip \(Grips_{new}\) can be obtained by calling the function InchwormGait. If \(Grips_{new}\) is empty, \(Offset\) will be updated by changing to another side to insert the grip. Then InchwormGait is called again. If this operation successes, \(Grips\) between \(t_{insert}\) and \(x\) are generated by the function GenerateGrip. Otherwise, the robot cannot reach the destination via this route. If the moving distance is in \((S_{3},S_{4})\), two grips always can be inserted between \(y\) and \(x\) successfully since there is enough adjustment space. In the case of \(SaFo\) gait, \((\lceil S_{i}/S_{2}\rceil-1)\) grips are distributed uniformly between the initial and finished gripping position. Verifications of kinematics and collision avoidance should be applied to each step. ```
Input :\(cMem\): The current member where the robot climbing on; \(GatisInfo\): The information of the hybrid gait. Output :\(Grips\): The grip sequence of the hybrid gait. \(cR\Left GaitsInfo.cR\) ; // The orientation for gripping \(cMem\) \(y\Left GaitsInfo.y\); \(x\Left GaitsInfo.x\) ; \(MovDir\Left InitializeMoveDirection(y,x)\) ; // Initialize the direction if\(|x-y|\in(S_{1},S_{2})\)then \(GatisInfo_{new}\Left GaitsInfo\); \(OffSet\Left CalculateOffSet(GatisInfo,MovDir,y)\); \(t_{insert}\Left y+OffSet\); \(GatisInfo_{new}.y\Left t_{insert}\); \(Gris_{new}\Left InchwormGait(cMem,GatisInfo_{new})\) ; // Algorithm 2 if\(Gris_{new}=\emptyset\)then \(GatisInfo_{new}\Left GaitsInfo\); \(OffSet\Left CalculateOffSet(GatisInfo,-MovDir,y)\); \(t_{insert}\Left y+OffSet\); \(GatisInfo_{new}.x\Left t_{insert}\); \(Gris_{new}\Left InchwormGait(cMem,GatisInfo_{new})\) ; // Algorithm 2 if\(Gris_{new}=\emptyset\)then return\(Grips\Left\emptyset\) else \(Grips\Left Grips_{new}\); return\(Grips.AddGrip(GenerateGrip(cR,cMem,t_{insert},x))\);  end if else \(Grips\Left GenerateGrip(cR,cMem,y,t_{insert})\); return\(Grips.AddGrip(Grips_{new})\);  end if else \(GatisInfo_{new}\Left GaitsInfo\); \(OffSet\Left CalculateOffSet(GatisInfo,MovDir)\); \(t_{insert}\Left y+OffSet\); \(GatisInfo_{new}.x\Left t_{insert}\); \(Grips\Left InchwormGait(cMem,GatisInfo_{new})\); return\(Grips.AddGrip(GenerateGrip(cR,cMem,t_{insert},x))\);  end if
```

**Algorithm 3**HybGait: generating grips for the hybrid gait

## 6 Simulation

To verify the proposed analysis and algorithms, simulations are conducted with Climbot. A simulation environment is developed, and algorithms are implemented on the platform of MATLAB R2015b.