Projects
On this page
The quadruped robot cut out from its background: blue printed body, grey upper legs, black lower legs.

ProjectSolo

8-DoF quadruped robot

A four-legged robot I designed and built: five-bar legs on eight servos, a custom servo-shield PCB, and ROS 2 control on a Raspberry Pi 5 that trots holding heading within ±2°.

Role
Solo engineer
Period
September 2025 – present
Context
Solo project
Status
Ongoing
Code
The quadruped standing on a white shelf, seen from the front left: a blue printed body with a battery on top and a camera board on the front plate, grey upper legs, black lower legs and white round feet.
Both servos of every leg sit in the body and drive the calf through a push rod, so the five-bar legs stay light. A Raspberry Pi 5 inside runs the whole ROS 2 controller.
  • 0.10–0.15m/strot speed, heading held within ±2°
  • 130–175mmadjustable body height
  • 82 → <10mmstepping drift in MuJoCo with closed-loop position control
  • ×2.2foot workspace from leg range computed on the CAD

Problem#

Walking on servos that report nothing#

The robot stands on eight Feetech FT6335 hobby servos, two per leg. Each servo takes a position command and drives toward it, but it reports no joint angle and no torque back: the servos run open loop. Nothing on the robot measures how far the body has travelled either.

Every decision the controller makes therefore comes from two sources: a BNO055 IMU (inertial measurement unit) that reports the body’s roll, pitch and yaw, and exact kinematics that turn servo commands into foot positions. Leveling, heading and foot placement all run on a Raspberry Pi 5 from those two.

Approach#

What the robot does#

On the robot, a ROS 2 controller trots forward at 0.10–0.15 m/s while a heading loop holds its direction within ±2°, and a leveling loop keeps the body flat. A PS5 gamepad drives it live: speed, turning and body height.

Left: the trot on the robot at a 0.6 s period, with leveling and heading hold closed on the IMU. Right: the same gait under live gamepad control, out, through a turn and back.

Designed end to end, tested on a model first#

I designed and built the robot across mechanics, electronics, kinematics and control: the body, mounts and servo-shield PCB, then a control stack in ROS 2 Humble on the Pi.

A MuJoCo model built from the CAD frames, masses and inertias, and a software-in-the-loop matrix of seven body poses, test every controller change before it reaches the robot. The matrix runs each behaviour at heights of 130, 155 and 175 mm, at ±10° pitch and at ±8° roll. 347 automated tests cover the code.

CAD render of the quadruped: a blue body with the servos at the shoulders, grey five-bar legs with push rods and dark round feet. (open the full-size figure)
The MuJoCo model of the quadruped standing on a checkered floor, with grey body, blue thighs and orange calves. (open the full-size figure)
The CAD assembly (left) and the MuJoCo model built from its frames, masses and inertias (right). The same meshes feed the leg-range and collision sweeps below.

What I built#

The five-bar leg and its kinematics#

Side-view drawing of one leg from its CAD meshes, with the joints labelled O, A, B, C, D, K, M and E from the hip down to the foot.
One leg from its CAD meshes. The upper servo turns the thigh about the hip axis O; the lower servo, at M, drives the calf through a crank and the push rod A–B. E is the foot.

Each leg is a five-bar linkage: a closed chain of links in which two motors together set one foot position. Both servos sit in the body, and the calf moves through a push rod, which keeps the leg light.

Forward kinematics maps the two servo angles θ to the foot position p = f(θ). My exact solution of the five-bar reproduces the first firmware’s 40-sample gait table exactly.

Inverse kinematics runs the other way, from a desired foot position p* to servo angles. I solve it by Gauss-Newton iteration with the Jacobian J of f, at about 22 µs per solve:

θ ← θ + (JTJ)−1JT (p* − f(θ))

The servo-shield PCB#

The robot from above and in front: the Raspberry Pi 5 and its cabling between the shoulder servos, a 4000 mAh battery on top and the camera on the front plate.
All compute and power ride inside the body: the Raspberry Pi 5 between the shoulder servos, under a 4000 mAh battery, with the PWM servo driver and the IMU on its I²C bus.

I designed a servo-shield PCB that powers and drives all eight servos from the 7.4 V battery. It carries:

  • a TPS63060 buck-boost converter for the 5 V logic rail, with power protection;
  • a PCA9685 PWM servo driver;
  • bulk capacitance for servo current transients;
  • a PCA9306 I²C level shifter, so the same board serves an Arduino or a Raspberry Pi.
Render of the servo-shield PCB: blue copper pour, servo headers in the four corners and the PWM driver at the bottom centre. (open the full-size figure)
Layout of the servo-shield PCB with top-layer traces in red and bottom-layer traces in blue, servo header groups in the corners and a long two-row header on the right edge. (open the full-size figure)
The servo shield as rendered (left) and as routed (right). The 16 PWM channels break out in four corner groups; the Arduino Uno footprint sits in the middle and a 40-pin Raspberry Pi header runs down the right edge.

Gait, body pose and balance#

