Skip to the lesson
FixTheRobot Explore Robotics / Robot Foundations / Module 1 / Lesson 3

Robot Foundations · Module 1: What Is a Robot?

The Robot Loop: Sense, Think, Act

Sense, think, act, and then do it again, many times every second.

  • Lesson 3 of 4
  • Beginner
  • No code
  • About 8 minutes

Walk across a room with your eyes open and you will not hit the furniture. Close your eyes after one good look and you probably will. You did not get worse at walking. You stopped checking. A robot is in the same position: it does not succeed by making one excellent decision, it succeeds by making small decisions, checking the result and deciding again. Pip does this 20 times every second.

What you will be able to do

  • Describe the three steps of the robot loop and what passes between them.
  • Explain what a loop rate is and compute how far a robot moves between two decisions.
  • Tell open-loop from closed-loop behaviour.
  • Explain why a fast loop of simple decisions beats one careful decision.

The idea

The three abilities of a robot are not done once. They form a circle.

The robot loopA loop of four blocks. Sense sends readings to Think. Think sends commands to Act. Act causes motion in the World. The World, now changed, is sensed again. SenseWhat is out there?ThinkWhat should I do?ActDo it WorldThe robot and its surroundings readings commands motion what changed
The robot loop. This drawing returns in later lessons, with the block under discussion in orange.
  1. Sense. The sensors measure. Out come readings: numbers such as "nearest wall: 1.2 m".
  2. Think. The software turns readings into a decision. Out come commands: numbers such as "left wheel 3 turns per second, right wheel 2".
  3. Act. The actuators carry out the commands. The robot moves, so the world as the robot sees it has changed.
  4. Again. The sensors measure the changed world, and the circle repeats.

The fourth step is the one that matters. Because the robot looks again after acting, it finds out whether its action worked. If a wheel slipped, the next reading shows that the robot is not where it expected, and the next decision can correct for it. No single decision has to be perfect, because another one is coming a moment later.

A robot does not need to be right. It needs to notice quickly when it is wrong.

How fast is the loop?

The number of times the loop runs each second is the loop rate, measured in hertz (Hz): 1 Hz means once per second. The time one pass takes is the time step.

The time step is one second divided by the loop rate.

time step = 1 ÷ loop rate

Pip runs its loop at 20 Hz, so its time step is 1 ÷ 20 = 0.05 seconds.

Between two decisions the robot is committed to its last command. It is, for that short time, driving blind. So the loop rate decides how far the robot travels without checking:

Distance travelled between decisions is speed multiplied by the time step.

distance per loop = speed × time step

At its top speed of 0.5 m/s, Pip moves 0.5 × 0.05 = 0.025 m, which is 2.5 cm, between decisions.

2.5 cm is small compared with a doorway, so Pip can correct its course long before a mistake becomes a collision. Different jobs need different rates:

Typical loop rates for three kinds of decision
What the loop doesTypical rateWhy
Balance a drone or a two-wheeled robot200 to 1000 HzIt falls over in a fraction of a second if left alone.
Steer a wheeled robot along a path10 to 50 HzIt moves a few centimetres per step.
Choose a new route through a buildingabout 1 Hz, or only when neededRoutes change slowly, and planning takes time.

A real robot runs several loops at once, fast ones inside slow ones. For now, one loop is enough.

Open loop and closed loop

A robot that acts without checking the result runs open loop: the circle is cut between the world and the sensors. "Drive forward for 4 seconds" is an open-loop instruction. It works if nothing unexpected happens. A robot that senses the result and corrects runs closed loop. "Drive forward until the wall is 0.5 m away" is a closed-loop instruction. It works on carpet, on tiles, uphill and with a low battery, because it is stated in terms of what the robot measures, not of what it hopes happened.

Almost everything that makes robots reliable is some way of closing a loop. Module 3 closes the loop on motion. Module 7 closes it on the question "where am I?".

Words to know

