Let's Make Robots!

Gait design

Where can I find some practical information about designing and programming gaits for quadrupeds and hexapods? 

There's plenty of theoretical mathematics on the web but I'm looking for a straight forward practical basics. I'll look at the sophisticated methods later.

Did the majority of robot builders here use a "start from scratch" trial and error approach?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I'm using MG996R servos. These should be an improved version of the MG995. Dirt cheap on Ebay for the power. These are very strong servos. The bad points: accuracy isn't great and they draw lots of current (+1A stalled).

I'm considering using the following servos to keep cost to a minimum:

Coxa: hs-485hb,  Femur: hs-645mg , Tibia: hs-485hb

Does that sound a reasonable choice?

The chassis and legs will be in 2mm aluminium and designed to keep weight down to a minimun.  A Mega 2560 cpu and SSC-32 servo controller.

It's not much good giving us names. Give us specifications!
Particulary the voltage and torque ratings.
Are they metal gears or plastic? Do they have ball bearings?

How heavy will you robot be and what length will the legs pieces be? Remember, if you use Gait 2 then half of your legs will be off the ground so your servos need to be able to support the weight with only half the legs on the ground.

If for example your coxa servo is rated for 12Kg/cm and your leg piece from coxa to femur is 10cm log then it can only lift about 1Kg. I'm down rating the servo slightly because LiPo batteries voltage drop as the discharge.

So assuming the rest of the leg is verticle (best case senario) and assuming 6 legs with half off the ground then your robot's maximum weight can only be 3Kg. If you don't want to have your servos constantly working at full load and only lasting for a week or so then you should try to keep the weight under 2Kg.

I only mention the coxa servo here since that will have the highest load and do most of the work. If you want to make a hexapod robot that will last longer than a week before you scrap it for parts then I have 3 recommendations.

1. Use metal geared servos, plastic gears always strip the first time something goes wrong such as the legs getting tangled when you make a mistake in your gait code.

2. Try to use servos with about twice the torque of what you actually need. The servos last longer if they are not constantly maxed out.

3. If you are buying from a hobby shop then ask them if they have a dead servo of the same type that you can pull apart. Some cheaper brands use flimsy metal strips for brushes that burn out quick under load. The photo below shows a servo motor that only lasted about an hour before it curled up and died in my Chopsticks robot. The rest of the servo was in great condition.


I haven't done the calculations yet  but I just wanted a general opinion on these servos.

An initial goal will be to try and  limit the body weight to 1,0kg but a lot of this will probably be the battery.

Servo specs:


Modulation: Analog

Torque: 4.8V: 72.0 oz-in (5.18 kg-cm) 6.0V: 89.0 oz-in (6.41 kg-cm)

Speed: 4.8V: 0.20 sec/60° 6.0V: 0.17 sec/60°

Gear Type: karbonite

Rotation/Support:  Single Bearings


HS-645MG :

Modulation: Analog

Torque: 4.8V: 106.9 oz-in (7.70 kg-cm) 6.0V: 133.3 oz-in (9.60 kg-cm)

Speed: 4.8V: 0.24 sec/60° 6.0V: 0.20 sec/60°

Gear Type: Metal

Rotation/Support:  Dual Bearings


Taken note of the recommendations.

The coxa servos are moving the leg horizontally so they don't participate in lifting the weightof the body.  I suppose that the femur and tibia should preferably be HS-645MG  but that increases cost.

I've heard so many bad echos on the chinese tower pro 995 clones that I'm not keen on chancing these even if they are cheap although I see that Badj  http://letsmakerobots.com/node/35928 is using them so maybe he has been lucky.


Actually, a lot of your weight is the servos.
My personal opinion is these servos may not be strong enough but it depends on a lot of factors.

If you have a Hexapod with 3 DOF on each leg then there is 18 servos you need to weigh.
Once you consider the weight of your servos and battery then you should allow at least half again for the body.
Better to error on the side of caution and double the weight.

