# GGUFC: a robot dog with three brains, no Linux and one shared memory

> Source: <https://www.fratepietro.com/2026/ggufc-robot-dog-three-kernel-images/>
> Published: 2026-12-05 23:00:00+00:00

**Recommendation:** Separate latency-critical control from model inference into its own process and share state through single-writer slots with odd/even counters, so a stalled model never blocks the 20 ms motor loop.
More in the playbook "Designing agent systems": <https://wpnews.pro/playbooks/agent-architecture>

# GGUFC: a robot dog with three brains, no Linux and one shared memory

You say “go get the red ball”. One program hears it, a second one decides what to do about it, a third one walks the dog to the ball, and the first one says “On my way to the ball!”. Each of the three is a kernel image built by [GGUFC](https://github.com/antonellof/ggufc), running in its own QEMU virtual machine with no Linux, no libc and no heap. The only thing they share is one block of memory.

In my [first post about GGUFC](https://www.fratepietro.com/2026/ggufc-compile-llm-to-c-boot-without-os/) I compiled a language model to C and booted it in place of Linux. This post is about putting several of those together into something that acts: a robot dog you can talk to.

## Why three images and not one program

A robot needs very different kinds of work at the same time. Hearing and speaking are heavy but can wait a second. Deciding needs the biggest model. Walking needs no model at all, but it has to answer the motors every 20 ms, whatever else is going on.

Put all of that in one program and the slowest part sets the pace for everything. So each job gets its own image, sized for it:

- **The ears and voice** run a speech recognizer (Qwen3-ASR 0.6B) and a text-to-speech model (Soprano 80M). They listen all the time, post what they heard, and speak whatever reply shows up.
- **The brain** runs Llama 3.2 1B on four cores. It reads what was heard and what the dog sees, and posts an action and a reply.
- **The legs** are a 28 KB image with no model in it: a trot and some steering, in plain C. They turn the action into joint angles, 50 times a second.

If the brain is busy thinking, the legs keep walking. If the brain stopped altogether, the legs would carry on with the last action, and the body would keep answering its own sensors.

## The blackboard

The images don’t send each other messages. There’s no network stack in them to send messages with. Instead they share one 4 MB block of memory with a fixed layout, which I call the blackboard. On the Mac it’s a file. QEMU maps that file into each virtual machine as a separate bank of memory (`memory-backend-file` with `share=on`, attached as its own NUMA node), so every image sees the same bytes at a fixed address. The simulator on the host maps the same file.

The blackboard has two kinds of things in it.

**Slots** hold the latest value of something: what was heard, the action, the reply, the dog’s pose, where things are, the camera frame. Each slot has exactly one writer. The writer bumps a counter to an odd number, writes, then bumps it again. A reader copies the value and checks that the counter didn’t move, and if it did, it reads again. Nobody ever waits for a lock, so a slow reader can never hold up the writer.

**Event rings** hold a history: “heard: stop”, “reached the ball”. Each reader follows a ring at its own pace. If it falls so far behind that old entries are overwritten, it’s told how many it missed instead of silently getting garbage. A stress test runs five writer processes and three reader processes on it, one deliberately slow, and checks that nothing is ever read half-written and that every event is either read or counted as lost.

## The body

The dog is a Unitree Go2, simulated in [MuJoCo](https://mujoco.org) with the model from DeepMind’s MuJoCo Menagerie. Every 20 ms the simulator writes the dog’s pose into the blackboard: position, orientation, the 12 joint angles and speeds, and how hard each foot presses on the floor. Ten times a second it renders the head camera into the camera slot.

Going the other way, it reads joint targets from the legs and applies them with a PD loop at the physics rate. That matches how the real Go2’s low-level interface works: you send a target angle, a stiffness and a damping per joint, and the motor drivers do the rest.

The simulator can also run in lockstep: it waits for the legs’ answer to each pose before stepping. Two lockstep runs give the same poses and camera frames, byte for byte.

## The legs: walking without a model

The trot is old-fashioned code. Diagonal legs move together. Each foot pushes back along the floor for half the cycle, then swings forward through an arc. Inverse kinematics turns each foot position into hip, thigh and calf angles.

Turning taught me something. My first version only made the left feet take shorter steps than the right ones, like a tank. The dog turned at about a quarter of the requested rate, because four planted feet resist being dragged sideways. The fix was to move every foot along the circle the body is turning around: the front feet step one way, the rear feet the other.

Steering is a few lines on top. For “go to the ball”, the legs compare the direction of the ball with the direction the dog faces. They turn toward it, walk faster when facing it, and stop at a set distance. “Turn left” means 90 degrees from wherever the dog faced when it heard the command. “Sit” lowers the rear hips.

The same C file runs on the Mac and inside the image. Built with the image’s own math functions, the two produce the same body states and camera frames over a 40-second run, byte for byte.

## The brain: choosing, not writing

The obvious way to use a chat model as a robot’s brain is to ask it to write the action. That fails in the obvious way: it writes “GO BOX” without the “ACTION:” in front, or invents an action that doesn’t exist.

So the brain never writes the action. The prompt describes the allowed actions and ends with `ACTION:`. Then, for each allowed action (FETCH BALL, GO BOX, GO PERSON, STOP, COME BACK, TURN LEFT, TURN RIGHT, SIT, NONE), the model scores how likely it would be to write it next. The most likely one wins. The answer is always something the legs can do, and the same input always gives the same answer. Only then does the model write a short reply after `SAY:`, and that one is free text.

The scene goes into the prompt in words, worked out from the positions on the blackboard and the dog’s own pose:

```
heard "Good job. Now go to the man in the yellow shirt."
sees  the red ball, 0.4 m ahead; the blue box, 2.7 m to your right;
      a person in a yellow shirt, 3.4 m ahead.
does  GO PERSON, says "I'm coming to you." (868 ms)
```

That line about the yellow shirt matters. In a first test without the scene, Llama got 12 of 14 commands right, and one of the misses was “the yellow man”, which it sent to the box. With the scene in the prompt, all seven commands in the demo came out right. Each decision takes 0.8 to 0.9 s on four cores.

## The ears: hearing and speaking for someone else

The ears are the real-time voice loop from the earlier demo, with one change: they no longer answer with their own chat model. When you stop speaking, they post the transcript on the blackboard and wait for a reply to appear, then speak it while they go back to listening.

## One command, end to end

Here is “Stop!” in the middle of a walk to the box, with the times from the run in the video:

1. You stop speaking. The ears notice the silence and transcribe what you said. The transcript is on the blackboard **0.67 s** later.
2. The brain sees a new value in the heard slot, describes the scene, and scores the nine actions. STOP and “Stopping.” are posted **0.82 s** later.
3. The legs read the new action at their next control step, at most **20 ms** later, and command a stand.
4. The ears pick up the reply and start speaking. Their voice starts **1.6 s** after you stopped talking.

Over the seven commands, the voice starts 1.6 to 2.8 s after you stop. Most of that is the speech recognizer, which runs on a single core in this image. Giving it more cores, as the Mac build already can, is the obvious next step.

## What is simulated

So nobody is misled:

- **The body is simulated.** It’s MuJoCo, not a robot.
- **Where things are comes from the simulator.** It writes the positions of the ball, the box and the person onto the blackboard. Nothing reads the camera yet.
- **The voice giving the commands is the Mac’s speech synthesizer** , fed in as a recording.
- **The ears image carries a small chat model it doesn’t use.** The image builder still requires one.

What is real: every model and every decision. They’re compiled from GGUF files to C by GGUFC and run in the kernel images, which connect to each other only through that block of memory.

## What’s next

The eyes. The vision-language model from the driving demo can answer questions about a camera frame twice a second. As a fourth image it would replace the simulator’s positions with what the dog actually sees. After that, the real thing: the images on an RK3588 board, a real microphone, and eventually real legs.

## Try it

Everything is in the [GGUFC repository](https://github.com/antonellof/ggufc). The [robot page](https://github.com/antonellof/ggufc/blob/main/docs/robot.md) explains the parts and how to run them. You need MuJoCo, the Menagerie models, QEMU and the three GGUF files. Then one script boots the three images and the body:

```
tests/brain/robot.sh out/robot-brain out/robot-ears commands.f32 100 out/robot/run
```

The code is Apache-2.0.
