# rhoban/microban architecture

> Architecture diagram of the GitHub repository rhoban/microban, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rhoban/microban
- Repository: https://github.com/rhoban/microban

## Overview

#### Purpose and deliverables
Microban is an open hardware/software platform for a ~30 cm, 19-DOF humanoid built around Dynamixel XL330 servos, a Raspberry Pi Zero 2W, and a Robot Hat. The repository combines printable mechanical design, assembly/deployment documentation, robot-control software, and simulation assets.

- Printable production models: `cad/stl/`, `cad/step/`
- Build, operation, and deployment procedures: `docs/assembly.md`, `docs/deployment.md`, `docs/usage.md`

#### Runtime entry points
The physical-robot application starts in `src/main.py`; its orchestration is divided among `src/controller.py`, `src/robot_controller.py`, and `src/scheduler.py`. A separate gamepad process is provided by `src/gamepad_daemon.py` and deployable as a system service through `systemd/microban-gamepad.service`.

Simulation has distinct entry points in `src/sim/sim_main.py` and `src/sim/viewer_main.py`.

#### Input-to-command boundary
Operator input is abstracted behind the input package, allowing keyboard and gamepad implementations to feed the same control layer.

- Input contract and implementations: `src/input/input_source.py`, `src/input/keyboard_input.py`, `src/input/gamepad_input.py`
- Gamepad service boundary: `src/gamepad_daemon.py`, `systemd/microban-gamepad.service`

The input layer should remain independent of servo transport and individual motions; it expresses user intent for the controller/scheduler.

#### Motion and behavior layer
Reusable robot actions are organized as move implementations, including head rotation, squatting, and walking. The walking stack includes a packaged ONNX model, making learned inference a material runtime dependency/data artifact.

- Move abstraction and behaviors: `src/moves/move.py`, `src/moves/walk.py`, `src/moves/squat.py`
- Learned walking asset: `src/agents/walk.onnx`

Control flow is expected to be: input event → controller/scheduler selection or update of a move → joint-level robot command. Stop handling is explicitly separated in `src/stop.py`.

#### Hardware-control and sensing boundary
Physical actuation is isolated in the robot controller path, while IMU and voltage modules provide hardware observations. This is the principal boundary between high-level behavior and the Raspberry Pi/Robot Hat/Dynamixel-connected robot.

- Hardware command path: `src/robot_controller.py`, `src/controller.py`
- IMU acquisition/interface: `src/imu.py`, `src/imu_reader.py`
- Power monitoring: `src/voltage.py`
- Shared robot constants: `src/constants.py`

The observer component (`src/observer.py`) is the likely aggregation point for state/feedback used by control behavior.

#### Simulation and model boundary
MuJoCo-facing adapters mirror portions of the physical control and input paths, enabling behaviors to run against a simulated robot rather than hardware. The canonical simulation geometry/kinematics are represented in MJCF, with a parallel URDF model.

- Simulation adapters: `src/sim/mujoco_controller.py`, `src/sim/mujoco_input.py`, `src/sim/placo_controller.py`
- MuJoCo model and scene: `src/model/mjcf/robot.xml`, `src/model/mjcf/scene.xml`
- Alternate robot description: `src/model/urdf/robot.urdf`

This separation permits controller and move logic to be exercised with simulated interfaces, while model assets remain distinct from printable manufacturing CAD.

#### Mechanical design and deployment infrastructure
Manufacturing files are STEP/STL assets; MJCF assets are simulation-specific representations and should not be conflated with print artifacts.

- Manufacturing design: `cad/step/`, `cad/stl/`
- Simulation mesh assets: `src/model/mjcf/assets/`
- Raspberry Pi setup and SD configuration: `docs/dev/setup_rasp.md`, `docs/dev/clone_sd.md`, `docs/dev/config.txt`
- Service installation: `systemd/install-gamepad-daemon.sh`