Loop
The cycle of sense, think, act that a robot repeats for as long as it is switched on. On Pip: it runs 20 times each second.
Reading
A number produced by a sensor at one moment. On Pip: distance to the nearest obstacle ahead: 1.2 m.
Command
A number sent to an actuator that tells it what to do. On Pip: left wheel: 3 turns per second.
Loop rate
How many times the loop runs each second, in hertz (Hz). On Pip: 20 Hz.
Time step
The time between two passes of the loop: 1 ÷ loop rate. On Pip: 0.05 s.
Open loop
Acting without measuring the result. On Pip: driving for a fixed time and assuming it has arrived.
Closed loop
Measuring the result of each action and using it in the next decision. Also called feedback. On Pip: driving until the measured distance to the shelf is small.

A worked example: the same robot with a slow loop

Pip is driving at 0.5 m/s toward a shelf and must stop when the laser scanner reads less than 0.30 m. Compare two loop rates.

  1. At 20 Hz. The time step is 0.05 s, so Pip moves 2.5 cm per loop. In the worst case the reading was just above 0.30 m on one pass, and Pip travels one more step before the next pass sees it. It begins to stop at about 0.30 − 0.025 = 0.275 m from the shelf.
  2. At 1 Hz. The time step is 1 ÷ 1 = 1 s, so Pip moves 0.5 × 1 = 0.5 m per loop. In the worst case it travels 50 cm past the 0.30 m mark before it finds out, by which time it is already touching the shelf.

The sensors, the motors and the rule are identical. Only the loop rate changed, and the slow robot hits the shelf. There are two fixes, and real robots use both: run the loop faster, or drive more slowly when something is close, so that the distance covered in one time step stays small.

Try it yourself

A delivery robot on a pavement drives at 1.5 m/s and runs its loop at 10 Hz. (a) What is its time step? (b) How far does it travel between decisions? (c) A child steps out 1 m ahead. Roughly how many decisions does the robot get before it reaches that spot, if it does not slow down?

Answer

(a) 1 ÷ 10 = 0.1 s. (b) 1.5 × 0.1 = 0.15 m. (c) 1 ÷ 0.15 is between 6 and 7, so about six decisions. Six chances to notice and brake is workable. At 1 Hz it would get none: it would cover 1.5 m before looking again.

Common mistakes

"A cleverer plan removes the need to keep checking."

No plan knows about the slippery patch, the low battery or the person who steps into the way. Checking is not a sign of a weak plan. It is what makes any plan survive contact with the world.

"Faster is always better."

A loop is only useful if the sensors deliver new readings that fast and the computer can finish thinking in time. Running a route planner 1000 times a second would waste the computer and gain nothing.

"Open loop is useless."

It is simple and it is fine when the world is predictable and errors are cheap: a short, slow move in a clear space. The mistake is to rely on it when either condition fails.

Remember this

  1. The robot loop is sense, think, act, and then again.
  2. The loop rate (in hertz) says how often the robot decides. The time step is 1 ÷ loop rate.
  3. Between decisions the robot moves speed × time step without checking.
  4. Closed loop means the result of each action is measured and used. It is what makes robots tolerate surprises.

Check yourself

Three questions. Write an answer in your own words, then reveal the explanation. Nothing you type leaves your browser.

Question 1

A robot arm is programmed to move its gripper to a fixed point, close, lift, and move to a second fixed point. It never looks at the object. Is this open loop or closed loop, and when will it fail?

Explanation

Open loop with respect to the object: it acts without measuring whether the object is there or was picked up. It fails whenever the object is not exactly at the expected place, or slips. A camera or a grip sensor, checked each cycle, would close the loop.

Question 2

A robot moves at 2 m/s with a loop rate of 50 Hz. How far does it travel between decisions?

Explanation

The time step is 1 ÷ 50 = 0.02 s. Distance per loop = 2 × 0.02 = 0.04 m, which is 4 cm.

Question 3

Why can a robot work well even though each of its individual decisions is based on imperfect measurements?

Explanation

Because the loop repeats. An imperfect decision produces a small error, the next reading shows that error, and the next decision reduces it. Errors are corrected faster than they build up, provided the loop is fast compared with how quickly things go wrong.

What’s next

One loop, six parts. The next lesson looks at how many different machines are built from them.

Next lesson

Kinds of Robots and the Problems They Share

Sort robots by how they move and what they do, and recognise the same loop inside all of them.

Where this goes on the site

Nothing below is needed to continue this course. These pages take the topic of this module further, and most assume more mathematics or Python than this course does.