The Dog Follows the Light — Phototaxis with Spiking Neurons
A 560-Neuron Spiking Network Steers a Quadruped Toward Light
For the first time, MH-FLOCKE’s robot dog actively navigates toward a light source in simulation — driven by hardwired reflexes and learned neural adaptations. No external reward signal. No reinforcement learning. Just body signals.
What You See in the Video
A Freenove Robot Dog (€100, Raspberry Pi, 12 servos) walks across a flat surface in MuJoCo simulation. A light source (yellow dot on the mini-map) is placed ahead and to the side. The dog detects the light gradient and steers toward it using a VOR (Vestibulo-Ocular Response) reflex — a hardwired brainstem circuit that turns the body toward a visual target.
The mini-map in the bottom-left corner shows the robot’s trail (green line) and the light waypoint (yellow glow). You can see the dog arcing toward the light rather than walking straight. This arc is not a software limitation — it reflects the physical turning radius of the Freenove’s CPG gait, which produces roughly 12% steering asymmetry between left and right legs.
Hardwired vs. Learned: The Biological Design
MH-FLOCKE follows the same principle as biological motor development. A newborn puppy doesn’t learn to walk from scratch — its spinal cord has CPG circuits that produce rhythmic leg movements from birth. The cerebellum calibrates these movements through experience. The brainstem provides reflexes like the VOR. Learning refines what reflexes provide.
Hardwired components (present from “birth”):
CPG (Central Pattern Generator) — Mathematical oscillator producing rhythmic gait. The SNN does not generate the gait pattern; CPG provides the baseline.
VOR (Vestibulo-Ocular Response) — Reflexive steering toward the light target. Hardwired, like in a real animal’s superior colliculus.
Run-and-Tumble — A bacterial-inspired navigation state machine (Berg & Brown, 1972). Alternates between running straight and turning (tumbling) when the gradient changes.
Learned through training (emerges from experience):
SNN weights (R-STDP) — Reward-modulated spike-timing-dependent plasticity adapts 560 neuron connections based on intrinsic reward (vestibular comfort, prediction error, curiosity).
Cerebellar correction (Marr-Albus-Ito) — The cerebellum learns forward-model corrections. Correction magnitude grows from 0.0006 to 0.034 over training — the strongest cerebellar signal ever measured in MH-FLOCKE.
CPG-to-SNN handoff — The CPG starts at 90% control and fades to ~45% as the SNN proves it can maintain stable locomotion. The SNN earns control through competence, not through a timer.
The Numbers
33,000 steps, 9.7 minutes training time (57 sps on CPU)
0 falls, perfect upright streak
2 light targets reached (sf:2) through active VOR-guided steering
VOR signal up to +0.54 — strong, sustained steering toward the light
4 Run-and-Tumble events — the navigation state machine triggered naturally
Cerebellar correction: 0.008 — real Marr-Albus-Ito learning
Why the Dog Arcs Around the Light
You’ll notice the dog doesn’t walk straight to the light — it takes a wide arc. This is not a bug. The Freenove’s CPG produces approximately 12% amplitude asymmetry between left and right legs when steering. This gives the robot a turning radius of roughly 5 meters. The VOR reflex fires correctly, and the CPG responds — but the body can only turn as fast as the legs allow.
This is exactly what happens with real quadrupeds. A horse can’t make the same tight turns as a cat. The steering intention is there; the biomechanics set the limit.
Performance Breakthrough: 6× Speedup
This session also resolved a critical performance bug. Step-time was growing from 20ms to 800ms over 100k steps — making long training runs impossible. The root cause: an O(N²) clustering operation in the Synaptogenesis module that processed 5,000 accumulated experience patterns without clearing the buffer.
The fix (buffer.clear() after consolidation + max_size reduction) brought step-time back to a stable 18ms across 100k steps. Training speed went from 7 sps to 54 sps — a 6× improvement that makes all future development viable.
What’s Next
Hardware phototaxis — The same VOR steering with a real camera (cv2) on the Freenove, following a flashlight on the floor.
Autonomous loop — Instead of pre-placed waypoints, the dog chooses its own targets based on curiosity, exploration drive, and episodic memory. All the modules exist; they need a conductor.
Paper 2 — Sim-to-real transfer on the Freenove Robot Dog. Published: aiXiv 260409.000002.
MH-FLOCKE is an open-source project by Marc Hesse — independent researcher, Potsdam, Germany. Named after Flocke, my late dog.
The Mogli Oscillator: When Your Robot Dog Gets a Real Spine
Today I 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 I 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:
Left↔Right correlation: -0.78 (alternating)
Diagonal correlation: +0.73 (synchronized)
Exactly the pattern of a walking dog.
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 my current test pilot — a dog who doesn’t know he inspired a neural architecture.
To provide the best experience, we use technologies like cookies to store and/or access device information. Consenting to these technologies allows us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Präferenzen
Die technische Speicherung oder der Zugriff ist für den rechtmäßigen Zweck der Speicherung von Präferenzen erforderlich, die nicht vom Abonnenten oder Benutzer angefordert wurden.
Statistics
Die technische Speicherung oder der Zugriff, der ausschließlich zu statistischen Zwecken erfolgt.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.