Skip to content

RFC-0002 — The robot brain: modes, navigator, safety and phases

Status: Proposed, revision 3 (2026-11-14): two reviews (round 1, round 2) and the operator's decisions taken in. Phase 0 approved by the operator. Builds on: ECOSYSTEM.md, MICRODUCK.md, RFC-0001 (the NXT's safety lessons). Part of a set: RFC-0003 (the robot interface), RFC-0004 (missions in words, models, perception, planning), RFC-0005 (missions with flotilla and eval-harness). Replaces: the draft docs/wip/ROBOT-BRAIN.md (2026-11-13).

1. Motivation

The operator's goal: tell the Microduck, in plain words, something like "visit every room, tell me roughly how big each is, then wait for me by the front door" — and have it do that on its own, with models on the homelab DGX. Later the NXT joins through the same brain.

A mission is explore + report + an end. The end is one of three options (operator, 2026-11-14), passed with the mission:

End In words In the simulated apartment
A. Landmark (first) "…then go to the front door" stop 1 m from the coat rack at the corridor's north end
B. Start "…then come back" return to where the mission began
C. Largest room "…then wait in the biggest room" stop in the doorway of the room it measured largest

Each end needs the whole home explored first, and each ends at a checkable place. (A kitchen table to hide under was the first idea; the simulated apartment has none a 25 cm duck fits under, so it was dropped.)

The duck walks, balances and keeps a map on board; it cannot be sent somewhere, and leaves planning to "the autonomy layer". This RFC is that layer. Facts about the duck come from /work/pollen/microduck (API v61), checked by the review.

2. What the duck gives, and what it does not

Gives:

  • One interface: JSON-RPC 2.0, one object per line, over Unix sockets, one socket per daemon; a subscription owns its connection.
  • Moving: robot.move {vx, vy, vyaw} (m/s, rad/s), sent repeatedly; robot.head, robot.look, robot.do {skill}, robot.stop, robot.flashlight (an RGB light any client may set; refused in the simulator, which has none).
  • State: robot.subscribe streams odometry, the applied twist and who sent it, what limited it (e.g. deadman), fall and pick-up flags, whether the duck's own autonomy is on.
  • Depth: a VL53L8CX, 8×8 zones over 45°, about 15 times a second — "a cane, not a lidar": the useful median range is about 0.5 m.
  • Map: mapd keeps an occupancy grid built at stops (map.grid, pose, a lost reason). It has no go-to; it has map.wipe, which the brain never calls. It maps only while the duck's autonomy is on, unless [map] enabled = true (off by default upstream because its standing CPU cost on the board has not been measured).
  • Camera: GET /frame on the duck's console — in the simulator at 127.0.0.1:8080; on the robot only on its own loopback (since daemon 0.19 the console is not on the LAN; a laptop reaches it through duckctl open or an ssh tunnel); media.stream for pushing video to a remote receiver.
  • A 500 ms deadman: the twist goes to zero if move commands stop. Stop is not limp.

Does not give, and what that forces:

  1. No speed clamp. The brain keeps inside the walking policy's training: forward 0.15–0.3 m/s (trained ±0.4; upstream reports no walking below about 0.2 m/s in simulation and autod never asks for less than 0.15 m/s, with a short full-speed start), turning ≤ 1.0 rad/s (trained ±1.0).
  2. No arbitration — last writer wins. autod yields only to the gamepad (and to an external soccer game). So the duck's autonomy and our navigator never drive at the same time (§3.1).
  3. No obstacle stop of its own (it lives in autod). When our navigator drives, it stops on the depth sensor itself, every frame.
  4. No path planning: upstream lists "go there" as not built. We build the navigator.
  5. The map grows only at stops: a stop opens after a few seconds with no twist asked for. Exploring is: walk a little, stop, look around (a survey), repeat.
  6. The deadman needs a fresh move command at least every 0.5 s, so whatever sends them must be on the LAN or on the robot.

3. Proposal

3.1 Two modes, one switch

Mode Who drives Mapping The brain
auto (explore) the duck's own autod: wanders, avoids obstacles, ends each wander in a 4–6 s survey (with mapping on, as it is in this mode) on by itself watches: copies the map, labels rooms from the camera, collects data
brain our navigator on ([map] enabled = true) drives to goals and to the mission's end

