Reinforcement Learning for Locomotion and Manipulation
Imitation learning is great when a human can smoothly teleoperate the task, but nobody wants to teleoperate a 12-motor quadruped sprinting up rocky stairs at 50 Hz. For dynamic balance, locomotion, and forceful contact recovery, Reinforcement Learning (RL) lets the robot discover motor strategies we couldn't easily demonstrate by hand.
Core ideas covered in this module
- Dense vs. sparse reward shaping
- Action-rate smoothness penalties
- PPO & curriculum staging
Dense vs. sparse rewards (and the art of not breaking your robot)
If you only give a robot a +10 sparse reward when it reaches a goal, a randomly flailing policy starting two meters away will almost never stumble into the goal by luck — it gets zero learning signal. So we add dense shaping rewards, like subtracting the distance to the target on every step.
Here's the catch: RL optimizers are ruthlessly literal. Whatever loophole exists in your reward formula, the policy will find it. Forget to penalize large motor torques or sudden jumps between consecutive actions, and the policy learns to vibrate violently at 50 Hz or fling itself forward using unrealistic simulator spikes. Crank the energy penalty too high, on the other hand, and the robot discovers a 'lazy' exploit: sit completely still, collect zero action penalties, and ignore the goal altogether.
PPO across parallel worlds and curriculum staging
Most modern sim-to-real locomotion stacks use Proximal Policy Optimization (PPO) paired with thousands of parallel simulation environments. PPO collects short rollouts across all environments, estimates which actions beat the average return (advantage), and updates the policy cautiously within a clipped trust region so one noisy batch doesn't blow up an already decent gait.
Instead of dropping an untrained policy onto 30-centimeter stairs on step one, teams stage a curriculum: start on flat ground at slow walking speeds, and automatically bump up terrain height or obstacle roughness only when the policy proves it can succeed consistently.
Interactive lab
Locomotion & Reach Reward Shaping Sandbox
marimo· LiveBrighter cells mark higher per-step reward. Dashed rings show equal-distance contours around the green goal zone.
Episode Return & Telemetry
Reading reward diagnostics before touching real motors
Try pushing Energy / action penalty high while keeping Dense distance weight low: the trajectory stops cold near the start because staying put earns a higher total episode return than spending energy to move. Now drop the Energy penalty near zero and crank the goal incentives: the agent sprints straight at the goal, blows past it, and rings back and forth.
In real RL tuning, you spend just as much time inspecting action-rate norms (`||a_t − a_{t−1}||²`) and joint velocity histograms as you do watching the success rate curve. A policy that hits 98% success in sim by slamming motors end-to-end will burn out a real gearbox in five minutes.
Standard shaped RL step reward with smoothness regularization
r_t = −w_dist · ‖p_t − p_goal‖ + R_goal · 𝟙[success] − w_act · ‖a_t‖² − w_rate · ‖a_t − a_{t−1}‖²
Task progress pulls the robot toward the goal, while action magnitude and action-rate penalties keep motor commands smooth enough for physical actuators.
During RL training for a quadruped, your robot scores great episode returns in simulation by standing completely frozen in place instead of walking toward the velocity command. Which bug is the most likely culprit?
Isaac Lab and MJX locomotion configs routinely combine 6–10 reward terms — linear/angular velocity tracking, foot air-time, orientation stability, torque, and action-rate penalties — tuned via ablation curves before hardware transfer.
Hands-On Python Notebook
04 · Reward Shaping & Smoothness Penalties Lab
Visualize 2D reward landscapes and see how tuning distance, sparse bonus, and action-rate penalties triggers or prevents reward hacking.
Try this on your own inside the notebook
- Increase the energy penalty until the policy prefers standing still over reaching
- Add an action-rate smoothness term to damp oscillatory banging
In Google Colab, use File → Save a copy in Drive to keep your own edits and notes. Or download the files directly:
uvx marimo edit --sandbox notebooks/course-6/04_reinforcement_learning_reward_shaping.pyWrap up this module
Saved automatically in your browser profile so you can pick up right where you left off.