How ai-fange/microduck-build-tutorial works
Microduck combines Raspberry Pi robot deployment with a MuJoCo/MjLab reinforcement-learning environment. Its main runtime workflow accepts keyboard or gamepad commands, schedules the walking move, reads robot state, and sends motor targets to Dynamixel servos; training produces an ONNX policy for deployment. The tree and README identify additional motion, simulation, monitoring, and training capabilities, but several source files were not sampled, so uncertain internal wiring is omitted.
Main entry points: scheduler.py Move scheduler · robot_controller.py Robot controller · main.py Runtime entry · input_source.py Input selection
Components 25
Robot runtime
- Runtime entry
microduck/src/main.py - Input selection
microduck/src/input/input_source.py - Keyboard input
microduck/src/input/keyboard_input.py - Gamepad input
microduck/src/input/gamepad_input.py - Headless gamepad service
microduck/src/gamepad_daemon.py - Move scheduler
microduck/src/scheduler.py - Walking move
microduck/src/moves/walk.py - Other moves
microduck/src/moves - Robot state observer
microduck/src/observer.py - Stop control
microduck/src/stop.py - Walking ONNX policy
microduck/src/agents
Robot hardware
- Robot controller
microduck/src/robot_controller.py - IMU reader
microduck/src/imu_reader.py - Dynamixel servo bus
- BNO08x IMU
- Voltage monitoring
microduck/src/voltage.py
Simulation tools
- Simulation entry
microduck/src/sim/sim_main.py - MuJoCo controller
microduck/src/sim/mujoco_controller.py - Placo viewer
microduck/src/sim/placo_controller.py - Simulation viewer
microduck/src/sim/viewer_main.py
Policy training
- Velocity training environment
mjlab_microduck/src/mjlab_microduck/tasks/microduck_velocity_env_cfg.py - Rewards and curricula
mjlab_microduck/src/mjlab_microduck/tasks/mdp.py - ONNX export
mjlab_microduck/src/mjlab_microduck/scripts/export_onnx.py
Other components
- Operator
- Bluetooth gamepad
Connections 28
- Operator → Runtime entry: starts
- Operator → Keyboard input: enters commands
- Bluetooth gamepad → Gamepad input: sends controls
- Bluetooth gamepad → Headless gamepad service: starts or stops
- Headless gamepad service → Runtime entry: launches control
- Runtime entry → Input selection: selects input
- Runtime entry → Robot controller: initializes hardware
- Runtime entry → Move scheduler: starts loop
- Input selection → Keyboard input: falls back to
- Input selection → Gamepad input: selects connected
- Keyboard input → Move scheduler: provides commands
- Gamepad input → Move scheduler: provides commands
- Move scheduler → Walking move: dispatches move
- Move scheduler → Other moves: dispatches moves
- Walking move → Walking ONNX policy: loads policy
- Walking move → Robot controller: reads state and sends targets
- Move scheduler → Robot controller: coordinates control
- Robot state observer → Robot controller: reads robot state
- Robot controller → Dynamixel servo bus: reads and writes
- Robot controller → IMU reader: starts reader
- IMU reader → BNO08x IMU: reads orientation
- Voltage monitoring → Robot controller: reads voltage
- Stop control → Move scheduler: requests stop
- Simulation entry → MuJoCo controller: selects simulation
- Simulation entry → Placo viewer: selects viewer
- Simulation viewer → MuJoCo controller: opens simulation
- Velocity training environment → Rewards and curricula: uses task terms
- ONNX export → Walking ONNX policy: exports model