The switch is robot.autonomous on/off, flipped by the brain (or the operator). On the real duck the flashlight shows the mode (green auto, blue brain, red stopped or waiting for the operator); the simulator refuses robot.flashlight, so the brain logs the refusal and carries on, and the lamp is checked in phase 5.

A mission can use both: explore in auto while the brain watches, then switch to brain to finish (end A/B/C) — reusing upstream's tested explorer and obstacle handling. Whether autod's novelty-driven wandering covers every room in reasonable time is measured in phase 2; if not, the brain explores itself.

3.2 Layers

 instruction ─► PLANNER   words → mission spec → tool calls          seconds       (RFC-0004)
                  ▼
               BRAIN      world model, perception, mode, run log      0.5–2 Hz
                  ▼ goals (x, y), surveys, skills, head
               NAVIGATOR  path on the map, depth + cliff stop,        10–20 Hz      we build it
                          limits, deadman refresh, measured odometry
                  ▼ JSON-RPC                                                        (RFC-0003)
               ROBOT      the duck's daemons (later the NXT service)  50 Hz
  • The LLM never sends a twist. It chooses the next step; the navigator moves; the robot balances. A slow or failed model call means the robot waits, standing.
  • Navigator (ours): A* on map.grid at 10 cm, keeping 15 cm clear of walls (as autod checks); pure pursuit to the next waypoint; frontier exploration toward unseen floor; surveys (send no twist, sweep the head, wait until mapd reports collecting); a depth stop distance and a cliff check every frame. It closes its loop on measured odometry, never on commanded speed, and logs commanded vs measured per run — the simulator walks at about 44 % of what is asked.
  • Run record (written as MCAP for Foxglove, ADR-0001): every run records the instruction, the mission spec, every tool and model call with latency and cost, poses, mode switches, map snapshots, the outcome — the input to eval-harness (RFC-0005).

3.3 Where things run, and how they reach the duck

The duck's daemons listen on Unix sockets, which are files on the duck: unreachable over the network on purpose. ssh carries them to the workstation:

workstation                                         the duck (Wi-Fi)
/tmp/duck/robotd.sock ══ ssh -L … microduck@duck ══► /run/robotd.sock
/tmp/duck/tof.sock    ══════════════════════════════► /run/tofd/tof.sock
/tmp/duck/map.sock    ══════════════════════════════► /run/mapd/map.sock

Our software connects to the local socket files exactly as if it were on the duck — and in the simulator they are local files in ~/.cache/duck-sim/, so the same code drives both; only the paths change. This is upstream's documented developer path (running the gamepad program from a laptop: docs/robot/cheatsheet-dev.md). ssh on Wi-Fi is opened with the face button (30 min), over USB until reboot, or kept open by the developer image. Frames come through the same ssh session (-L 8080:127.0.0.1:8080, then /frame), since the console is on the robot's loopback only.

Simulator (phases 0–4) Real duck (phase 5)
Link local sockets ssh-forwarded sockets over the LAN
Navigator, brain, planner client workstation workstation
Models LiteLLM aliases (RFC-0004) same

The Hugging Face relay ("rendezvous": JSON-RPC over HTTP/SSE, 1200 requests and 400 notifications a minute, no pixels) is for a brain away from home, not for the navigator.

3.4 Phases

