Adaptive Hexapod:
CPG Locomotion Engine
A six-legged, 18-servo walker built to cross terrain wheels can't, then raced (and danced) at the Great Sand Dunes.
The Regolith Problem
Loose, granular regolith, the kind NASA's Lunabotics competition simulates and the kind that covers the Great Sand Dunes, is a nightmare for traditional rovers. Wheels spin out, dig holes, and get stuck.
To guarantee traversal over that terrain, I abandoned wheels entirely and designed a six-legged hexapod capable of stepping over loose sand rather than rolling through it. The real proving ground ended up being the Colorado Space Grant Robotics Competition, held right on the dunes.
Standing on markwtech's Shoulders
Rather than design a hexapod frame from scratch, we started from markwtech's open-source hexapod design, the 3D model below, and built, wired, and reprogrammed our own unit on top of it, later reworking the servo mounts ourselves (see 06__MECH).
markwtech reference 3D model, our starting pointBring-up went leg by leg. Here's the first leg wired up and moving under our own firmware, before the rest of the frame was even assembled.
All six legs assembled, wired, and mounted to the central Arduino Mega controller, fully built for the first time.
Fully assembled, all 18 servos wiredAnd its first steps under its own power.
Inverse Kinematics (IK)
Moving a leg isn't just "move servo A." To place a foot at exactly [x, y, z], you must solve a system of non-linear equations, the Law of Cosines applied through three joint planes simultaneously, to determine coxa, femur, and tibia angles.
I implemented a custom geometric IK engine in C++, validated to sub-millimeter round-trip accuracy across all six legs. It runs in under 0.6ms per leg on the Arduino Mega, fast enough to solve all 18 joints within the 25ms control budget at 40Hz.
The same IK math was independently ported to Python for simulation, where phase-plane visualization confirmed the geometric approach matched the firmware to floating-point precision. This IK engine is what both the CPG research below and the simpler gait that actually raced (05__GAIT) are built on top of.
Central Pattern Generator
This is real, completed work (designed, coded, and validated in simulation), not vaporware. But coordinating six independently-driven oscillators in firmware turned out to be its own project, and with competition day approaching we shipped a simpler, proven gait instead (see 05__GAIT). This section is what we built toward, not what raced.
Real insects don't compute gait keyframes: their spinal cord runs a self-organizing oscillator network called a Central Pattern Generator. The brain sends one signal ("walk faster"), and the CPG handles all inter-leg coordination automatically. I designed the same architecture for this robot.
| ω (rad/s) | GAIT | LEGS DOWN | USE CASE |
|---|---|---|---|
| ~1.0 | Wave | 5 | Rocks, slopes, max stability |
| ~3.0 | Ripple | 4 | General traversal, sand |
| ~5.0 | Tripod | 3 | Speed, flat cleared ground |
The key insight: gait type is not a mode switch. It is a continuous function of ω. Change one number, and the wave→ripple→tripod transition emerges from the coupling dynamics automatically. No state machine. No hard-coded offsets. The fixed tripod gait that actually raced is the ω≈5.0 row of this table, hard-coded instead of emergent.
What Actually Raced
With the CPG unfinished, the fielded robot ran a fixed tripod gait adapted from markwtech's reference code, three legs down at all times, simple and proven, driven through our own IK engine. Obstacle handling was a straightforward bump-and-recover loop instead of continuous sensor fusion:
That's it: two front bump switches for obstacles, and the IMU periodically pulling the heading back to forward so small drift doesn't compound over a run.
The IR range finders, foot contact switches, and ultrasonic sensors from the original CPG-fed sensor suite design were never implemented on the competition robot: there simply wasn't time. Bump switches and the IMU were the entire terrain-sensing budget on race day.
Frame Replacement
FutureTrace kit → markwtech 3D-printed frameThe original FutureTrace kit mounts every servo as a cantilever, the output shaft is the only structural connection between the servo body and the driven leg segment. Every stance phase redirects the robot's full weight radially through that shaft. The stock plastic bushing grinds out within hours. The shaft deflects under load, and that deflection introduces positioning error that compounds through the entire IK chain. Cheap servos fighting shear loads they were never designed for.
Single cantilevered bushing. Radial load grinds it out in hours. Output drifts ±3–5° from commanded angle. Gait becomes unreliable on sand.
Dual 624Z bearings built into every servo mount. Servo outputs pure torque. All radial load carried by the printed frame. Sub-degree positioning throughout.
The markwtech hexapod (inspired by the Trossen PhantomX, designed for MG996R-class servos) solves the shear problem at the design level, not as a retrofit. Every one of the 18 servo mounts has a press-fit 624Z bearing seat on the outboard side, machined into the print geometry itself. The bearings are structural from day one.
- >
PLA, 30% infill, printed hot (210°C) for layer adhesion
- >
TPU, 10% infill, compliant, grip-enhancing on regolith
- >
624Z (4mm ID × 13mm OD × 5mm) × 18, one per servo mount
- >
4-40 machine screws + nuts, 3/8″ / 1/2″ / 5/8″ lengths
- >
MG996R clone, 11 kg·cm, same pinout as existing firmware
- >
Thingiverse #3463845, Fusion 360 source + print-ready STLs
Body bottom plate
Body top plate
Body risers
Servo mounts (bearing seat)
Femur brackets
Femur bracket end caps
Tibia brackets
Tibia bracket end caps
Tibia base plates
Tibia foot plates
Tibia sides 1 + 2
Tibia spacer tubes
TPU foot bumpers
Wire guides
Control Loop Budget
The Arduino Mega runs at 16MHz with no FPU. This is the budget for the gait that actually raced (fixed tripod gait, bump switches, and IMU heading correction) inside the 40Hz (25ms) loop.
Total used: ~4.6ms of 25ms available. Plenty of headroom left over: most of it would have gone to the CPG and the extra sensors in 04__CPG, had there been time to finish them.
Race Day at the Great Sand Dunes
The Colorado Space Grant Robotics Competition ran right on the dunes, as close to a lunar regolith analog as Colorado gets.
Great Sand Dunes, CO: competition morningThe tripod gait and bump-recovery loop got us through the first course clean.
First course, completedWe failed every other course. The tripod gait and bump logic that worked on the first run didn't generalize to the rest of the obstacle set.
But it can dance. We built a dedicated dance mode, and it was worth every minute.
Janga, Cal, Luke, and Haley, at the Great Sand DunesJanga, Cal, Luke Bray, and Haley: Colorado Space Grant Robotics Competition team.
Frame design based on markwtech's open-source hexapod, adapted from the Trossen PhantomX.