Introduction: Arduino Quadruped Robot
Meet Stompy, the Arduino quadruped robot.
Most of the quadrupeds I’ve seen use “insect” type legs, but I wanted to try one with “mammal” type legs. The result was Stompy, a quadruped using eight servos, with each leg consisting of a hip joint and an ankle joint (no knee). Stompy uses a “trot” type gait where the front right leg is synchronized with the back left leg and these two limbs move in antiphase with the other two limbs. The result is a stomping type of walk, but it gets the job done. Controlling all the servos requires eight PWM pins and standard Arduinos only have six, so I decided to use an Arduino Mega. Stompy uses an IR distance sensor to keep from bumping into things and is capable of autonomous movement.
Step 1: List of Materials
Step 2: Robot Construction
Leg assembly is illustrated in the photos above. For the robot to move properly, the servos need to be centered. Information on how to center the servos that I used is available here. The side bracket mounting kits I used came with two plastic plates. The larger of these worked perfectly as a foot for the robot. I placed four small adhesive rubber tabs in each corner of the plate to improve traction. These rubber tabs also provided clearance for the nuts and bolts that hold the foot in place. The four legs are then attached symmetrically to the large plastic platform that forms the body of the robot. The servo cables are passed through holes in the plastic platform and attached to the Arduino. The Arduino itself is also bolted to the plastic platform. An IR distance sensor attached to a micro servo forms the head of the robot. This allows Stompy to roam free range.
Step 3: Forward Movement
In the Arduino code given below, the movement of the limbs is controlled by the variable flex1, which sets the angle at which a limb is bent. I have it set to 45, but it can be increased or decreased to lengthen or shorten the stride. In the setup section of the code I initially position Stompy with the front left and back right legs set forward and the front right and back left legs set rearward. Writing a value between 0 and 90 to the hip servos corresponds to a forward position and a value between 90 and 180 corresponds to a rearward position. Since the ankle servos are aligned 180 degrees opposite to the hip servos, writing the same value to both the hip and ankle servos will result in the foot being parallel to the floor. The setup section ends with a 5 second pause to allow time to position the robot.
The loop section of the code contains the walking algorithm. First, I straighten the front left and back right legs. The variable smoothnessDelay controls the speed and smoothness of this motion. With the front left and back right legs now straight, the front right and back left legs are off the ground in the rearward position. I bring these legs forward in three steps. First, I flex the ankles all the way forward to get them as far off the ground as possible. Next I swing the hips forward, during which time Stompy's heels will skip the ground. Last, I level the ankles so that they are ready to hit the ground. Now, the front left and back right legs are moved to the rearward position. After this motion, Stompy is half way through one complete walking cycle. I now repeat the process with commands to diagonal pairs of legs switched.
Attachments
Step 4: Left Turn, Right Turn, Reverse
Stompy is somewhat less graceful when turning. Basically, to make Stompy turn, I make the stride on one side of his body shorter than the other. For example, to turn left I make the stride on the left side of the body one third as long as the stride on the right side of the body. The variable multiplier in the code controls this. It is a little awkward looking, but it gets Stompy from point A to point B. A right turn is accomplished in a similar manner. Reverse is a straightforward modification of the forward walking algorithm. The code for all three is contained in the attached files.
Step 5: Autonomous Movement
The four gait files given in the previous two steps, along with some distance sensor code, can be combined into one file to allow for autonomous obstacle avoiding movement. I use an IR distance sensor to measure the distance to obstacles in front of Stompy. If the distance is below a set tolerance, Stompy stops, looks to the left and right to take two more distance measurements, and then continues in the direction of the clearer path. Since Stompy cannot turn on a dime, the change in direction is accomplished by first backing up 3 steps and then turning in the clear direction for 5 steps. Stompy then continues forward in a straight line until encountering another obstacle. The number of steps in the change of direction sequence are controlled by the variables reverseTime and turnTime. I use a laser to indicate the direction in which Stompy is looking.
Attachments

Participated in the
Epilog Contest 8

Participated in the
Arduino Contest 2016
19 Comments
3 years ago
HI,
Very nice construction,i know a little inverse kinematics. if you may,i want to write a code that might help the movement a little better
Question 3 years ago on Step 1
tell me how to assemble the circuit of this robot
6 years ago
Could you use an arduino uno instead of the mega
Reply 6 years ago
I'm not sure. The 8 servos for the legs need to be controlled by PWM pins on the Arduino, but there are only 6 PWM pins on an Uno (pins 3, 5, 6, 9, 10 and 11). I think there might be ways to extend PWM capability to other pins on an Uno, but unfortunately I don't know how to do it.
Reply 6 years ago
you do not need PWM for servo control
6 years ago
This is SO AWESOME. We love Stompy! :D
Reply 6 years ago
Thanks!
6 years ago
can u show the wiring diagram ,btween the adruino mega and servos and everything else
Reply 6 years ago
The image below shows how the servos are connected. I didn't have room for them all, so I just put in two representative ones. Just make sure to use different power supplies for the arduino and the servos since the Arduino pins cannot supply enough current to run the servos. The two power supplies do need to share the same ground connection.
6 years ago
woaahh thats an incredable work u did there bro ,... i want to makeone tooo ..
Reply 6 years ago
Thanks! Glad you liked it!
Reply 6 years ago
i am noobie and i have a doubt ..i see that u have separate program codes for forward left turn right turn reverse etc .. cant it all made one ?? .
Reply 6 years ago
Yes! The file containing all of them is given in Step 5. That file also contains code to process information from a IR distance sensor. When Stompy gets too close to a wall he stops, looks to the left and right to take distance measurements, and then continues in the direction of the clearer path.
6 years ago
can you share a video ?
Reply 6 years ago
There are more videos in Steps 4 and 5 of the instructable.
6 years ago
Thanks for the board concept
Reply 6 years ago
Glad you liked it!
6 years ago
Can it turn?
Reply 6 years ago
It's a little clumsy, but it can turn. There is a video of it turning in step 4.