L0 · PAI-110

The Embodied Loop

Wire a sense->decide->act loop that drives the rover forward and halts it within 0.25 m of the goal with no overshoot.

01
Challenge

Try this first — before any explanation.

Bench opens in the Blockly editor. The rover sits at the origin facing an amber goal 3.0 m dead ahead. Make the rover drive forward and stop when it gets close to the goal — not crash through it, not stop early. Drag blocks, press Run. You have not been taught the right answer yet — try it.

The Bench

Drag blocks (shown here as the Python they generate) so the rover senses, decides, and acts every tick.

VISUAL · BLOCKS → PYTHON

The Embodied Loop

Drag blocks (shown here as the Python they generate) so the rover senses, decides, and acts every tick.

02
Model

The idea, built visually.

A robot is not a program that runs once. Picture driving to a goal: point it, push go — and it overshoots, because a single command can't know when to stop. So it does something else: it SENSES (how far to the goal?), DECIDES (close enough yet?), and ACTS (drive, or stop) — then does the whole thing again, many times a second. That loop is the robot.

The one thing that trips everyone up: if you check 'am I there yet?' only once, the rover never re-asks and overshoots forever. The deciding has to live inside the loop, asked every single tick.

▣ Stage animation: Three SENSE->DECIDE->ACT nodes arc into a spinning cycle; an inset rover advances one nudge per revolution as goal_distance shrinks and the < 0.25 check flashes; a split screen shows the stop-check outside the loop (sails past) vs inside (halts clean on the marker).

03
Guided practice

Build it up, step by step.

Step 1 (worked): the loop and forward-drive block are placed; you drop in if goal distance < ??? with a number near 0.25. Step 2 (faded): rebuild the loop and choose the threshold yourself. Step 3 (independent): tune the threshold so the rover halts within tolerance — too small overshoots, too large stops early.

04
Feedback

How the Bench grades your run.

PASS WHEN Stopped with final goal-distance <= 0.25 m, never exceeding goal x by more than 0.30 m, with the stop-decision evaluated every loop iteration.

  • FAIL: ran the full 15 s without stopping — no stop condition reached; place a goal-distance read in the comparison.
  • FAIL: overshot the goal by 0.62 m — the rover never re-checks distance while driving; move the if inside the repeat-forever loop.
  • FAIL: halted 0.71 m short — stop threshold fires while still far away; lower it toward 0.25 m.
05
Retrieve & space

Bring back what you've already mastered.

  • Tag fragments as SENSE / DECIDE / ACT (read_range -> SENSE, set_motor -> ACT, if < 0.25 -> DECIDE).
  • Predict: change threshold 0.25 -> 0.6 — does the rover stop closer or farther from the goal? (Farther — triggers sooner.)
  • Spot-the-bug: a block stack has the stop-check outside the loop; drag it back inside.
06
Mastery gate

What you must demonstrate to advance.

From the fixed seed, the rover drives forward and halts within 0.25 m of the goal with no overshoot beyond 0.30 m, stop-decision provably inside the loop (L0: runs a given loop).

07
Project

How this feeds your build.

Contributes the stop-on-condition STOP primitive to the capstone; the 'test the sensor every tick, inside the loop' habit is the skeleton of every later controller (PID loop, timer-ISR tick).