MODULE 1 · LESSON 4 OF 6 · 35 MIN
Reward and return
A score for every step, how cyclotron builds it from 20 terms, and how far ahead a policy looks.
The policy has no idea what “standing” or “walking” means. The only thing that tells it what we want is the reward: after every step, one number that says how good that step was. Training changes the policy so that, over time, it collects more of it. Everything you want the robot to do, or not do, has to show up in that number.
SIMULATOR
Asimov 1 simulated with MuJoCo and driven by a trained policy, on your own computer.
Downloads 31 MB once: the physics engine, the policy runtime and the robot model.
Upright · 0.00 s · step 0
The command the policy follows. Limits come from the policy’s training ranges.
Push the pelvis for 0.15 s
Directions are relative to where the robot faces. You can also double-click the robot, or drag a body part to pull it.
One number, built from many terms
cyclotron’s walking task scores each step with 20 terms. Each term measures one thing about the step and has a weight: positive weights reward, negative weights penalise.
| Term | Weight | What it scores |
|---|---|---|
| track_linear_velocity | +5.0 | Moving at the commanded forward and sideways speed |
| track_angular_velocity | +3.0 | Turning at the commanded rate |
| upright | +1.0 | Keeping the torso level |
| pose | +1.0 | Staying close to the default pose, more tightly when standing |
| air_time | +0.5 | Feet in the air between 0.05 and 0.5 s per step, when walking |
| heading_drift | −0.5 | Drifting off the commanded heading |
| foot_clearance | −2.0 | Swinging feet that are not about 10 cm high |
| foot_swing_height | −0.25 | The highest point of a step not being about 10 cm |
| foot_slip | −0.1 | Feet sliding while on the ground |
| feet_orientation | −1.0 | Soles not flat |
| action_rate_l2 | −0.5 | Actions changing from one step to the next |
| body_ang_vel | −0.08 | The torso rocking |
| angular_momentum | −0.03 | The whole body spinning |
| dof_pos_limits | −1.0 | Joints near their limits |
| ankle_roll_overuse | −0.5 | Ankle roll beyond 0.06 rad |
| joint_deviation_l1 | −1.0 | Any joint away from the default pose, when standing |
| feet_stumble | −1.25 | Feet hitting something sideways |
| feet_contact_force_limit | −0.0005 | Stamping: foot forces above 350 N |
| soft_landing | −0.00001 | Hard landings |
| self_collisions | −1.0 | Body parts hitting each other |
Only the first two say what the task is. The other 18 shape how the robot goes about it; lesson 6 explains why they are needed.
The reward for one step is the sum of every term’s value times its weight, times the step’s length in seconds:
| Symbol | Meaning | Unit | Asimov standing still (measured) |
|---|---|---|---|
| the reward for step : one number | – | 0.170 | |
| which term: 1 to 20 in cyclotron’s walking task | – | 8 computed on this page | |
| term ’s weight from the table: positive to reward, negative to penalise | – | +5 for track_linear_velocity | |
| what term measured on that step, for example how close the speed was to the command | depends on the term | 1.000 for track_linear_velocity | |
| the length of a step. Multiplying by it keeps rewards comparable if the control rate ever changes | s | 0.02 |
The eight terms this page computes, for the built-in policy standing still. The two largest are track_linear_velocity and track_angular_velocity; the other six add the rest.
The reward, live
The Reward panel recomputes the reward of the policy that is running, term by term, from that policy’s own training file. The built-in policy’s file has 18 of the 20 terms above. The panel computes 8 of them, the ones that need only the robot’s joints, its pelvis and the actions: track_linear_velocity, track_angular_velocity, upright, action_rate_l2, joint_deviation_l1, dof_pos_limits, body_ang_vel and angular_momentum.
It lists the other 10 below its table, without values, because this page cannot reproduce them faithfully:
- Nine are about the feet touching things: air_time, foot_clearance, foot_swing_height, foot_slip, feet_orientation, soft_landing, feet_stumble, feet_contact_force_limit and self_collisions. In training they read Isaac Sim’s contact sensor: which foot is on the ground, since when, and how hard it presses. MuJoCo computes contacts too, but differently, so a copy here would give different numbers from the ones the policy was trained with.
- pose allows each joint a different amount of deviation depending on whether the robot is standing, walking or running, from three tables this page does not read yet.
So the panel’s total is the sum of 8 terms, not the policy’s full training reward.
Standing still under the built-in policy, the eight terms added up to 0.170 per step. After a 300 N push forward, the step reward was lowest 13 steps later, at −0.112, and the term that had dropped most was track_linear_velocity.
Exercise 4.1 · In the simulator
Which term reacts to a push
Let the robot stand, then push it forward at 300 N while watching the Reward this step column. Which term drops furthest, and which barely moves?
Hint 1
Hint 2
Checkpoint: answers only
Solution
A push changes several things at once: the torso rocks, the robot moves without being asked to, the joints leave the default pose and the policy’s actions change quickly to recover. Each of those shows up in its own term. The heavily weighted tracking terms usually move most, because the command is “stand still” and the push makes the base move. Terms that measure smoothness move too: recovering takes fast action changes, and the reward charges for them. The policy was trained to trade these off.
From reward to return
The reward scores one step, but no single step matters on its own. A policy that leans into a push loses a little reward now and keeps the robot standing for the next thousand steps. What training optimises is the reward over time, the return:
| Symbol | Meaning | Unit | Asimov standing still (measured) |
|---|---|---|---|
| the return from step : all the reward still to come, each reward discounted | – | 16.55 after 10 s (17.0 if it stood forever) | |
| the reward steps after step | – | 0.170 per step | |
| the discount (gamma), a number between 0 and 1 | – | 0.99 (cyclotron) | |
| how many steps ahead a reward is: 0 for the very next one | steps | 50 per second |
If every step were worth the same 0.170, the return would add up to 100 steps’ worth. Measured, after 10 s it was already 16.55.
A reward steps ahead counts as much as a reward now. How fast that weight falls sets how far the policy looks ahead: how far into the future rewards still count for much. A common measure is steps; a reward that far ahead counts about a third as much as one now, and rewards further away count less and less.
cyclotron uses , so its policies look about 100 steps, or 2 s, ahead: long enough to see a fall coming, short enough that what happens ten seconds later barely counts.
The Reward panel also shows the discounted return from the start of the episode, , as it adds up. Watch how it grows quickly at first, then flattens: rewards far into the episode are multiplied by tiny weights. In the measured run, standing still, was 6.39 after 1 s, 10.44 after 2 s, 15.29 after 5 s and 16.55 after 10 s.
Exercise 4.2 · On paper
How far ahead does a policy look?
- With , how much does a reward 1 s ahead count, and one 5 s ahead?
- With , roughly how far ahead does the policy look, in steps and in seconds?
Hint 1
Hint 2
Checkpoint: answers only
Solution
- and .
- steps, which is 0.2 s at 50 steps a second. A policy that looks 0.2 s ahead would hardly see the consequence of a fall that takes half a second to happen. That is one reason locomotion uses discounts close to 1.
Exercise 4.3 · On paper
The return of standing still
Suppose standing still earned the same reward on every step, forever. What would be with ? Use the measured per-step reward at rest, 0.170, and compare with the 10 s value above.
Hint 1
Checkpoint: answers only
Solution
The series adds up to , here = 17.0. After 10 s (500 steps) the remaining weight is , so is already within 1% of that limit if the reward really stays constant. The measured value, 16.55, differs a little because the reward of a standing robot is not exactly constant: the policy keeps making small corrections.
Recap
- The reward is one number per step: the sum of weighted terms, times 0.02 s.
- cyclotron’s walking reward has 20 terms; two define the task and the rest shape how it is done.
- The return adds up future rewards, each discounted by .
- With , a policy looks about 100 steps, or 2 s, ahead.
Sources
- cyclotron, velocity task: the 20 reward terms and their weightssource/cyclotron/cyclotron/tasks/locomotion/velocity_env_cfg.py, lines 377–526 (commit d71390f)
- cyclotron, reward functions (tracking, upright, smoothness, posture)source/cyclotron/cyclotron/tasks/locomotion/mdp/rewards.py
- cyclotron, PPO settings: discount γ = 0.99source/cyclotron/cyclotron/tasks/locomotion/agents/rsl_rl_ppo_cfg.py, line 91
- Isaac Lab's reward manager adds value × weight × step duration for every termsource/isaaclab/isaaclab/managers/reward_manager.py, line 150 (Isaac Lab commit b0542fe, as pinned by cyclotron)
- The browser reward gauge: ports of eight termssite/src/sim/reward.ts in the denebots repository
- cyclotron, which reward terms read the foot contact sensor, and pose's separate tolerances for standing, walking and runningsource/cyclotron/cyclotron/tasks/locomotion/mdp/rewards.py (feet_* terms, soft_landing, self_collision_cost, variable_posture)
- Measurement: reward terms at rest, after a 300 N push, and the discounted return over 10 smeasurements.json, results.reward (scripts/measure-module-1.mjs)
- R. S. Sutton and A. G. Barto, Reinforcement Learning: An Introduction, 2nd edition, MIT Press, 2018Sections 3.2 and 3.3: goals, rewards, returns and discounting