MH-FLOCKE MH-FLOCKE
HomeDocsGitHubBlogPapersYouTubeReddit𝕏

My Robot Dog Couldn’t Walk Straight — 8 Bugs and a New Steering System

The Freenove robot dog has a problem. It drifts to the right. Every unit is different — servo tolerances, weight distribution, surface friction — and no amount of calibration fixes it permanently. The drift changes with battery level, temperature, and floor surface.

For weeks, I tried to fix this with Z-offset steering — shifting all four feet sideways to create a turning moment. It seemed logical. It was useless. A 45-second hardware test proved it: ±5mm of Z-offset produces less than 5 degrees of effect against 70 degrees of mechanical drift. One measurement killed weeks of assumptions.

Tank Steering

The replacement is asymmetric stride — differential hip amplitude between left and right legs. Left legs take a longer step, the dog curves right. Like a tank. Biology does this through the reticulospinal tract, which modulates stride length independently per side.

Hardware test: drift reduced from 70 degrees to 8.5 degrees. Three times more effective than Z-offset, and it works on any surface because the IMU provides closed-loop feedback.

The PID controller reads the actual heading from the MPU6050 IMU, compares it to the target heading from the camera (where the light is), and drives the stride asymmetry. No calibration, no per-robot tuning. The I-term accumulates over time to eliminate steady-state offset — exactly what the cerebellum does biologically through long-term depression.

Eight Bugs in One Session

The steering replacement exposed eight bugs that had been hiding in the system:

The steering signal was computed correctly but silently dropped in compute_tendon() — wrong code path, one line fix. The log was showing a proxy value instead of the actual steering — the controller had been working the whole time, but the display said zero. The competence gate required walking speed above 0.03 m/s, but with drift, all locomotion energy went to correction instead of forward progress. The baby never grew up. MuJoCo yaw convention is inverted versus hardware — one minus sign. A threshold prevented target updates when the dog was roughly aimed at the light. The PD controller initialized its target to zero instead of the current heading.

Each one of these individually prevented the system from working. Finding them required switching between simulation and real hardware, comparing signs and values, and measuring instead of guessing.

The Dog Approaches the Light

After fixing all eight bugs and tuning the PID on hardware (Kp=0.05, Ki=0.01, Kd=0.015), the Freenove robot approaches a light source from 0.52 meters to 0.17 meters in 60 seconds. Not perfect tracking — the steering saturates near the end — but genuine, IMU-corrected, drift-compensated navigation on a 100-euro robot kit.

In simulation with measured hardware drift injected: 50,000 steps, zero falls, three light targets found, actor competence 1.0.

Meta-Learning Loop

This release also introduces the complete autonomous meta-learning loop — four modules that form a closed self-improvement cycle:

EpisodeAnalyzer compares successful versus unsuccessful navigation events and identifies what makes the dog successful. Which context variables (gait quality, heading error, velocity, steering offset) correlate with finding the light?

StrategyAdapter converts those insights into parameter adjustments — modifying run/tumble duration, PID gains, and exploration bias.

CuriosityExplorer uses world model prediction error to drive exploration. High prediction error means unfamiliar territory — explore more. Low prediction error means familiar ground — exploit what works.

HypothesisGenerator creates testable motor hypotheses from insights that can be tested autonomously through the existing Directed Learning module.

The loop runs but has not generated insights yet — the dog is too successful in the current scenario (100% success rate, no failures to learn from). Harder scenarios and longer runs will activate it.

Hardware Drift Simulation

The drift profile injected into the simulator has been updated. The previous measurement (-0.4 deg/s) was taken during a stationary test. Under walking load, the actual drift is 1.5 to 2.0 deg/s — servo asymmetry amplifies under dynamic conditions. The updated profile makes simulation training more realistic.

Every Freenove unit has different drift characteristics. MH-FLOCKE handles this automatically through the PID controller. No manual calibration needed.

What Comes Next

Hardware video with the new PID steering. Longer simulation runs to activate the meta-learning loop. A potential third robot platform (Petoi Bittle X V2) to prove the architecture is body-agnostic.

The code is on GitHub (Apache 2.0). Updated documentation at mhflocke.com/docs.

v0.5.1Full changelog

From Simulation to Walking Robot: MH-FLOCKE on Real Hardware

MH-FLOCKE now runs on a real robot. A Freenove Robot Dog Kit (~100€) with a Raspberry Pi 4 executes the same spiking neural network that learns to walk in the MuJoCo simulator — same code, same weights, same cerebellar architecture.

One Codebase, Two Platforms

The key design decision: the Pi imports src/brain/ directly. There is no separate hardware implementation, no NumPy approximation, no simplified model. The SNNController and CerebellarLearning classes run identically on both platforms. A brain file (brain.pt) trained in simulation loads on the Pi without conversion.

This was made possible by topology.py, a new module that computes cerebellar population sizes without any MuJoCo dependency. Both the simulator’s MuJoCoCreatureBuilder and the Pi’s freenove_bridge.py call the same function.

What Runs on the Pi

The Freenove profile uses 232 neurons — scaled down from the Go2’s 4,624 but with the same cerebellar architecture:

  • 48 mossy fiber inputs (12 servo + 2 CPG + 4 IMU + padding)
  • 106 granule cells (expansion layer)
  • 18 Golgi cells (inhibitory feedback)
  • 24 Purkinje cells (2 per actuator)
  • 24 DCN neurons (motor correction output)
  • 12 output neurons (one per servo)

At 34ms per step (29Hz), the control loop runs fast enough for stable walking. The cerebellar climbing fiber responds to real IMU orientation errors from the MPU6050, and PF→PkC weights grow from 0.078 to 0.114 over a typical session — the cerebellum is learning on real hardware.

The Live Dashboard

A web dashboard on port 8080 shows what the SNN is doing in real time: all six cerebellar populations with live spike activity, servo angles, the competence gate balance, and neuromodulation levels. Every data point comes directly from the running PyTorch SNN.

Try It Yourself

The complete deployment guide, source code, and servo configuration are on GitHub. The Freenove FNK0050 kit costs about 100€ and requires a Raspberry Pi 4 with 2GB+ RAM. PyTorch runs CPU-only on the Pi — no GPU needed.

Watch the demo video →