The ROS 2 controller on the Pi runs at 50 Hz and has three layers.

  1. Gait generator. A data-driven generator places each foot along a swing and stance path. The trot proven on the robot moves diagonal legs together with a 0.6 s period, a 20 mm foot lift and a 0.7 duty factor, the fraction of each cycle a foot spends on the ground. At 0.7, all four feet share the load for 40% of every cycle, and the body rocks about 30% less than at 0.6.
  2. Body pose. A pose layer sets height (130–175 mm), pitch (±10°) and roll (±8°) as one rigid transform about the ground point under the body.
  3. Balance. A leveling PID corrects body attitude around the commanded pose, with a 1° deadband so the servos hold still when the body is level. A heading PID on IMU yaw steers toward the commanded heading.

PS5 gamepad teleoperation feeds speed, turning and body height into the same layers.

One guarded path to the servos#

Every servo command passes through one path on its way to the PCA9685:

  1. a per-servo limit clamp;
  2. a 500–2500 µs pulse clamp;
  3. a 400°/s rate limiter;
  4. one block write to the driver.

A fuzz test over 100,000 samples found no command outside the limits, and no clamp fired in any walk on the robot.

The stock BNO055 driver never recovers from an I²C error, and a stale IMU once held a 17 mm leveling correction that threw off the walk. The correction now fades to zero on stale data, and a supervisor node restarts the driver.

Leg range computed from the CAD#

A hand-set joint box (60–120° thigh, 60–100° calf) kept the legs far inside their real range. I computed the feasible joint region from the CAD meshes and the forward kinematics instead:

Leg range Hand-set box Computed from the CAD
Thigh × calf joint range 60–120° × 60–100° 36–157° × 58–125°
Joint-space area 2,400 deg² 5,341 deg²
Foot workspace 81 cm² 180 cm² (×2.2)
Fore-aft reach at 155 mm height −26…+70 mm −81…+117 mm
Plot of the foot workspace in the leg plane: a large blue crescent of reachable foot positions around a smaller orange outline, with the stride line and swing arc below the hip. (open the full-size figure)
Foot positions the leg reaches inside the CAD-derived limits (blue) against the old hand-set box (orange outline). The black arc is the trot: a 20 mm lift over the stance stroke at 155 mm height.

A second pass sweeps both servos through their whole travel against the CAD, calibrated on the robot’s real lowest pose with the hip 70 mm above the ground. It finds 10,080 deg² of contact-free joint space connected to the standing pose, which widens the range again.

Side-view drawing of the leg's CAD meshes folded flat under the body, the knee and foot resting on a ground line.
The leg's CAD meshes at the robot's real lowest pose, kneeling with the hip 70 mm above the ground. The second pass calibrates its contact tolerance on this pose.

Keeping the front and rear legs apart#

On each side, the front and rear legs can reach each other. Two independent sweeps check every rear-front leg pose pair on a 2° grid, about 1.8 million pairs per side: one slices the meshes into layers, the other uses MuJoCo contacts. They agree on 99.97% of pairs, and exact mesh distance settles the rest.

The sweeps found about 6,000 pairs per side that the old foot-gap table allowed and where the rear crank link hits the front calf. The swept unsafe set is now the controller’s one inter-leg check: a startup check covers every gait, pose and stride, and a per-tick guard tests each command against the set in 1.6 µs.

Six panels of a rear leg in orange and a front leg in blue, each with a close-up of the closest point between them. (open the full-size figure)
Left-side pose pairs from the MuJoCo sweep, rear leg orange, front leg blue. The top four overlap and sit in the forbidden set, one of them the rear crank link reaching the front calf; the bottom two clear by 2 mm and stay allowed.

Results#

Trotting with heading hold#

On the robot, the trot runs forward at commanded speeds of 0.10–0.15 m/s, holding heading within ±2°.

Walking backward: the heading hold that caused a spin#

Walking backward at 0.12 m/s, the robot spun 45–117° in 5 s. With the heading hold off, it backed up straight, so the hold itself caused the spin: a large differential stride made the feet slip as they pushed toward the nose, the yaw response reversed, and the PID pushed harder.

The heading PID outputs a turn rate ω from the heading error e, clamped to a limit I call its authority:

ω = clamp( kpe + ki∫e dt + kdė, ±ωmax )

Capping ωmax at 0.1 rad/s, well above the robot’s natural veer of about 0.015 rad/s, broke the loop:

Run on the robot Heading authority Heading error at the end of the run
Backward, hold on (before) 0.4 rad/s 45–117° (spinning)
Backward, hold off none 4.3°
Backward, hold on (after) 0.1 rad/s 0.5–3.5°
Forward, hold on (after) 0.1 rad/s 1.0–1.5°

After the fix, roll stayed within 0.9–1.5° RMS in both directions.

Drift and balance in MuJoCo#

In MuJoCo, closed-loop position control cut stepping drift from 82 mm to under 10 mm, over 10 s of stepping in place on flat ground at seven body poses with simulated odometry. The same loop cuts the distance a push costs:

MuJoCo, 7 body poses Open loop Closed loop
Stepping in place for 10 s, final drift 49–82 mm 0–9 mm
4 N push while walking at 0.1 m/s, distance lost 84–388 mm 22–98 mm

Across 273 runs, the model never fell and no servo clamp fired. Leveling brings the body from a 4° slope into its 1° deadband in under 5 s, and a 4 N side push tilts it by at most 2.0°.

What’s next#

  1. A PPO locomotion policy trained in Isaac Lab for sim-to-real transfer on open-loop servos with no joint feedback.
  2. A jump that pushes off with the takeoff velocity closed on the IMU and lands with leveling held.
  3. Vision-directed behaviours driven by the front camera.