RobotForge
Published·~16 min

Reinforcement learning primer for roboticists

MDPs, value functions, policy gradients — the RL minimum for a robotics audience. Skip the chess-playing examples; learn the math you'll use to train a quadruped.

by RobotForge
#learning#rl#fundamentals

RL textbooks teach you to play Atari. RL papers teach you to play chess. Robot RL is a different game: continuous actions, sample inefficiency, sim-to-real, hardware safety. Here's the minimum theory you need to read robot-RL papers without flipping back to Sutton & Barto every page.

The Markov Decision Process

The mathematical setup. At each timestep :

  • Robot observes state .
  • Picks action according to policy .
  • Environment transitions: .
  • Robot receives reward .

The Markov assumption: the future depends only on the current state and action, not the full history. For partially-observable problems (robot can't see everything), use POMDPs — same math with hidden state.

Goal: find maximizing expected discounted return:

is the discount factor — encodes "prefer rewards now over rewards later." Typical: 0.99 for episodic robot tasks.

Value functions

The expected return from a state under policy :

The state-action value (Q-function):

is "what's the expected return if I take action now and then follow forever after?"

The Bellman equation links them recursively:

Most RL algorithms are tractable approximations of this recursion.

The two policy families

1. Value-based: learn Q, derive π

Train a network to satisfy the Bellman equation. At each state, pick the action that maximizes .

For continuous actions (robotics), naive doesn't work — the action space is infinite. Workarounds:

  • DDPG: separate "actor" network outputs the directly.
  • TD3, SAC: variants of DDPG with stability tricks.

These are off-policy methods: they can learn from data collected by any policy, including past or random ones. Sample-efficient, hard to stabilize.

2. Policy-based: learn π directly

Parametrize the policy and adjust to maximize expected return. The key tool: policy gradient theorem.

"Increase the log-probability of actions that lead to high return; decrease the log-probability of low-return actions." Pure intuition, derived rigorously.

Practical algorithms: REINFORCE, A2C/A3C, PPO. On-policy: each batch of training data must come from the current policy. Stable but sample-inefficient.

Sparse vs dense rewards

The reward function determines what your policy learns. Two extremes:

  • Dense reward: every step provides feedback. "Distance to goal," "speed forward," "energy efficiency." Easy to learn from; risk of reward hacking (policy exploits the reward, ignores the spec).
  • Sparse reward: 0 every step until task succeeds, then +1. "Did the peg enter the hole?" Hard to learn from; aligned with the actual goal.

Most robot RL uses dense rewards with careful hand-tuning. Modern alternatives:

  • Hindsight experience replay: relabel failed episodes with achieved-state goals; turns sparse into dense.
  • Curriculum learning: start with easy tasks, increase difficulty.
  • Imitation as reward: bootstrap with demonstrations, then RL on top.

Exploration

Without exploration, the policy never tries new things and gets stuck. Strategies:

  • ε-greedy: with probability ε, take a random action. Discrete actions only.
  • Gaussian noise: add noise to the policy output. Standard in robotics.
  • Entropy regularization: push the policy toward higher-entropy distributions. SAC's central trick.
  • Curiosity: reward the policy for visiting unfamiliar states. Useful when reward is very sparse.

What's different about robotics

  • Continuous everything: states, actions, rewards. Can't enumerate; must function-approximate.
  • Sample inefficiency: real robots collect ~1 hour of experience per hour. PPO needs 10⁸ steps. → train in sim.
  • Sim-to-real: the bridge that makes sim training useful. Covered in detail in the sim-to-real lesson.
  • Hardware safety: random actions can break expensive equipment. Constrained exploration matters.
  • Reset complexity: real robots can't always be teleported back to "start state." Episode resets are a real engineering problem.

The four-algorithm shortlist

Algorithm Type Use for
PPOOn-policySim training, default
SACOff-policySample-efficient sim, real-world RL
TD-MPCModel-basedLong horizons, tasks needing planning
HIL-SERLReal-world RLProduction-grade hardware training

Master PPO + SAC and you can read 80% of robotics RL papers.

What to read after this lesson

  • Sutton & Barto: the canonical RL textbook. Free online.
  • Lilian Weng's blog: deep but readable summaries of every modern algorithm.
  • OpenAI Spinning Up: clean implementations + walkthroughs.
  • Specific to robotics: Tedrake's Underactuated Robotics (chapters on RL).

Exercise

In MuJoCo Playground, train a PPO policy for the cartpole environment. Then change the reward function from "stay upright" to "stay upright AND move forward." Watch the trajectory shift. Tweak weights between the two reward terms; see how policy behavior changes. This is reward shaping; you'll do it for every project.

Next

PPO in practice — the actual hyperparameters that determine whether your training run converges or thrashes.

Comments

    Sign in to post a comment.