Unit 01 · lesson

The Sense-Decide-Act Loop

A robot that moves once is easy. A robot that keeps behaving correctly while the world changes is harder.

The core pattern is:

SENSE → ESTIMATE → DECIDE → ACT → OBSERVE WHAT CHANGED
   ↑                                      |
   └──────────────────────────────────────┘

That loop can run thousands of times per second or only when an event occurs. The important idea is not the speed. The important idea is that new evidence can change the next action.

Open loop first

Imagine telling a robot:

Run the left and right motors at 40% power for two seconds.

That is an open-loop command. The robot does not use evidence about how far it actually traveled. If the battery voltage drops, the floor changes, one wheel slips, or the robot carries more mass, the final position can change.

Open-loop control is not automatically bad. Sometimes the task is simple enough that exact correction is unnecessary. The mistake is assuming a timed command guarantees a physical result.

Close the loop with evidence

Now add wheel encoders and ask the robot to move until the measured distance reaches one meter.

target distance = 1.00 m
measured distance = 0.62 m
error = target - measured
error = 0.38 m

The robot can use the error to decide whether to continue, slow down, or stop. Later in the course, feedback control will turn that idea into a formal control loop.

For now, notice the architectural difference:

Open loopClosed loop
command is issuedtarget is defined
action occursaction occurs
result may be assumedresult is measured
no correction from outputoutput can change the next command

Where robots get fooled

Feedback does not guarantee truth. Suppose the wheel spins while the robot is stuck against an obstacle. An encoder attached to the wheel may report motion even though the robot chassis barely moved.

That is not a broken sensor. The sensor measured what it was designed to measure: wheel rotation.

The failure is in the interpretation.

This is a pattern you will see repeatedly:

  1. a physical event occurs;
  2. a sensor measures one property of that event;
  3. software converts the measurement into a claim;
  4. the claim may be useful, incomplete, or wrong.

A robot is only as reliable as the chain between reality and the decision it makes.

Trace one loop

Take the robot from your first lesson and write one complete loop using exact nouns.

Bad:

robot senses → robot thinks → robot moves

Better:

ultrasonic sensor measures range → controller compares range with stop threshold → motor driver reduces motor command → wheels slow → next range measurement changes

If you cannot name the parts, the system is still too vague.