Main entry points: [`src/controller.py`](https://github.com/rhoban/microban/blob/main/src/controller.py) (Control orchestration), [`src/moves/move.py`](https://github.com/rhoban/microban/blob/main/src/moves/move.py) (Robot moves), [`src/sim/mujoco_controller.py`](https://github.com/rhoban/microban/blob/main/src/sim/mujoco_controller.py) (MuJoCo control adapters), [`src/scheduler.py`](https://github.com/rhoban/microban/blob/main/src/scheduler.py) (Move scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_physical["Physical robot runtime"]
  node_main["Robot application<br/>entry point<br/>[main.py]"]
  node_input["Operator input<br/>input contract + drivers<br/>[input_source.py]"]
  node_gamepad_daemon["Gamepad daemon<br/>input process<br/>[gamepad_daemon.py]"]
  node_controller["Control orchestration<br/>controller<br/>[controller.py]"]
  node_scheduler["Move scheduler<br/>[scheduler.py]"]
  node_moves["Robot moves<br/>move behaviors<br/>[move.py]"]
  node_stop["Stop handling<br/>safety control<br/>[stop.py]"]
  node_robot_controller["Robot controller<br/>hardware command boundary"]
  node_observer["Robot observer<br/>feedback aggregation<br/>[observer.py]"]
  node_sensors["IMU and power sensing<br/>hardware observations<br/>[imu.py]"]
  node_hardware{{"Physical humanoid"}}
end

subgraph group_simulation["Simulation"]
  node_sim_main["Simulation runner<br/>entry point<br/>[sim_main.py]"]
  node_sim_adapters["MuJoCo control adapters<br/>simulation interfaces"]
  node_mjcf["MuJoCo robot scene<br/>MJCF model<br/>[scene.xml]"]
  node_urdf["Alternate robot model<br/>URDF<br/>[robot.urdf]"]
end

subgraph group_assets["Assets and deployment"]
  node_gamepad_service["Gamepad system service<br/>systemd unit"]
  node_walk_model["Walking policy<br/>ONNX model<br/>[walk.onnx]"]
  node_cad["Printable mechanical design<br/>STEP and STL assets"]
  node_docs["Build and deployment docs<br/>procedures<br/>[assembly.md]"]
end

node_main -->|"reads intent"| node_input
node_main -->|"starts"| node_controller
node_controller -->|"selects and updates moves"| node_scheduler
node_scheduler -->|"runs"| node_moves
node_moves -->|"uses for walking"| node_walk_model
node_moves -->|"joint commands"| node_robot_controller
node_stop -->|"stops active move"| node_scheduler
node_controller -->|"coordinates commands"| node_robot_controller
node_robot_controller -->|"actuates"| node_hardware
node_hardware -->|"provides IMU and voltage"| node_sensors
node_sensors -->|"observations"| node_observer
node_observer -->|"feedback"| node_controller
node_gamepad_service -->|"launches"| node_gamepad_daemon
node_gamepad_daemon -->|"feeds gamepad intent"| node_input
node_sim_main -->|"runs with"| node_sim_adapters
node_sim_adapters -->|"executes shared behaviors"| node_moves
node_sim_adapters -->|"controls simulated model"| node_mjcf
node_mjcf -.->|"parallel robot descriptions"| node_urdf
node_cad -.->|"separate from simulation assets"| node_mjcf
node_docs -.->|"installation procedure"| node_gamepad_service

click node_main "https://github.com/rhoban/microban/blob/main/src/main.py"
click node_input "https://github.com/rhoban/microban/blob/main/src/input/input_source.py"
click node_gamepad_daemon "https://github.com/rhoban/microban/blob/main/src/gamepad_daemon.py"
click node_gamepad_service "https://github.com/rhoban/microban/blob/main/systemd/microban-gamepad.service"
click node_controller "https://github.com/rhoban/microban/blob/main/src/controller.py"
click node_scheduler "https://github.com/rhoban/microban/blob/main/src/scheduler.py"
click node_moves "https://github.com/rhoban/microban/blob/main/src/moves/move.py"
click node_walk_model "https://github.com/rhoban/microban/blob/main/src/agents/walk.onnx"
click node_stop "https://github.com/rhoban/microban/blob/main/src/stop.py"
click node_robot_controller "https://github.com/rhoban/microban/blob/main/src/robot_controller.py"
click node_observer "https://github.com/rhoban/microban/blob/main/src/observer.py"
click node_sensors "https://github.com/rhoban/microban/blob/main/src/imu.py"
click node_sim_main "https://github.com/rhoban/microban/blob/main/src/sim/sim_main.py"
click node_sim_adapters "https://github.com/rhoban/microban/blob/main/src/sim/mujoco_controller.py"
click node_mjcf "https://github.com/rhoban/microban/blob/main/src/model/mjcf/scene.xml"
click node_urdf "https://github.com/rhoban/microban/blob/main/src/model/urdf/robot.urdf"
click node_docs "https://github.com/rhoban/microban/blob/main/docs/assembly.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_input,node_gamepad_daemon,node_controller,node_scheduler,node_moves,node_stop,node_robot_controller,node_observer,node_sensors,node_hardware toneBlue
class node_sim_main,node_sim_adapters,node_mjcf,node_urdf toneAmber
class node_gamepad_service,node_walk_model,node_cad,node_docs toneMint
```

## Components

### Physical robot runtime

- [Robot application](https://github.com/rhoban/microban/blob/main/src/main.py): entry point · `src/main.py`
- [Operator input](https://github.com/rhoban/microban/blob/main/src/input/input_source.py): input contract + drivers · Keyboard and gamepad implementations express control intent. · `src/input/input_source.py`
- [Gamepad daemon](https://github.com/rhoban/microban/blob/main/src/gamepad_daemon.py): input process · `src/gamepad_daemon.py`
- [Control orchestration](https://github.com/rhoban/microban/blob/main/src/controller.py): controller · `src/controller.py`
- [Move scheduler](https://github.com/rhoban/microban/blob/main/src/scheduler.py): scheduler · `src/scheduler.py`
- [Robot moves](https://github.com/rhoban/microban/blob/main/src/moves/move.py): move behaviors · Reusable walking and squat actions implement the move abstraction. · `src/moves/move.py`
- [Stop handling](https://github.com/rhoban/microban/blob/main/src/stop.py): safety control · `src/stop.py`
- [Robot controller](https://github.com/rhoban/microban/blob/main/src/robot_controller.py): hardware command boundary · Translates joint commands for the Robot Hat and Dynamixel robot. · `src/robot_controller.py`
- [Robot observer](https://github.com/rhoban/microban/blob/main/src/observer.py): feedback aggregation · `src/observer.py`
- [IMU and power sensing](https://github.com/rhoban/microban/blob/main/src/imu.py): hardware observations · `src/imu.py`
- **Physical humanoid**: Raspberry Pi / Robot Hat / servos

### Simulation

- [Simulation runner](https://github.com/rhoban/microban/blob/main/src/sim/sim_main.py): entry point · `src/sim/sim_main.py`
- [MuJoCo control adapters](https://github.com/rhoban/microban/blob/main/src/sim/mujoco_controller.py): simulation interfaces · Mirrors control and input paths for simulated execution. · `src/sim/mujoco_controller.py`
- [MuJoCo robot scene](https://github.com/rhoban/microban/blob/main/src/model/mjcf/scene.xml): MJCF model · `src/model/mjcf/scene.xml`
- [Alternate robot model](https://github.com/rhoban/microban/blob/main/src/model/urdf/robot.urdf): URDF · `src/model/urdf/robot.urdf`

### Assets and deployment

- [Gamepad system service](https://github.com/rhoban/microban/blob/main/systemd/microban-gamepad.service): systemd unit · `systemd/microban-gamepad.service`
- [Walking policy](https://github.com/rhoban/microban/blob/main/src/agents/walk.onnx): ONNX model · `src/agents/walk.onnx`
- **Printable mechanical design**: STEP and STL assets
- [Build and deployment docs](https://github.com/rhoban/microban/blob/main/docs/assembly.md): procedures · Assembly, operation, Pi setup, and service installation instructions. · `docs/assembly.md`

## Connections

- Robot application → Operator input: reads intent
- Robot application → Control orchestration: starts
- Control orchestration → Move scheduler: selects and updates moves
- Move scheduler → Robot moves: runs
- Robot moves → Walking policy: uses for walking
- Robot moves → Robot controller: joint commands
- Stop handling → Move scheduler: stops active move
- Control orchestration → Robot controller: coordinates commands
- Robot controller → Physical humanoid: actuates
- Physical humanoid → IMU and power sensing: provides IMU and voltage
- IMU and power sensing → Robot observer: observations
- Robot observer → Control orchestration: feedback
- Gamepad system service → Gamepad daemon: launches
- Gamepad daemon → Operator input: feeds gamepad intent
- Simulation runner → MuJoCo control adapters: runs with
- MuJoCo control adapters → Robot moves: executes shared behaviors
- MuJoCo control adapters → MuJoCo robot scene: controls simulated model
- MuJoCo robot scene → Alternate robot model: parallel robot descriptions
- Printable mechanical design → MuJoCo robot scene: separate from simulation assets
- Build and deployment docs → Gamepad system service: installation procedure