# Phase Done when
0 Spike: is the simulator a usable stand-in? Turning in the backlash scene; the backlash robot in the apartment; mapd with [map] enabled = true beside duck-sim ~~Turning on the spot within 20 % of upstream's ~50°/s~~ turning that is repeatable, with a navigator that compensates (operator, 2026-11-14, after the spike); the duck walks in the apartment; the map gains keyframes with autonomy off. Done 2026-11-14
1 Groundwork + navigator. Project (uv), JSON-RPC client, modes, navigator Bar revised by the operator, 2026-11-14 (the first runs showed refusals passing, no definition of reached, no falls): 20 go-to goals from the dock with a fixed seed, within reach of what the duck has seen or sees on the way (office, corridor, through open doorways; rooms behind unseen walls are phase 2). Safe: zero falls, zero contacts (trunk centre within 8.3 cm of an obstacle's outline: the duck's measured size), upright throughout. Finishes: every goal reached or refused with a reason, no timeouts. Accurate: ≥ 18 reached within 25 cm of the goal by simulator truth. Logged: every run viewable in Rerun. Odometry is calibrated per robot (operator: option a) — the simulated duck now, the real one in phase 5. Met 2026-11-14 (run 8: 20 of 20, no contacts, no falls; PHASE1-RESULTS.md)
2 Explore, map, rooms (both ways: autod exploring with the brain watching, and the brain exploring) Bar changed by the operator, 2026-11-15: the challenge course first (RFC-0008: one difficulty per scene, pass rates by truth); then, as the final exam: all six rooms visited; each room's area within ±25 % of apartment.xml's floor boxes; time per way compared
3 Perception (RFC-0004) Room type right at most survey stops; the coat rack found from every start
4 Missions in words End A from ≥ 10 start poses, then B and C, scored by eval-harness; mission specs from sentences checked offline. End A is evaluated from the camera bearing and odometry (the coat rack is a 4 cm pole the map will not hold), and graded against simulator ground truth: the trunk's distance to the coat-rack geom
5 Real duck mapd's CPU cost on the board measured; the same score sheet, simulator vs real, with the commanded/measured speed gain as the first comparison

