gwordal

Lesson 1 of 5 · 20 min

Anatomy of a walker

A wheeled robot rolls on a smooth floor and is done. A legged robot has to decide, every few milliseconds, where each foot goes, how much weight it carries and whether the whole body is about to tip over. Before writing any code, you need a clear picture of the machine: how many legs, how many joints, where every servo sits and whether those servos are strong enough to carry the body at all.

Why four legs

The deciding factor is static stability. A body stays upright without any active balancing as long as its centre of mass, projected straight down, lands inside the polygon formed by the feet touching the ground. Three feet make the smallest polygon that works: a triangle.

  • Two legs never form a polygon, only a line. A biped must balance dynamically, like an inverted pendulum, with a fast sensor loop. Hard for a first walker.
  • Four legs let you lift one foot and still have three on the ground. You can walk slowly, stop at any instant and stay upright with the power off.
  • Six legs let you lift three at once and are very stable, but they need 18 servos: 50% more weight, more cost, more current.

Four legs is the cheapest layout that is statically stable while walking, and it is also the layout of the animals people read as pets.

Degrees of freedom per leg

A degree of freedom (DOF) is one independent way a joint can move. Every DOF costs one servo, so you want the fewest that still do the job.

DOF per legWhat the foot can doProblem
1Swing on one arcCannot lift and push, so no walking
2Reach any point in a vertical planeCannot step sideways, cannot turn well, cannot shift weight left and right
3Reach any point in a 3D volumeNeeds 12 servos in total

Three DOF is the sweet spot. Each leg gets:

  1. Hip abduction (roll): swings the whole leg sideways, about the long axis of the body.
  2. Hip pitch: swings the thigh forward and back.
  3. Knee: bends the shin relative to the thigh.

Pitch plus knee is a planar two-link arm, which lesson 3 solves with simple trigonometry. Abduction rotates that plane. Four legs times three joints gives 12 servos.

Drag to orbit
A quadruped trotting. Count the joints per leg: hip abduction, hip pitch and knee.

The 12-servo layout

Assign the PCA9685 channels in a fixed pattern now, so the code in later lessons can loop over legs instead of repeating itself.

ChannelLegJoint
0, 1, 2Front leftabduction, hip, knee
3, 4, 5Front rightabduction, hip, knee
6, 7, 8Rear leftabduction, hip, knee
9, 10, 11Rear rightabduction, hip, knee

Channels 12 to 15 stay free for a head servo, a tail or a sensor.

Torque estimate: can the servos carry the body?

Hobby servo torque is quoted in kg-cm: the force in kilograms-force that the servo can hold at 1 cm from its axis. To convert, 1 kg-cm = 0.0981 N·m.

Take a realistic cat-sized build:

  • 12 metal-gear servos at 55 g each: 660 g
  • 2S LiPo battery: 110 g
  • Frame, electronics, wiring: 630 g
  • Total mass: 1.4 kg

The leg has a thigh of 80 mm and a shin of 90 mm, and the body stands 120 mm above the ground. In a trot, only two feet touch the ground, so each carries half the weight: 1.4 kg / 2 = 0.7 kg.

The knee is the hardest-working joint. With the foot directly below the hip, the knee sits about 60 mm (6 cm) in front of the foot, which is the lever arm. The torque is force times lever arm:

T = 0.7 kg x 6 cm = 4.2 kg-cm = 0.41 N·m

Check it in SI units: 0.7 kg x 9.81 m/s² = 6.87 N, then 6.87 N x 0.06 m = 0.41 N·m. The two routes agree.

A typical MG996R-class servo is rated near 10 kg-cm at 6 V, but that is the stall figure. Compare:

4.2 / 10 = 42 % of stall torque while standing on two feet.

Standing on all four feet, each carries 0.35 kg: 0.35 x 6 = 2.1 kg-cm, only 21%.

Why a bigger robot is not just a scaled-up one

Double every length and the mass grows with volume, so it goes up 8 times. The lever arms also double, so the torque needed grows 8 x 2 = 16 times. Servo torque does not grow that fast. This is the square-cube law, and it is why small robots feel nimble and large ones need much stronger, heavier, more expensive actuators. A cat-sized walker sits right at the edge of what 10 kg-cm hobby servos can do.

Three practical ways to improve the margin:

  1. Use a lighter frame (3D printed with low infill, or carbon plate).
  2. Choose 15 to 20 kg-cm servos for the knees only, since they carry the most.
  3. Keep the leg shorter: torque scales directly with lever arm.

Check yourself

Why is a quadruped statically stable while walking, while a biped is not?

Check yourself

A robot has mass 1.2 kg and stands on two feet. The knee lever arm is 5 cm. Roughly what knee torque does each leg need?