MicroDuck RL: From Simulation to the Real Robot — Part 02 of 14
This part introduces all the background concepts you will need. If you are already comfortable with MuJoCo and reinforcement learning, feel free to skip ahead to the environment setup in Part 03.
MuJoCo and MuJoCo Warp
- MuJoCo is one of the most widely used physics engines for robot simulation. It excels at rigid-body contact dynamics involving joints, collisions, and friction, and has become a de facto standard for reinforcement-learning research in robotics. Models are defined in MJCF, an XML format that describes bodies, joints, actuators, sensors, collision geometry, and more.
- MuJoCo Warp is a reimplementation of MuJoCo on NVIDIA Warp. Its key advantage is the ability to simulate thousands of environment instances in parallel on a GPU. A traditional setup might run one environment per CPU core; Warp can simulate 4,096 robots simultaneously on a single RTX 5080 at faster than real time. That parallelism is what makes one-to-two-hour locomotion training possible.
The Reinforcement-Learning Loop
This project runs one RL cycle every 0.02 seconds, or 50 Hz:
Observation, obs (61D) ──> Policy network, π ──> Action (14D target joint positions)
↑ │
│ ↓
Reward <── Reward-function evaluation <── One MuJoCo physics step
- Policy: A neural network that maps observations to actions. This project uses a multilayer perceptron (MLP).
- PPO: Proximal Policy Optimization, one of the most widely used policy-gradient algorithms. PPO gathers a batch of experience, or a rollout, estimates the advantage function, and updates the network using a clipped objective that prevents any single update from becoming too large.
- Reward: Your only way to communicate the desired behavior to the robot. “Walk well” must be decomposed into numeric signals: reward target-velocity tracking, penalize falling, penalize foot slip, penalize jerky actions, and so on. RL optimizes exactly what you specify—including loopholes you never anticipated. Part 10 includes real examples, many of which are also documented in the repository’s
AGENTS.md.
Sim2Real and Domain Randomization
Simulation will always differ from reality because of friction, mass, actuator behavior, sensor noise, and many other factors. The standard Sim2Real approach is not to make one simulation perfect. Instead, we randomize physical parameters whenever an environment resets, forcing the policy to work across a distribution of conditions. The physical robot then becomes just another sample from that distribution. Part 05 covers this project’s complete randomization setup.
How the Stack Fits Together
microduck_rl (this repository) Task definition: robot, rewards, DR, curriculum
│
mjlab Training framework: environment wrapper,
│ PPO runner, logging, and viewers
MuJoCo Warp GPU-parallel physics simulation
│
rsl_rl PPO implementation from the ETH Robotics Systems Lab
│
BAM Voltage-level servo model from Rhoban
That is all the theory you need for now. This project is an excellent place to learn by doing and fill in the theory as you go. Part 03 begins the environment setup.