MicroDuck RL: From Simulation to the Real Robot — Part 06 of 14
This part looks at the robot itself and at one of the most underestimated components in the entire pipeline: the actuator model.
Joint Layout: 14 Servos
0–4 Left leg: hip_yaw, hip_roll, hip_pitch, knee, ankle
5–8 Head/neck: neck_pitch, head_pitch, head_yaw, head_roll
9–13 Right leg: mirrored layout of the left leg
The model files live in src/mjlab_microduck/robot/microduck/ and were exported from Onshape CAD using onshape-to-robot. Note that different tasks use different robot models:
| Model | Purpose |
|---|---|
robot_walk.xml |
Walking tasks. Some body and head collision geometries are removed, reducing the cost of falling so that the policy is willing to explore. |
robot_groundcontact.xml |
Tasks involving body contact with the ground, such as standing, rolling, and picking up objects. Uses a carefully selected collision set. |
robot_groundcontact_rollers.xml |
Roller-skating tasks, with passive wheels under the feet |
*_backlash.xml |
Backlash variants. Each joint includes a passive ±1° clearance hinge to model play in the real gears. |
Removing collision geometries to make falling cheaper is an interesting design choice. Falls are frequent during locomotion training. If every fall triggers a large set of collision constraints, the policy may learn “avoid falling at all costs” instead of exploring how to walk. Lowering the cost of a fall gives the policy more freedom to explore.
Why the BAM Actuator Model Matters
In the project’s words: “At this scale—a small servo driving an 800 g biped—actuator fidelity accounts for most of the Sim2Real gap.”
A basic simulation treats each servo as an ideal PD controller. This project uses BAM, or Better Actuator Models, to model the Dynamixel XL330 all the way down to its voltage-level control law, including:
- Back electromotive force
- Coulomb, static, and load-dependent friction
- Battery voltage and voltage sag under load
- Firmware PD gains, including
kp_fw = 200
See src/mjlab_microduck/robot/microduck_constants.py for the configuration.
Modeling Backlash
Real servo geartrains have mechanical play. The repository provides a -Backlash- twin for each task. Every joint includes an unactuated passive_*_backlash hinge with ±1° of travel, and the encoder reading passes through the backlash element, matching the physical robot’s output-side encoder. Policies trained with this model become robust to play in the gears.
The key lesson from this part is simple: the largest part of the reality gap often comes not from contact and friction, but from the actuators themselves. Part 07 shows how to monitor training and watch a policy improve in real time.