Learn from demonstrations without copying hidden state

Collect observation-action pairs and understand where behavior cloning fails.

Browser walkthrough·Intermediate·4 min read

Teach a Go2 by showing it

Press Start recording, then use the slider or arrow keys to drive the robot to the 1 m line and stop it there. You have 12 seconds. A policy is then fitted to your commands and has to drive on its own.

Go2 test lane

Ready · 0.0 / 12.0 s

The robot is at 0.000 m at 0.0 s. The orange line marks the 1 m target. You are driving.

2D reference and fallback
Robot position over 12 secondsYour demonstration ends at 0.000 meters. The dashed line is the 1 meter target.1.2-0.10 s12 sYou
Model, fit, and limits

The same one-dimensional model of the Go2 as the control lessons: the drive approaches its commanded speed with a 0.4 s lag and the command is limited to ±0.80 m/s. Your slider value is recorded every 0.1 s. The policy is a least-squares fit of three numbers, so it can only represent a straight-line rule. A vision-language-action model is trained on the same kind of observation and action pairs, but with camera images as input, a far larger model, and many demonstrations. Nothing here is sent to a robot.

Requirements and learning goals

Before you start

  • A browser with JavaScript for the experiment
  • Python and arrays for the NumPy exercise

You will be able to

  • Build a demonstration schema
  • Split by episode
  • Recognize distribution shift

The browser exercise above works without extra setup. The project brief below assumes the listed prerequisites and gives you a task and checks to perform. Need a guided first project?

trains a from examples of someone performing a task. Behavior cloning is its simplest form: predict the demonstrated action from the observation. It is useful when you can demonstrate a behavior more easily than design a . Here you will fit a tiny example and learn why matching recorded actions does not guarantee recovery from mistakes.

Use application recording streams to preserve observations and actions with timestamps. Converting recordings into aligned training demonstrations remains part of your data pipeline.

Try it in your browser

The experiment above is behavior cloning at its smallest scale. You are the demonstrator.

  1. Press Start recording. Drive the robot to the 1-meter line with the slider and stop it there. A rough attempt is fine.
  2. After 12 seconds, a policy is fitted to your commands. Read the rule it learned: a weight on position error, a weight on velocity, and a constant.
  3. Watch the clone drive. Compare its final error and with your own run.
  4. Under Test the clone in, select the steady push. Your demonstration never included a push. Read the clone's final error again.
  5. Record a deliberately poor demonstration, such as stopping well short of the line, and compare what the policy learns.

The policy does not know where the target is. It reproduces the relationship between what you saw and what you did. If you stopped short, it stops short. Nothing in your demonstration showed how to answer a push, so expect a different final error under one. The average command gap can stay small in both cases: copying a demonstration well is not the same as completing the task.

Learn the demonstrated action

A cloned policy may reproduce familiar states while failing to recover from its own mistakes.

Record observation, action, capture time, execution time, and ID. Keep future measurements and the demonstrator's private knowledge out of model inputs.

Fit a visible baseline

This synthetic NumPy exercise fits target error and velocity to an action:

import numpy as np
 
rng = np.random.default_rng(4)
observations = rng.uniform(-1, 1, size=(200, 2))
actions = 0.7 * observations[:, 0] - 0.2 * observations[:, 1]
features = np.c_[observations, np.ones(len(observations))]
weights, *_ = np.linalg.lstsq(features, actions, rcond=None)
print(weights)  # approximately [0.7, -0.2, 0]

This checks feature ordering and action meaning. It is not a robot policy.

Checkpoint 1 of 2

Suppose the demonstrator's rule were actions = 0.5 * observations[:, 0] + 0.3 * observations[:, 1]. What would the script print?

Commit to an answer. Every choice explains itself.

Collect recoveries too

Include varied starts, pauses, disturbances, and corrections. Split by episode or session rather than adjacent frames. Store unsuccessful attempts with explicit labels.

Evaluate the learned controller in a loop where its own actions change future observations. Low offline prediction error does not establish successful behavior. Compare completion, interventions, and distance to the goal with the demonstrator.

Checkpoint 2 of 2

A cloned policy predicts held-out demonstration actions almost perfectly. Running in a loop, it drifts off the path and does not come back. Which data addresses this most directly?

Commit to an answer. Every choice explains itself.

The G1 reference-conditioned example shows why reference files and joint conventions matter. Its required dataset and parent checkpoint are not bundled, so the small exercise above is the self-contained starting point.

Common snag: delayed action labels make a policy appear hesitant. Measure observation-to-action timing before training.

Optional extension: collect recovery demonstrations at the states where the cloned policy actually fails, then evaluate on new episodes.

Can you do each of these?

  • Build a demonstration schema
  • Split by episode
  • Recognize distribution shift

0 of 2 checkpoints solved. Try checkpoint 1

Previous: Train a small policy and keep the experiment reproducible
All lessons in this topic
  1. 1. Define observations, actions, and rewards
  2. 2. Test a policy with imperfect sensors
  3. 3. Train a small policy and keep the experiment reproducible
  4. 4. Learn from demonstrations without copying hidden state
  5. 5. Evaluate and replay a policy as a complete system
  6. 6. Measure the simulation-to-hardware gap

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.