160 Gait Analysis and Stability Evaluation of a Hexapod Robot Shaoyuan Zhang 1, *, Xuehan Zhang 2, a, Liyuan Sun 3, b 1 Hailiang Foreign Language High School, Zhuji, Zhejiang, China 2 Xian Tie Yi International Curriculum Center, Xi’an, Shaanxi, China 3 Shanghai Guanghua College Cambridge International Center, Shanghai, China * Corresponding author: Shaoyuan Zhang (Email: zsyqaq@outlook.com), a zhangxuehan2026@163.com, b luchaosunzong@163.com Abstract. Biomimetic hexapod robots present distinct advantages over wheeled robots in navigating uneven terrains. They are well-suited for applications in search and rescue, geographic exploration, military operations, and other similar endeavors. This study presents the development, hardware design, gait design, and performance analysis of a six-legged robot. We used forward kinematics and inverse kinematics to collect data and construct sinusoidal functions to probe two types of gaits: Tripod and Quadruped. A series of experiments was conducted to evaluate how body height (pose) and gait type of the robot influence its locomotion stability, including lateral deviation, vertical oscillation, and slippage. Using two-way ANOVA, we found that body height significantly affects lateral stability, while both gait and height interact to influence vertical displacement and slippage. Our findings highlight key mechanical and control factors in improving hexapod stability and motion efficiency. Future work will focus on enhancing adaptive capabilities through self-balancing mechanisms, robust gait planning under complex terrains, and the integration of multimodal sensing for intelligent control in unstructured environments. Keywords: Hexapod Robot; Gait Analysis; Posture Stability; Forward Kinematics; Inverse Kinematics; Locomotion; Tripod Gait; Quadruped Gait; Error Analysis; Two-Way ANOVA. 1. Introduction As an essential branch of robotics, the Biomimetic robot has shown comprehensive application prospects in terms of scientific research, industry, and the education field in recent years. By imitating the movement method of insects, with its wonderful stability and terrain adaptability, Six- legged (hexapod) robots offer superior stability and terrain adaptability compared to wheeled robots, making them ideal for challenging environments like search and rescue or exploration [1]. However, maintaining stable locomotion on rough or slippery surfaces remains difficult. Key challenges include designing effective gaits, preventing foot slippage, and managing body posture [2]. Recent research has highlighted that the robot’s body pose, particularly body height and orientation, plays a decisive role in locomotion stability. For instance, Coelho et al. [3] proposed a real-time posture adjustment framework allowing hexapods to modify body height and orientation based on terrain geometry, significantly improving stability on irregular surfaces. Similarly, Liu et al. [1] developed a multi-mode control algorithm to maintain posture balance on rugged terrain, while Arrigoni et al. [2] emphasized terrain-interaction feedback and anti-slip control for enhanced foot- ground reliability. Furthermore, Su et al. [4] analyzed geometric and dynamic parameters affecting robot stability and proposed a dimensional optimization model to enhance traversability on complex terrain. Building on these insights, this paper presents the development and analysis of a hexapod robot. We describe its construction, implement anti-slip measures for reliable ground contact, and develop core walking gaits. The primary focus is on analyzing how the robot's body pose (mainly, height) impacts its stability. We systematically test different poses under various conditions and evaluate their effect on stability margins. Our goal is to provide insights for optimizing pose control to enhance the robot's robustness during operation. 161 This paper is structured as follows: Section 2 describes the hardware of the robot; Section 3 introduces two different gaits; Section 4 analyzes the stability and sources of error of the robot; and finally, Section 5 gives the conclusion and the future directions of this study. 2. Hardware Our hexapod robot has six legs, each driven by three servos controlling the hip, femur, and tibia joints. To control all 18 servos, we used an ESP32 and two PCA9685, connected as in the Figure 1,2 below. Figure 1. ESP32 and PCA9685 Figure 2. Connection Diagram 162 In this essay, including the diagrams, we will refer to the legs as in the labeled Figure 3. Also, for the angles, our conventions are: For the tibia joints, 180° is defined as full extension, and 0° is defined as full flexion. For the femur joints, 90° is defined as parallel to the horizontal. 180° is defined as pointing straight down, and 0° is defined as pointing straight up. For the hip joints, 90° is defined as the normal position, 0° is defined as pointing straight forward, and 180° is defined as pointing backward. Figure 3. Marked Legs When we were putting the robot together, we spent a lot of time calibrating the servos; however, it later turned out that it is easier to correct the servos in the code. For the anti-slip material of the hexapod robot's legs, we had many options, including cutting rubber from balloons or rubber gloves and binding them to the robot's feet. However, these methods caused different problems. We noticed that this kind of material and structure can neither function well under the pressure from the tips of the endpoints of the legs, nor withstand the shearing stress from the motion of “trying to move forward”, resulting in ripping. Inspired by the resin we saw on social media, we made a plan for designing a mold for a foot cover and printing it out with a 3D printer. We wanted to make the actual foot cover with hot melt adhesive. However, since the leg and the mold are of the same material, the HMA tends to stick to the mold. So, we used hand cream as a substitute for the release agent at that time. After evenly applying the hand cream inside the mold, we injected the HMA and pressed the robot's foot into the mold, and waited for it to cool down and solidify. Then we tried to pull the foot out; however, we faced tremendous resisting forces. We believe it resulted from the poor ventilation: the vacuum effect in the sealed cold has made it very difficult to demold. So we added a small hole at the bottom to improve ventilation. With these improvements, we obtained almost identical foot covers with few defects. However, the feet still tend to slip easily; we suspect it is due to the lack of larger structures to prevent slipping, so we cut random lines on the surface of the foot covers where contact with the ground should take place. This successfully improved the stability of the robot and prevented much of the slipping [5]. 163 3. Methodology We started by designing the movements via experimenting with the angles of the servos. We used lists containing 18 numbers representing the angles of servos, and setting the legs with the lists in order can eventually make the robot move. 3.1 Tripod Gait During this process, we noticed that while the structure of the robot is symmetrical, the servos are not, so we reversed all angles for the right side of the robot, so that the control of the legs can be exactly the same. Figure 4. Steps Parameter Matrix For this gait, the legs are in two groups, moving out of phase. In every complete cycle, there are six frames, named after the function of the movement from the last frame to the next frame. The frames for leg0 (LF), from 0 to 5, are lagging, supporting, raising, swinging, supporting, and propelling. Figure 5. Gait Movement Diagram We then modelled each leg as connected rigid rods. We then calculated and collected the coordinates of one of the legs during two complete cycles and graphed them. We noticed that simple sine waves can fit the graph well. So, we used sine waves to generate the coordinates of the end of the legs at a given time. We can calculate the angles via trigonometry. We wanted the index of the new controlling system to remain generally the same, so we set the period to be close to 6. We also wanted the rate of change of y to be maximum when the z value is at maximum or minimum (when it is propelling or swinging); we also needed the rate of change of x to be 0 at both the start and end of the propelling stage. 164 Figure 6. Coordinates of One Leg within Two Complete Cycles Figure 7. Partial Code Illustration 3.2 Quadruped Gait Figure 8 and 9. Waveform Diagram Depicting Gait Patterns We also attempted a quadruped gait by splitting the legs into three groups (LF and RR, LM and RM, LR and RF). One whole cycle will have nine frames, very similar to the tripod gait, except that the phase difference between groups is 120°, or three frames. For each leg, it goes through: supporting, rising, swinging, falling, propelling, supporting, lagging, another lagging phase. Notice that in a quadruped gait, we have only three stages in which the leg is not touching the ground, which accounts for one-third of the total nine stages. While in the tripod gait, we also have three stages in which the leg is not touching the ground, which is 50% of the total six stages. This would mean that a quadruped 165 gait is more stable as it has one more leg supporting at any time. Also, we notice that in our quadruped gait, there are two stages (out of nine stages) in which the leg is actively pushing the robot forward (the propelling stages), whereas in our tripod gait, there is only one propelling stage (out of six stages), which means that our quadruped gait is slightly faster. We later confirmed this in our actual experiment. And we used similar sinusoidal waves to generate this gait. This time, we set the period close to 9, which is our original index for the final stage of a complete cycle. The complete code is in the final appendix. The waveform diagrams depicting our gait patterns have also been included in the final appendix section. These visualizations were generated using Desmos, a graphing tool, and interested readers are encouraged to examine them. 4. Stability and Error Analysis Achieving stable and smooth locomotion is a fundamental objective in hexapod robot design. Different gait and posture combinations offer varying levels of performance. To investigate this, we conducted a series of experiments evaluating lateral offset, vertical displacement, and the tendency to slip across multiple configurations. 4.1 Lateral Offset To assess the degree of lateral offset during locomotion, we conducted a controlled experiment under two gait conditions: Tripod and Quadruped. For each gait, we varied the robot’s average height from the ground (termed as “Settings”) across three levels: 120, 85, and 45. A total of six conditions were tested, and data were collected for each setting. The results are presented in Table 1 below. Table 1. Lateral Offset Data Gait Tripod Settings 120 85 45 Distance (cm) 160 160 160 130 130 130 155 160 160 Lateral Offset 50 40 40 60 60 60 20 10 10 Ratio 0.31 0.25 0.25 0.42 0.42 0.42 0.13 0.06 0.06 Gait Quadruped Settings 120 85 45 Distance (cm) 180 180 180 140 120 120 190 200 200 Lateral Offset 60 40 60 30 80 60 20 30 0 Ratio 0.33 0.22 0.33 0.21 0.67 0.5 0.11 0.15 0 In Table 1, distance refers to the x-axis component of the robot's trajectory, representing forward movement. Lateral Offset represents the y-axis component, representing lateral deviation from the intended straight-line path. The Ratio is defined as the Lateral offset divided by the Distance. Settings correspond to the z-component height (average vertical distance between the robot's body and the ground), defined in the code below: Figure 10. Defined in the code A higher Settings value indicates a greater average height of the robot during its movement. 166 With the data above, we used a two-way analysis of variance (ANOVA) to examine the individual and interactive effects of gait type and robot settings on lateral offset. The results are shown in the Table below. Table 2. Two-way ANOVA Summary Table regarding Lateral Offset Sum of Squares df Mean Square F p-value Significance Settings .3795 2 .1898 16.99 0.0003 Significant Gait .0022 1 .0022 0.20 0.6635 Not significant Gait × Settings .0010 2 .0005 0.05 0.9559 Not significant Residual(Error) .1340 12 .0112 R-squared 0.7407 The results show that Settings had a statistically significant effect on the ratio (F(2,12) = 16.99, p = 0.0003), while Gait (p = 0.6635) and the interaction between Gait and Settings (p = 0.9559) were not statistically significant. In conclusion, the setting at 45 resulted in the lowest average lateral offset among all configurations, while the setting at 85 resulted in the highest. Different gaits have no significant influence on lateral offsets. 4.2 Vertical Offset To measure the vertical stability, we wish to measure the amplitude of the oscillation of the body of the robot. Since the z value is modeled by a sine wave, it can be considered as a simple harmonic motion. So we recorded the motion of the robot’s body from its side and measured the amplitude under 6 different circumstances. Table 3. Vertical Offset Data Gait Tripod Settings 120 85 45 Amplitude(unit) 2.1 2.2 2.1 3.5 3.5 3.6 2.5 2.5 2.5 Gait Quadruped Settings 120 85 45 Amplitude(unit) 1.5 1.5 1.4 0.8 0.9 0.8 0.1 0.1 0.1 Table 4. Two-way ANOVA Summary Table regarding Amplitude Sum of Squares df Mean Square F p-value Significance Settings 16.6272 1 16.6272 16.99 0.0000 Significant Gait 2.3544 2 1.1772 0.20 0.0000 Significant Gait × Settings 3.6144 2 1.8072 0.05 0.0000 Significant Residual(Error) .0267 12 .0022 R-squared 0.9988 Table 4 demonstrates that both the type of gaits and different settings individually have strong effects on vertical offsets. Their interaction is also significant, implying a combined influence. In this case, the model explains nearly all the variability in the data with minimal residual error (R-squared value of 0.9988). In conclusion, Tripod gaits have larger amplitudes than Quadruped gaits. For Tripod, setting "85" has the greatest amplitude, and setting "120" has the smallest. For Quadruped, setting "120" has the greatest amplitude, and setting "45" has the smallest. 4.3 Slipping When the robot walks, we found that its legs would inevitably slip. The more its legs slip when it is propelling or lagging, the more inefficient this stage will be, so the distance travelled will decrease. 167 In order to evaluate the degree of slippage, we measured the total distance traveled by the robot under two different gaits and 3 different settings over a fixed number of steps. The corresponding data are presented in the table below. Table 5. Slipping Data Gait Tripod Settings 120 85 45 Total Distance (cm) 160 160 160 130 130 130 155 160 160 Gait Quadruped Settings 120 85 45 Total Distance (cm) 180 180 180 140 120 120 190 200 200 Table 6. Two-way ANOVA Summary Table regarding Slipping Sum of Squares df Mean Square F p-value Significance Settings 1512.5 1 1512.5 51.86 0.0000 Significant Gait 8419.4444 2 4209.7222 144.33 0.0000 Significant Gait × Settings 1308.3333 2 654.1667 22.43 0.0000 Significant Residual(Error) 350 12 29.1667 R-squared 0.9698 The results indicate that both settings and gait, as well as their interaction, had statistically significant effects on slipping (all p-values < 0.001). The high R-squared value (0.9698) suggests that the model explains approximately 97% of the variance in the response variable. 4.4 Sources of Error By observing the motion of the robot, we noticed several causes of turning during an intended straight movement. First is the lateral slipping. If the robot's leg hits the ground (entering the propelling/supporting stage) at an incorrect angle, the angle of the tibia joint might be deflected. As a result, the effective normal reaction force from the ground will decrease, decreasing the effective frictional force that can be exerted upon the robot during the propelling stage. To be more specific, to increase the frictional force, legs should be closer to normal to the ground when in contact with the ground. This difference in frictional forces will cause this side of the robot to move more slowy than the other side. Another factor is the faulty calibration of the hip joints, which breaks the symmetry of the two corresponding legs on different sides, which means that the pair of legs will not be propelling directly forward. Normally, apart from the middle legs, each leg in the other two pairs of legs will produce a force with a non zero lateral component, which should cancel out with the latertal component from the cooressponding leg, however if the hip joint is not perfectly callibrated, the direction of the propelling force will change, and the lateral component will not cancel out perfectly, causing the robot to turn slightly. A third factor is the slight difference in the foot cover; some legs might be exerting a greater force while propelling, so we tried to improve this by cutting the foot cover more regularly. This turned out to be successful, it exterminated the cases in which the robot turns very fast and hits the wall before the robot was planned to stop. A fourth factor is the location of the center of gravity. If the centre of gravity is not perfectly on the center axis, the normal reaction force exerted on one side of the robot will be greater than the normal reaction force on the other side. This means that the propelling force will be stronger on one side, causing the robot to turn. This can be fixed by carefully placing some load to balance the hexapod robot. We did not attempt this because we did not have space for the load. 168 5. Conclusion & Future Work In conclusion, this study presents the gait development of a biomimetic hexapod robot and investigates how body height and gait type affect its locomotion stability. We designed the robot’s mechanical system, implemented custom anti-slip foot covers, and developed gait control using sinusoidal motion planning. Through systematic experiments and two-way ANOVA analysis, we found that body height significantly influences lateral deviation and slippage, while both gait and height affect vertical oscillation. Additional sources of error, such as joint miscalibration and uneven foot structures, were identified. We observed that the angle between the robot's legs and the ground may be an important factor influencing stability. However, we were not able to control or precisely measure this parameter in our current setup. In future work, we aim to incorporate more advanced posture control, including both translational and rotational adjustments. As a biomimetic mobile platform, there is more remaining space for improvement regarding the adaptability of the hexapod robot in complex environments. For future research, we could focus on the following improvements: Self-balancing ability optimization: During the period of static standing and dynamic walking, there is a need for the stability of the robot, especially when there is an external force such as a varying load or the ground is not perfectly level or perfectly flat, as it is a potential challenge to adjust posture and keep the robot stable. It would require the addition of sensors and a special control system to react to external changes. Adaptive improvement in a complex environment: Six-legged robot needs to adapt to diverse terrains, like sand, mud, gravel, and slopes. It can autonomously adjust its gait and motion strategy in an unknown environment, in order to keep walking stably. This might require the ability to sense changes in its posture, and perhaps a randomized genetic algorithm for control. Motion control for recovery: When the robot stays in some stable state (such as being pushed down by external forces or being on the rotating platform), achieving posture recovery and continuing to walk is the vital direction in our future research. Robust walking in an unstructured environment: In a dynamic or "inexplicable" state, like sudden ground collapse, obstacle movement, strong wind interference, etc. Robots need to have stronger anti- interference ability and autonomous decision-making ability to maintain stable motion. Fusion of Multimodal Perception and Intelligent Decision-making: Combine multi-sensor information such as vision, force, and touch, improving the ability of real-time perception of the robot, and on the basis of an intelligent algorithm, to achieve more efficient gait planning and motion control. In the future, the hexapod robot is expected to improve in the aspects mentioned above and play a more critical role in applications such as rescue missions, exploration, and military operations. With further development, it has the potential to become an intelligent mobile platform capable of effectively adapting to complex and unstructured environments. References [1] Liu, Y., Wang, C., Zhang, H., & Zhao, J. (2020). Research on the Posture Control Method of Hexapod Robot for Rugged Terrain. Applied Sciences, 10(19), 6725. https://doi.org/10.3390/app10196725. [2] Arrigoni, S., Zangrandi, M., Bianchi, G., & Braghin, F. (2024). Control of a Hexapod Robot Considering Terrain Interaction. Robotics, 13(10), 142. https://doi.org/10.3390/robotics13100142. [3] Coelho, J., Dias, B., Lopes, G., Ribeiro, F., & Flores, P. (2024). Development and implementation of a new approach for posture control of a hexapod robot to walk in irregular terrains. Robotica, 42(3), 792– 816. doi:10.1017/S0263574723001765. [4] Su, Y., Ding, L., Xu, P., Wang, G., Wei, Q., Liu, T., Wang, H., & Gao, H. (2025). Dimensional design method based on stability analysis to enhance traversability of Heavy-Duty Hexapod robots over challenging terrains. SSRN Electronic Journal. https://doi.org/10.2139/ssrn.5167730. [5] Ruyuan Xiao Li Microcontroller Design. (2025). STM32 SG90 Servo Control (Video explanation included). https://blog.csdn.net/qq_50749196/article/details/145636471 [in Chinese].