3.5 Prerequisites in the simulator

  • Phase 0 was run on 2026-11-14: PHASE0-SPIKE.md.
  • mapd is not started by duck-sim: phase 0 adds [map] enabled = true to the sim's robotd.toml and starts it against the sim's sockets and a map file of its own: mapd --config ~/.cache/duck-sim/robotd-duck-a.toml --robot-socket ~/.cache/duck-sim/duck-a.sock --tof-socket ~/.cache/duck-sim/duck-a-tof.sock --socket ~/.cache/duck-sim/duck-a-map.sock --map ~/.cache/duck-sim/duck-a-map.json (its defaults are the robot's /run/… paths).
  • The apartment scene carries the robot without backlash, on which the walking policy does not step: phase 0 makes a backlash variant. Scene changes are offered to Pollen, not forked silently.
  • The corridor has a staircase hole (mid-south; the coat rack is at the north end), on the way when approaching from the south: the cliff check is tested there.

3.6 Safety

Limits: §2.1 speeds, a depth stop distance, a maximum mission time, a geofence (cells mapped free, plus the frontier). An operator STOP sends robot.stop directly, never through the planner. The planner's tools are an allowlist; every model call has a timeout. Every STOP path runs on the workstation today; the robot's own deadman is the backstop. Real-duck missions need the operator in the room with a STOP at hand (phase 5 precondition): the depth sensor sees only a 45° wedge ahead, so a dog arriving from the side or behind is not seen.

Situation Rule
The duck's autonomy switched on while the brain drives (NFC tag, robotctl) Watch autonomous in every state frame; stop, mark the mission interrupted; resume only when it is off and the operator says so
Someone else drives (a gamepad, a second brain) Name each run robot-brain-<run-id> (hello), hold a per-robot lock; if move.source is not us, stop and report
Wi-Fi drops The deadman stops the duck. Reconnect with back-off, re-read pose, map.status and the driver; resume only if not lost, still the driver, within the mission's time; else survey or ask
Lost (carried, bumped, sat, fell, contradiction, or a reason not known) No pose → no geofence: turn-in-place surveys only (upstream relocalises after two agreeing stops); not found after N → abort and report
Fall, pick-up or bump The duck stands itself up; the mission drops out of auto and resuming needs the operator's OK (never walk back into the dog)
The floor disappears ahead (stairs) Stop, treat as an obstacle, never cross

3.7 Frames of reference: dead reckoning with fixes

Frame What it is Source
trunk the duck's body: x forward, y left, z up; move commands are in it robot.move
odom position from legs and gyro since boot; 50 Hz and smooth, but it drifts robot.state.odom
map mapd's floor plan, origin at its first stop, "no north"; it jumps when corrected, does not drift map.stream, map.grid

The standard arrangement (ROS: map → odom → base_link), and what autod does. It is a navigator's dead reckoning: odometry is the log and compass, a survey stop is taking a fix, the map→odom offset is the fix plotted, and "lost" is fog. The navigator keeps one offset: at each mapd pose, offset = map pose − odom pose at the same t_ns; between fixes, position on the map = latest odometry + offset. Upstream measured the simulator's drift at about 0.3 % per metre; the real robot's is not measured.

3.8 Building the navigator

Python, as pure functions (state in, command out, no sockets inside, like autod's brain), unit tested on recorded state and replayed offline before it drives:

  1. Cost map: map.grid at 10 cm every few seconds; obstacles grown by about 15 cm plus the duck's half-width; unknown cells expensive, not forbidden.
  2. Path: A* to the goal; replan when the map changes or the path is blocked.
  3. Following: pure pursuit to a point about 30 cm ahead → forward speed 0.15–0.3 m/s and turn ≤ 1.0 rad/s; turn on the spot first when the heading is over about 45° off; a short full-speed start; speed and turn corrected from measured odometry.
  4. Reflexes, every depth frame: something close ahead → stop; floor gone → stop.
  5. Deadman: a move command every 100 ms while walking.
  6. Surveys: a zero twist (or none), head sweep, wait for collecting. mapd counts a twist under 0.02 m/s and 0.05 rad/s as "not commanded" (maploc/src/input.rs), so the navigator may keep sending zeros.
  7. Exploring: the nearest worthwhile frontier (free cells next to unknown).

The concepts and frame names follow ROS 2 Nav2, the standard navigation stack, so moving to Nav2 later stays possible. Not now: it means installing ROS 2 and bridging the duck's JSON-RPC, and Nav2's defaults assume a 360° range sensor, not a 45° short-range depth sensor.

The duck's daemons listen only on files inside the duck, on purpose: nothing on the network drives it without an authenticated door. Upstream's doors: the WebRTC control channel (browser and app; the same JSON-RPC), the Hugging Face relay (programs anywhere; rate-limited, no pixels), Bluetooth (setup only), and ssh (developers). Across robotics the pattern is the same: fast loops on the robot, slow thinking off it (ROS 2 topics, vendor APIs such as Spot's gRPC SDK, WebRTC or DDS, MQTT for fleets).

  1. Now: the simulator's local sockets.
  2. First real-duck runs: ssh-forwarded sockets — the real duck looks exactly like the simulator, no new code. A developer tool, not the end state.
  3. Grown up: the navigator runs on the duck beside autod (it is a Linux computer); the brain stays off-board and talks to it through the relay, the WebRTC channel, or our own JSON-RPC (RFC-0003). The reflex loop no longer crosses Wi-Fi. Decided by the operator (2026-11-14): the navigator moves onto the robot mid-term (on the NXT, onto a Pi riding on the brick). The v1 non-goal "no code of ours on the duck" holds until then.

3.10 Several robots, the brain's API and its UIs

Several missions at once: the brain holds several robots and oversees one mission per robot in parallel — a navigator per robot (near it), a lock per robot, a mission case per robot.

Robots working together (the duck watches, the NXT drives) is a later phase (operator, 2026-11-14), because it needs new concepts: a shared map with a common frame (markers on the floor both can see, or the duck's camera locating the NXT), shared objects, and a mission that spans robots. Phase 6 below; also on the roadmap.

The UI into the brain: the brain has an API (JSON-RPC: mission.start, mission.stop, status, an events stream) and every UI is a client of it:

Client For
Mission control page (grown from nxt-web, RFC-0006) from the start: type a mission, see the spec read back, confirm; robots and modes; a big STOP
A Slack app from the start: notifications and simple commands; approvals move to flotilla when connected
flotilla's operator UI later: missions as cases, approvals with evidence, history
Foxglove (ADR-0001) watching: map, path, pose, camera, decisions on one timeline
The command line scripts and tests
An MCP server from the start: talking to the robots from Claude or any agent
# Phase (after 5) Done when
6 Robots working together: shared map and common frame, shared objects, missions across robots The duck and the NXT localise in one frame and complete one joint mission in simulation and at home

4. Non-goals (v1)

  • Training walking policies (separate work, MICRODUCK.md).
  • The LLM controlling motion, or anything in the 50 Hz loop.
  • Changing the duck's own daemons; our code on the duck.
  • Robots working together in one mission (a shared map and more; §3.10, phase 6); the NXT joins after phase 4.

5. Open questions

  1. autod's coverage in auto mode — measured in phase 2.
  2. mapd's CPU cost on the real board with [map] enabled = true — measured in phase 5.
  3. Room segmentation on a coarse grid from a short-range sensor — phase 2.
  4. ~~Whether mapd treats a zero twist as "no twist asked for"~~ Answered from source: yes, a deadband (§3.8); confirmed empirically in phase 0.
  5. Where the brain runs long-term (workstation, DGX, an always-on box).
  6. ~~Whether the navigator moves onto the duck~~ Decided: yes, mid-term (§3.9).

6. Alternatives considered

  • Give autod goals: not possible; it takes none and listens on no socket.
  • Let the LLM send twists: rejected — model latency is seconds, the deadman 0.5 s, and a stop must not wait for a model.
  • Run autod and our navigator together: rejected — no arbitration; they would alternate.
  • Everything over the relay: rejected for the navigator (rate limits, no pixels).
  • ROS 2 as the foundation: not now (ADR-0001): no install or bridges yet, and Nav2 assumes a lidar. Terms and data shapes follow ROS so joining later is a bridge; reconsidered for the arm robot (MoveIt), ready-made SLAM, or several robots.
  • The navigator as a daemon on the robot: not needed; ssh-forwarded sockets give the same interface on the LAN.

7. Discussion

  • 2026-11-13 — Draft as docs/wip/ROBOT-BRAIN.md; the operator approved phase 0 and the phase-1 models.
  • 2026-11-13 — Operator: the combined mission loop is the direction (RFC-0005).
  • 2026-11-14 — Split into RFC-0002 to RFC-0005 at the operator's request.
  • 2026-11-14 — Independent review (REVIEW). Operator: drop the kitchen table; missions take end options A/B/C, A first, described in plain words; two modes (auto / brain) with a switch, watching and collecting data during auto; the navigator is ours; ssh-forwarded sockets for the real duck. Revision 2 applies all of it, plus the stairs check.
  • 2026-11-14 — Operator asked how the navigator is built and why an ssh tunnel; added §3.7 frames (dead reckoning with fixes — the operator's sailing analogy), §3.8 the navigator build, §3.9 how the link evolves (navigator on the duck as an open decision).
  • 2026-11-14 — Second review (round 2): /frame is loopback only on the robot (the session's own error in revision 2); the flashlight is refused in the simulator; the exact mapd command; the stop deadband; the end-A oracle; operator in the room for real-duck missions. Operator: the navigator moves onto the robot mid-term; the brain oversees several missions; robots working together is phase 6 (§3.10). Revision 3.
  • 2026-11-14 — Operator: ROS 2 not the foundation now, terms aligned with ROS, Foxglove from the start — recorded as ADR-0001.
  • 2026-11-14 — Phase 0 run (PHASE0-SPIKE.md): the apartment and mapping pass; turning misses upstream's 50°/s (no start below ~1.1 rad/s from a stand, about half the asked rate once stepping). Operator chose option 2: the bar becomes repeatable turning and a navigator that compensates (kick-start, closed loop on heading), measured in phase 1's go-to goals.
  • 2026-11-14 — Phase 1, first three evaluation runs (duck/runs/phase1-run*): goals beyond the map were refused, a stranding wall margin, routes past half-seen furniture, the duck's odometry ~11 % long against truth, and a fall down the staircase: the duck walked onto the opening along a route 3 cm from its edge, with no cliff check (first written here as "while turning on the spot"; the log shows it was walking). The operator revised phase 1's bar (§3.4), approved the order — cliff check, no turning near a drop or a wall, odometry calibration (per robot), the test rescoped and rescored with the duck's measured size — and chose calibration for odometry; then options 2 and 3 together (scale odometry, mapd's poses and its grid by the measured factor, per robot: duck/calibration/sim.json, 0.91 at 0.3 m/s), with the finding drafted for Pollen.