# - Walking algorithm

To figure out the sequence of servo movements which make the robot move was a tough task for me. My imagination betrayed me, so I had to use the robot, moving its legs by hand and taking notes of the movements.

I use the following notation when describing the movements:

The position of servo is A, B or Center. Center is self explanatory. Position A is with the lever of the servo moved counter clockwise from the center, B is moved clockwise (looking at the servo from the side on which the lever is attached).

Servos are assigned numbers: 1 – left-hand side servo, 2 – right-hand side servo, 3 – center servo. See the pictures for details:

Fig. 6.1 – Positions of servos

Fig. 6.2 – Servos on the robot – top view

To present the algorithms in a clear way I use table where the columns mark position of the servo in each step of the algorithm. There is about 0.2 s pause in the execution of the MCU program between steps, so that the servo has enough time to reach desired position.

Don't be suprised if you won't understand the tables just by reading this. You will probably need to try it on the real robot (just like I had to) if you decide to make some changes in the walking algorithms. On the other hand, if you will be satisfied with the way Krabos walks with the provided algorithms, you do not need to spend much time on this "low level" information.

Algorithm to walking forward

 Step S1 S2 S3 0 Center Center Center 1 Center Center A 2 Center A A 3 A A A 4 A A B 5 B A B 6 B B B 7 B B A 8 B A A

The robot starts from neutral position (all servos at center). Steps 1 and 2 are performed only once when it starts to move. Then the program cycles through steps 3 to 8 to keep the robot moving. Note that at each step only one servo changes its position.

To describe the algorithm in words:

1. tilt right (left side of robots body is higher than right side) – S3 to A

2. move left legs forward - S2 to A

3. move body forward (in other word move right legs backward) - S1 to A

4. tilt left – S3 to B

5. move right legs forward – S1 to B

6. move body forward - S2 to B

7. tilt right – S3 to A

8. move left legs forward – S2 to A; see step 2

9. move body forward – S1 to A; see step 3

10. and so on, step 4, 5,...

Algorithm for turning left

 Step S1 S2 S3 0 Center Center Center 1 Center Center B 2 B Center B 3 B Center A 4 A Center A 5 A Center B

Step 1 is performed only at the start of the rotation from neutral position, then steps 2 through 5 repeat to keep the robot rotating.

Algorithm for tunrning right

 Step S1 S2 S3 0 Center Center Center 1 Center Center A 2 Center A A 3 Center A B 4 Center B B 5 Center B A

Step 1 is performed only at the start of the rotation from neutral position, then steps 2 through 5 repeat to keep the robot rotating.

To rotate left or right the robot uses this simple algorithm (right rotation described):

1. tilt right (left side of the body higher than the right side), left legs up – S3 to A

2. move left legs forward (they are above ground) – S2 to A

3. tilt left, left legs back to the ground, right legs up – S3 to B

4. move body forward; rotates robot body on the left legs to the right – S2 to B

5. tilt right – S3 to A

6. move left legs forward and so on – repeats step 2

Algorithm for walking backwards

 Step S1 S2 S3 0 Center Center Center 1 Center Center B 2 A Center B 3 A A B 4 A A A 5 B A A 6 B B A 7 B B B 8 B A B

Steps 1 and 2 are performed only once when robot starts to move. Then the program cycles through steps 3 to 8 to keep the robot moving. Note that in each step only one servo changes its position.