# Straight Gait Research of a Small Electric Hexapod Robot
## 4 Straight Gait Planning
### Gait Transformation Scheme  
In the beginning, the robot is crouching and needs a transformation to make it enter a certain gait cycle. Similarly, when the robot completes a specified number of cycles of motion, it can also transfer to the initial state to accept new instructions, to wait for new motion commands. What's more, when the robot is moving using a certain gait, it may receive commands to change to walk by using other types of gait. Therefore, it is necessary to further design the online gait transformation planning that supports remote control. The gait transformation scheme designed in this paper is based on the adjustment of foot positions. If the robot receives the command to change the gait during the motion, it will stop after completing the current step. The robot can then adjust the foot positions to a new state to enter the new gait cycle. There are two principles put forward for the adjustment of foot positions:  
1. Stability principle: When determining the swing leg, the robot should first be able to maintain static stability. Take leg 1, leg 4, and leg 5 as one group, and leg 2, leg 3, and leg 6 as another group. In one step, the robot can swing at most three legs at a time (the three legs must be in the same group), and the two adjacent legs cannot swing at the same time. Otherwise, the robot will lose its stability;
2. Rapidity principle: On the premise of ensuring the stability of the robot, choose the least number of steps to adjust, then strive to adjust the least number of legs. According to these two principles, Figure 8 shows the flow chart of gait transformation. Details are as follows:  
1. First, define a few parameters. \(M\): the number of adjustment steps in gait transformation. \(N\): the number of legs that need to be adjusted in gait transformation. \(M_{min}\): the minimum number of adjustment steps required in gait transformation. \(N_{min}\): the minimum number of legs required to be adjusted in gait transformation. The initial values of \(M_{min}\) and \(N_{min}\) are set to 3 and 6, respectively;
2. Traverse each foot position state in the new gait and compare it with the current foot position state of the robot. The previous parameters can be determined in this process. Since the foot positions of the six legs are already included in the set \(P\), when the two states are compared, \(N\) is easy to determine. Next, based on the stability principle,  
Figure 7: Walking forward using tripod gait. discuss in several situations: (1) If \(N\) is greater than 3, \(M\) must be 2; (2) If \(N\) is 3 and the three legs to be adjusted are in the same group, \(M\) is 1, otherwise \(M\) is 2; (3) If \(N\) is 2, and the two legs to be adjusted are not adjacent, \(M\) is 1, otherwise \(M\) is 2; (4) If \(N\) is 1, \(M\) is 1; (5) If \(N\) is 0, \(M\) is 0. This way, \(M\) can be determined. If \(M\) is less than \(M_{min}\), or although \(M\) is equal to \(M_{min}\), \(N\) is less than \(N_{min}\), update \(M_{min}\) and \(N_{min}\), and make the current traversed foot position state as the target state;
3. After the traversal is completed, the final adjustment steps can be determined. If \(M_{min}\) is 0, the robot can directly enter the new gait without adjusting foot positions. If \(M_{min}\) is 1, the robot only needs one step to complete the adjustment. If \(M_{min}\) is 2, based on the grouping of robot legs in the tripod gait, we can only adjust the positions of the legs in the same group in one step to ensure the stability principle. And the gait transformation process is completed in two steps finally. Here are two examples to illustrate the gait transformation scheme proposed in this paper. Consider a situation in which the robot changes from the tripod gait to the quadrangular gait. When the robot stops from the tripod gait, the foot position is assumed to be \(\{5,\)\(-5,\)\(-5,\)\(5,\)\(5,\)\(-5\)\((P_{T,2})\). According to the gait transformation scheme, the target state can be determined as \(\{5,\)\(0,\)\(-5,\)\(5,\)\(0,\)\(-5\}\) (\(P_{Q,2}\)).