REF-03 // HEXAPOD|NASA LUNABOTICS 2026

Adaptive Hexapod:
CPG Locomotion Engine

"Wheels fail where the ground fights back. To explore the lunar surface, we had to reinvent the step."

18
DOF
40Hz
Control Loop
3
Emergent Gaits
6
Oscillators

The Regolith Problem

NASA's Lunabotics competition challenges engineers to navigate a simulated lunar surface. The loose, granular regolith is a nightmare for traditional rovers — wheels spin out, dig holes, and get stuck.

To guarantee traversal over boulders and craters, I abandoned wheels entirely. I designed a six-legged hexapod capable of stepping over obstacles rather than rolling through them. Each foot can probe for stable ground independently — something no wheel can do.

// HARDWARE — markwtech frame // MG996R Ɨ 18 // PLA + TPU
markwtech 3D-printed hexapod robot with 624Z dual-bearing joints on Martian regolith test surface
markwtech frame // 624Z bearings Ɨ 18 // 4-40 fasteners // PLA 30% infill

Inverse Kinematics (IK)

// THE MATH

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.

Central Pattern Generator

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 implemented the same architecture.

// KURAMOTO COUPLED OSCILLATORS
dφᵢ/dt = ω + Σⱼ Kᵢⱼ Ā· sin(φⱼ āˆ’ φᵢ āˆ’ θᵢⱼ)
φᵢ — oscillator phase, leg i ∈ [0, 2Ļ€)
ω — natural frequency → controls speed + gait type
Kᵢⱼ — coupling strength between legs i and j
θᵢⱼ — target phase offset → encodes desired gait
ω (rad/s)GAITLEGS DOWNUSE 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.

Terrain Sensor Suite

Each sensor feeds directly back into the CPG parameters — not a simple stop/turn interrupt, but a continuous modulation of oscillator frequency, duty factor, and step height. The robot's gait adapts in real time to what it's actually experiencing.

S1

MPU-6050 IMU

Sand / Tilt~$5

Body roll, pitch, and yaw at 40Hz. Feeds body height compensation and asymmetric stance adjustments on inclines.

ω reduction on tilt > 8°
S2

6Ɨ Foot Contact Switches

Sand / Sinking~$5

Microswitches at each tibia tip trigger CPG phase-reset on touchdown — the robot re-syncs gait to actual ground contact rather than predicted contact. Biological insects use the same mechanism.

Phase reset: φᵢ → 0 on contact
S3

3Ɨ IR Range (GP2Y0A21)

Holes / Voids~$9

Front-facing downward IR sensors detect sudden loss of ground return — indicating a crater or drop edge. Triggers hard stop and reroute.

Hard stop → reverse → turn
S4

3Ɨ HC-SR04 Ultrasonic

Rocks / Obstacles~$5

Forward-facing sonar detects surface obstacles at 2–400cm. Detection increases ω (wave gait) and STEP_HEIGHT for clearance, resolving smaller rocks without stopping.

ω ↑ + step height ↑ on detection

Frame Replacement

FutureTrace kit → markwtech 3D-printed frame

The 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.

// BEFORE — FutureTrace kit
servo ──[bushing]──horn──── leg
↑ all load here

Single cantilevered bushing. Radial load grinds it out in hours. Output drifts ±3–5° from commanded angle. Gait becomes unreliable on sand.

// AFTER — markwtech frame
servo ──[624Z]──horn──── leg ────[624Z]── mount
↑ shared ↑ shared

Dual 624Z bearings built into every servo mount. Servo outputs pure torque. All radial load carried by the printed frame. Sub-degree positioning throughout.

// WHY THIS FRAME

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

// PRINTED PARTS MANIFEST
1Ɨ

Body bottom plate

1Ɨ

Body top plate

6Ɨ

Body risers

18Ɨ

Servo mounts (bearing seat)

12Ɨ

Femur brackets

12Ɨ

Femur bracket end caps

6Ɨ

Tibia brackets

6Ɨ

Tibia bracket end caps

6Ɨ

Tibia base plates

6Ɨ

Tibia foot plates

6Ɨ

Tibia sides 1 + 2

6Ɨ

Tibia spacer tubes

6Ɨ

TPU foot bumpers

6Ɨ

Wire guides

Control Loop Budget

The Arduino Mega runs at 16MHz with no FPU. Every millisecond is accounted for. The 40Hz loop (25ms period) is divided across tasks in strict priority order.

CPG step() — 11Ɨ sin()
2.5ms
6Ɨ IK solve + servo write
3.5ms
IMU read (I²C)
0.5ms
6Ɨ foot switch read
0.1ms
Ultrasonic (1Ɨ per frame)
1ms
IR sensors (3Ɨ analog)
0.3ms
Serial + overhead
0.5ms
Headroom
16.6ms

Total used: ~8.4ms of 25ms available. 16.6ms headroom reserved for sensor fusion algorithms and future expansion.