MH-FLOCKE MH-FLOCKE
HomeDocsGitHubBlogPaperYouTubeReddit𝕏

The Mogli Oscillator: When Your Robot Dog Gets a Real Spine

14 Apr 2026 5 min read Marc Hesse
The Mogli Oscillator: When Your Robot Dog Gets a Real Spine

Today we replaced the mathematical heart of MH-FLOCKE’s locomotion system. The old Central Pattern Generator — a set of sine and cosine functions that produced smooth, predictable gait patterns — is gone. In its place: 24 Izhikevich spiking neurons that fight each other to make a robot dog walk.

What Changed

Every vertebrate animal has a spinal CPG — a neural circuit in the spinal cord that produces rhythmic locomotion patterns without input from the brain. Thomas Graham Brown discovered this in 1911: take two neurons, connect them with mutual inhibition, add intrinsic adaptation, and you get alternating rhythm. Flexor fires, inhibits extensor. Flexor fatigues, extensor takes over. Repeat forever.

The Mogli Oscillator implements exactly this. Each of the robot’s 12 joints gets a pair of Izhikevich neurons — one flexor, one extensor — that alternate through adaptation-driven switching. Four legs × 3 joints = 24 neurons total.

The legs are coupled through interneurons: left-right pairs inhibit each other (alternation), diagonal pairs excite each other (walk gait synchronization). The coupling topology determines the gait — and because the coupling weights are stored in a learnable matrix, they can adapt through R-STDP.

Why It Matters

The old sine/cosine CPG was a placeholder. It worked — the Freenove robot walked, the Go2 ran 45 meters — but it had fundamental limitations:

No per-leg independence. All legs followed the same global clock. If one leg needed to step differently — obstacle, slope, missing leg — the CPG couldn’t accommodate it.

No real turning. Steering was a hack: offset the abduction angle. The Mogli Oscillator turns by giving one side more tonic drive — longer steps on the outside, shorter on the inside. Exactly how animals turn.

No gait transitions. Walk, trot, gallop require different phase relationships between legs. The old CPG had fixed phase offsets. The Mogli Oscillator’s coupling weights can shift to produce any gait.

No fault tolerance. If a leg breaks, the old CPG keeps sending signals to all four legs. The Mogli Oscillator can reorganize: the remaining three oscillators find a new stable pattern through R-STDP. Like a real dog learning to walk on three legs.

Adaptive Gain: The Cautious Newborn

The output gain is not hardcoded — it develops. The oscillator starts with a gain of 3.0 (tiny, cautious movements) and ramps to 8.0 over the first 2000 training steps. This mirrors biological development: serotonin (5-HT) from the brainstem’s raphe nuclei gradually increases motor neuron excitability over the first postnatal days. A puppy’s first steps are small and wobbly — not because it’s broken, but because the gain hasn’t matured yet.

CPG Autonomy: The Decerebrate Cat

An interesting finding during development: when the behavior planner switched to “look around” or “alert” behaviors (which reduce movement amplitude), the Mogli Oscillator stalled completely. The robot stopped walking.

This is biologically wrong. Decerebrate cats — cats with the brain disconnected from the spinal cord — still walk on a treadmill. The spinal CPG is autonomous. The cortex modulates locomotion but cannot silence it. Only the basal ganglia can actively suppress locomotion, and we haven’t implemented that yet.

The fix: a CPG autonomy floor of 70%. The behavior planner can slow down the robot, but the spinal rhythm continues. This is not a hack — it’s an anatomical property of the spinal cord.

First Results

The Mogli Oscillator walks forward, maintains perfect balance (0 falls in 50,000 steps), and the SNN actor takes over faster than with the old CPG (65% actor competence vs 11%). The walk gait emerges from the coupling topology:

Metric Mogli Oscillator Mathematical CPG
Distance (50k steps) 1.21 m 8.2 m
Falls 0 0
Actor Competence 0.649 0.108
CPG Weight 58% 85%
Upright Streak 50,000 50,000

Distance is lower because the system prioritizes stability during learning — exactly what a biological newborn does. The actor learns 6× faster because the Mogli Oscillator provides richer, more variable input signals than the predictable sine wave.

Nothing Is Faked

Everything you see in the video is the real output of neuronal dynamics. No sine functions. No hardcoded trajectories. The 24 Izhikevich neurons fire, inhibit each other, and produce a walking pattern through the same mechanism that Thomas Graham Brown described 115 years ago. The wackiness you see is real — it’s not a smooth sine wave anymore, it’s spike-driven motor commands. Like a real animal.

What’s Next

R-STDP coupling learning — the robot learns to adjust its own gait pattern through reward-modulated plasticity. The weight matrix is prepared, the eligibility traces exist. Activation is next.

Limb loss compensation — simulate a broken leg in MuJoCo, watch the remaining oscillators reorganize. A robot dog that loses a leg and teaches itself to walk again — like a real animal. No retraining needed.

Hardware deployment — the Mogli Oscillator runs at 28ms/step in simulation. The Freenove Pi runs at 25ms/step. Same code, same architecture. The sim-to-real gap is bridged by on-device R-STDP learning.

The Mogli Oscillator is named after our current test pilot — a dog who doesn’t know he inspired a neural architecture.


Code: github.com/MarcHesse/mhflocke (Apache 2.0) — enable with --neural-cpg flag
Video: YouTube @mhflocke
Paper 1 — Architecture & Ablation: doi.org/10.5281/zenodo.19336894
Paper 2 — Sim-to-Real Transfer: doi.org/10.5281/zenodo.19481146

#CPG #Freenove #izhikevich #locomotion #mogli-oscillator #neuroscience #open-source #quadruped #R-STDP #spiking-neural-network