A small open-source quadruped: four MG90S servos, one hip joint per leg, an Arduino Nano, and a 3D-printed body.
Everything you need to build one is here: the CAD, the exported URDF with meshes, the firmware, and the bill of materials.
Real hardware.
Same robot, simulated.
Drag this whole folder onto sim.aperobotics.io.
The site reads robot.sim.json and urdf/, drops the robot into a physics scene, and
opens an editor on the Arduino sketches in this repo. Hit Run and the simulated robot
walks with the same firmware you would flash onto real hardware — same pins, same
button, same serial commands. No install, no toolchain, no parts.
It is the cheapest way to see how the gait behaves and to try tuning changes before you spend money on servos.
| CAD (Onshape) | https://cad.onshape.com/documents/1d6856ca64e180c232afc1ec/w/bab35be0ac78b85a8fe890d0/e/db99d840450bf47cc6e8ddd6 |
| Bill of materials (Google Sheets) | https://docs.google.com/spreadsheets/d/1U2su3gvjsynv5EzIhSvFMGVECgmOlc8QD5Ccmuy-CCc |
| Simulator | https://sim.aperobotics.io/ |
| Demo video (YouTube) | https://www.youtube.com/watch?v=HywcIKy0xDY |
four-legged/
├── robot.sim.json # actuators, pins and wiring — what the simulator reads
├── urdf/
│ ├── four_legged.urdf # 257 links, 4 revolute DOFs (one hip per leg)
│ └── meshes/ # visual geometry (.obj + .mtl), exported from Onshape
├── quadruped_walk/ # the main firmware: gait, steering, button, serial console
│ └── quadruped_walk.ino
└── calibrate/ # single-servo helper, used while assembling
└── calibrate.ino
The authoritative list, with sourcing notes, lives in the BOM spreadsheet. Reproduced here:
| Item | Qty | Notes |
|---|---|---|
| Arduino Nano | 1 | Any clone works; the sketches use only Servo.h |
| MG90S servo, with horn and horn screws | 4 | One per leg — this is the whole actuation budget |
| 7.4 V LiPo battery, with charger | 1 | |
| Step-down converter (HW-411 / LM2596 style) | 1 | Drops the pack to the 5 V servo rail |
| Power switch | 1 | Inline between the battery and the converter |
| JST-2P connector | 1 pair | Battery ↔ switch ↔ converter |
| Tactile switch | 1 | The stand/walk button on D2 |
| Half-size breadboard | 1 | Carries the 5 V and GND rails |
| Hook-up wire | — | Servo and button leads to the Nano |
| Item | Qty | Notes |
|---|---|---|
| M2 × 10 mm self-tapping screws | 8 | Mount the servos to the body (came with the servos) |
| M2 × 5 mm self-tapping screws | 4 | Hold the printed body parts together |
| M2 × 8 mm self-tapping screws | 4 | Fix each leg to its servo horn |
| M2.5 × 8 mm machine screws | 4 | Attach the servo horn to the servo |
Printed as a set — the repo was built around JLC3DP prints, but any FDM printer with a
reasonable tolerance will do. From the CAD: Base, Top Cover,
Battery Holder, and 4 × Leg. Pull the current geometry from the
Onshape document;
the .obj meshes in urdf/meshes/ are visual exports and are not intended as print
sources.
A soldering iron, and whatever you normally use for small screws.
Servo signal pins, straight out of robot.sim.json:
| Leg | Signal (orange) | Servo home angle |
|---|---|---|
| Left front (LF) | D13 | 0° |
| Left back (LB) | A5 | 180° |
| Right front (RF) | D12 | 180° |
| Right back (RB) | D3 | 0° |
A5 is a normal digital output on the Nano, so Servo drives it exactly like any
digital pin.
The tactile switch bridges D2 to GND. The firmware enables the internal pull-up, so the pin idles HIGH and a press reads LOW — no external resistor.
Power path:
7.4V LiPo → JST-2P → power switch → step-down converter (set to 5V) → breadboard rails
├── 4 × MG90S
└── Arduino Nano
Two things worth getting right:
- Set the converter output to 5 V with a multimeter before you connect anything to it. These modules ship at arbitrary voltages and will happily cook a Nano.
- Do not power the board from USB and the 5 V rail at the same time. Unplug one.
- The servos must not be fed from the Nano's regulator — four MG90S under load draw far more than it can supply. They come off the converter rail directly, sharing a common ground with the Nano.
- Print the parts and clean up the holes.
- Seat the battery in the battery holder and mount the holder to the base, with the JST lead facing the switch. It goes in first because the holder sits under the servos — once they are in, you cannot reach its mounting points.
- Home the servos before the horns go on. Flash
calibrate/calibrate.ino, which drives a servo on D3 to exactly 0° and holds it there. Plug each servo into D3 in turn, then fit its horn at the angle that leg needs (0° for LF and RB, 180° for LB and RF — theservoDegreescolumn inrobot.sim.json). Getting this wrong is the single most common reason a build walks in circles. - Mount the servos to the body with the M2 × 10 mm self-tapping screws, and secure each horn with an M2.5 × 8 mm machine screw.
- Mount the top cover with the M2 × 5 mm screws, routing the servo and battery leads up through it as you go.
- Attach the legs to the horns with the M2 × 8 mm self-tapping screws.
- Wire it up per the table above — breadboard, converter, Nano and button all sit on the top cover.
- Flash
quadruped_walk/quadruped_walk.inoand press the button.
quadruped_walk/quadruped_walk.ino — Arduino IDE, board Arduino Nano, no libraries
beyond the bundled Servo.
It boots standing. The tactile switch toggles stand ↔ walk straight, which is the entire on-robot interface — everything else is optional and comes over serial.
| Key | Action |
|---|---|
w / x |
Walk forward / backward |
s |
Stand and stop |
a / d / f |
Steer left / right / straight |
r |
Random-heading wander |
+ / - |
Faster / slower gait |
[ / ] |
Smaller / bigger stride |
c |
Calibration sweep, one leg at a time |
? |
Help |
Diagonal pairs move in antiphase (PHASE = {0.00, 0.50, 0.50, 0.00}) — a trot. Within a
cycle, each leg spends gStanceFrac (70%) pushing slowly backwards and the remaining 30%
snapping forward through a smoothstep. Because the slow stroke has more time to grip than
the fast one, the net friction pushes the robot forward. Turning is differential stride
length: one side's amplitude scales by 1 + gTurn, the other by 1 - gTurn.
Everything lives in a small block at the top of the sketch:
| Symbol | Default | What it does |
|---|---|---|
gAmplitude |
15.0 |
Sweep in degrees either side of centre. Bigger stride, more slip |
gPeriodMs |
900.0 |
One full gait cycle |
gStanceFrac |
0.70 |
Share of the cycle spent pushing. The asymmetry is the propulsion |
TURN_MAG |
0.6 |
How hard a/d steer |
DIR[] |
{-1,-1,+1,+1} |
Which way +angle swings each leg |
If one leg walks backwards, flip only its entry in DIR[]. Run c on the serial
console first: it sweeps each leg forward, back, then centre, one at a time, so you can
see which sign is wrong.
Drag the folder onto sim.aperobotics.io — see the top of
this README. robot.sim.json is what tells the simulator which joint each servo drives
and where its signal wire goes, so the same pin numbers in the sketch reach the same
joints in simulation.
urdf/four_legged.urdf is a plain URDF and loads in the usual places (PyBullet, MuJoCo
via a converter, RViz). Mesh paths are package://four_legged/meshes/…, so a ROS
consumer needs a package named four_legged rooted at urdf/; most standalone loaders
let you map the prefix to that directory instead.
Use Onshape's built-in URDF exporter — it is what produced the model in this repo, it
needs no API keys or local toolchain, and it keeps the joint names the simulator expects.
Open the Onshape document,
right-click the assembly tab → Export, and choose URDF as the format. You get a zip
with the .urdf and its meshes; drop the contents into urdf/ to replace what is here.
One caveat, learned the hard way: the built-in exporter ignores mass overrides. It computes mass from part density, so overriding a part's mass in Onshape has no effect on the export. The major structural parts in this model carry corrected densities instead so the exported inertias are realistic — keep that in mind if you fork the CAD and the simulated robot starts behaving like it is made of foam.
The design is deliberately minimal — one DOF per leg is about the least you can get away with and still walk — which makes it a reasonable starting point for adding a second joint, swapping the gait, or hanging sensors off the unused pins (A0–A4 are free; A0 is currently read floating as a noise seed). Fork it and go.

