## 3 State Machine Strategy Based on FASM Stabilization Criterion  
### Robot Tipping and Instability Determination  
When the hexapod robot walks in the quadrupedal gait, it is subjected to the action of gravity, inertial force, external disturbance force, and foot-end touchdown force. According to the Alembert principle, by conducting the dynamic analysis of the hexapod robot, the force and moment balance equations can be obtained as follows:  
\[\sum f_{gra}+\sum f_{iner}+\sum f_{con}+\sum f_{ext}=0 \tag{9}\]  
\[\sum f_{gra}+\sum f_{iner}+\sum f_{con}+\sum f_{ext}=0 \tag{10}\]  
where \(f_{grav}\), \(n_{grav}\) are the gravitational force of the robot and the moment generated by gravity, respectively; \(f_{iner}\), \(n_{iner}\) are the inertial force and inertial moment, respectively; \(f_{con}\), \(n_{con}\) are the contact force and contact moment between the foot-end and the ground, respectively; and \(f_{ext}\), \(n_{ext}\) are the external disturbance force and disturbance moment, respectively. By transforming the above formula, the resultant force and resultant moment that cause the robot to become unstable are obtained as follows:  
\[f_{r}=\sum f_{grav}+\sum f_{ext}+\sum f_{iner}=-\sum f_{con} \tag{11}\]  
\[n_{r}=\sum n_{grav}+\sum n_{ext}+\sum n_{iner}=-\sum n_{con} \tag{12}\]  
When the hexapod robot is in the motion state, the footholds of the legs in contact with the ground form a support polygon on the support surface. \({}^{C}P_{i}=\left[{}^{C}P_{i^{c}}\,{}^{C}P_{i^{y}}\,{}^{C}P_{iz}\right]^{T}\) represent the position vector of the foothold \(i\) in the body coordinate system. The lines connecting adjacent footholds are selected as the possible overturning axes of the body to form the support polygon. The overturning axis \(i\) is denoted as:  
\[\left\{\begin{array}{l}a_{i}={}^{C}P_{i+1}-{}^{C}P_{i}\\ a_{k}={}^{C}P_{1}-{}^{C}P_{k}\end{array}\right.,i=1,2\ldots k-1 \tag{13}\]  
where \(k\) is the number of feet in contact with the ground. Normalize the rotation axis vector to get \(\hat{a}_{i}=a_{i}/\|a_{i}\|\); further analyze the projection of the resultant force \(f_{r}\) in the unstable state onto the plane with \(\hat{\kappa}\) as the normal vector:  
\[f_{ri}=(E-\hat{a}_{i}\hat{a}_{i}^{T})f_{r} \tag{14}\]  
The component of the equivalent resultant moment \(n_{r}\) at the center of gravity of the hexapod robot in the \(\hat{\kappa}\) direction is \(n_{ri}\), and \(f_{ri}\), \(n_{ri}\) are the resultant force and resultant moment that cause the hexapod robot to tip over along the axis \(\hat{a}_{i}\). The schematic diagram of the stability cone of the support polygon during the quadrupedal gait of the robot is shown in Figure 3. \({}^{C}P_{G}-{}^{C}P_{1}{}^{C}P_{3}{}^{C}P_{6}{}^{C}P_{5}\) is the constructed stability cone of the hexapod robot. The vector passing through the center of gravity of the robot and perpendicular to the side \(i\) of the support polygon is \(V_{i}=(E-\hat{a}_{i}\hat{a}_{i}^{T})({}^{C}P_{i+1}-{}^{C}P_{G})\). After normalization, it is represented by \(\hat{V}_{i}\), and the equivalent couple in the support plane for the side line \(\hat{a}_{i}\) of the support polygon is:  
\[f_{ni}=\frac{\hat{V}_{i}\times n_{ri}}{\|V_{i}\|} \tag{15}\]  
The resultant overturning force \(f_{i}^{*}\) at the center of gravity of the hexapod robot with respect to the support polygon \(i\) is:  
\[f_{i}^{*}=f_{ri}+f_{ni} \tag{16}\]  
Normalizing \(f_{i}^{*}\), it can obtain \(f_{i}^{*}\). The overturning angle of the side line \(\theta_{bi}\) can be calculated by \(V_{i}\) and \(f_{i}^{*}\). The stability margin in the FASM method is defined as the minimum value of the included angles of each side, that is,  
\[S_{FASM}=\frac{k}{i=1}(\theta_{bi}) \tag{17}\]  
As the index to judge the stability of the hexapod robot, if the minimum overturning angle exceeds the threshold, the flag bit Flag = 1; if its value is lower than the stable value, Flag = 0; in other cases, Flag = 2.