I think it's probably closer 12 servos than 18 since the , assuming that  the tibia is more or less vertical when it's supporting the weight of the robot, then it's weight is not adding to the body weight. Having said this, it'sobviously more complicatedthan that since as soon as a leg is off the ground it's weight is added to that of the body. The femur servo is having the most work.

As you rightly say, better to be on the side of caution so calculate for the worst case and then add a factor of 2 seems a good approach! 


Thanks, that really useful information to get started. I was looking at all thes robots and thinking,"how did they design their gaits?", but I see that it's often very much a "try and see" approach and depends obviously on the physical characteristics of each robot.

I think I'm finally going for a quaduped. I watched a few videos and it seems a good idea for the body to shift away from the leg that's going to be raised in order to shift the center of gravity.

I'm probably going to use an SSC-32 servo controller. I see it has some built in gait sequences for hexapods so I'm wondering if that can be adapted for quadrupeds

As for inverse kinematics, I will indeed leave that for later.

The first time I made a Quadruped I did use Gait 1 and I did make it shift it's body weight from side to side so that more weight was on the 2 legs on the ground.You can see video here: http://www.youtube.com/watch?v=MLZIN2Ttfpk

However I also found that if your robot is moving quickly then Gait 2 is fine because the robot does not have time to fall over. This is how the lizzards run at high speed. You can see a video here: http://www.youtube.com/watch?v=mICi5vjVcUw

(Disclaimer - Observations only; I've never made a quadruped #;¬)

You're right about shifting body weight for a quadruped - For slow movement, especially if you're only using 4 servos, you need the 'bot to be stable on the other 3 legs while you bring the fourth leg forward clear of the ground.  I was thinking about a 4 servo robot with a 5th servo to twist the front of the body relative to the rear to help with this.  Big feet would be an advantage for stability but harder to handle in the 'recovery' stage.

For fast movement, it strikes me that the rhythm of movement relative to body-weight is important and is something animals do instinctively but would be extremely complex on a 'bot, requiring accelerometer feedback.

A gait does not need complex math although it depends to some extent what you want to do. I started from scratch, looked at some videos and came to the conclusion that there are two basic gaits that you can use for both hexapod and quadrupeds.

Regardless of which gait you use, number the legs from 1 to whatever going clockwise or anti-clockwise around the body. The following descriptions assume walking forward.

Gait 1: The steadiest gait which is best for balance and / or carrying a heavy load lifts only one foot at a time.

Going in a sequence of your choosing, legs 1 through to whatever take turns at lifting and going forward. All other legs are on the ground supporting the weight of the robot and slowly moving backward to push the robot forward.

Gait 2: This is usually the fastest and perhaps the simplest gait. Unless the the Quadruped has big feet and can balance on diagonally opposite legs this gait should only be used by Quadrupeds for running. Hexapods and Octopods can work with this gait at any speed.

While legs with even numbers are being lifted and brought forward, legs with odd numbers are on the ground and pushing backward. Then Lift odd numbered legs and move forward while even numbered legs push backward.

You can see a video of my "Chopsticks" robot walking first with Gait 1 and then changing to Gait 2 here:

You will see the robot turns just like a skid steer robot by making the legs on one side go forward while the legs on the other side go backward. Because of the shape of the robot and the fact that I do not use any inverse kinematics some feet will slide a bit but it is good enough to get the robot walking about.

My 12 DOF hexapod was a little bit different because the legs were all at 60° to each other. In this case I did have to remember some basic trigonometry but I still managed to implement Gait 2 without too much fancy mathematics. I tried to comment each line of the code to make it as easy as possible for others to understand how the code worked.

You can see video here:


With all my gait code I break the gait into steps. These steps are basically:
1. Raise leg(s).
2. Move raised leg(s) forward, move lowered legs backward.
3. Lower raised leg(s).
4. Go to next leg(s) in sequence and repeat.

Gait 1 can end up having a lot of steps depending how many legs you have. You can download the code for my robots and look at the gait code. It is basically a step counter and a switch statement.

Inverse kinematics can give you more precise movement but if you are just learning robotics then you might want to skip it for now.