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

Robot Foundations · Module 4: Sensing the World

What a Sensor Really Measures

A sensor does not tell the robot what is true. It tells the robot what it measured.

  • Lesson 1 of 4
  • Beginner
  • No code
  • About 9 minutes

Pip's laser scanner reports a wall 2.03 m away. The wall is 2.00 m away. Nothing is wrong: the number came from a real measurement, and real measurements are close to the truth, not equal to it. A robot that forgets this treats every reading as fact and is surprised by every mistake. This lesson separates what is true from what is reported, and gives you four questions that describe any sensor.

What you will be able to do

  • Explain what a sensor does, and why its reading is not the truth.
  • Describe a sensor by its range, resolution, rate and field of view.
  • Work out the gap between neighbouring beams of a scanner at a given distance.
  • Say why an object can be missed even though the sensor is working.

The idea

A sensor is a part that measures something physical and reports it as a number. In the lesson The Parts of a Robot you met it as the part that serves the "sense" step of the loop.

Every sensor does the same four things in a row:

  1. Something physical: light, sound, rotation, contact
  2. The sensor reacts to it
  3. The reaction becomes an electrical signal
  4. A circuit turns the signal into a number

Each step adds a little error. A wall at exactly 2.00 m becomes a pulse of light that takes slightly longer than expected because the air was warm, and a circuit that rounds off the answer. The program receives 2.03. That number is a reading. The wall's true distance is something the robot never sees.

A reading is a measurement of the world, not the world. Treat it as a good guess with a known size of error.

Four questions that describe any sensor

Whatever a sensor is made of, four properties say what it can and cannot do. When you meet a sensor for the first time, find these four.

Four properties of a sensor, with the values for the laser scanner of the course robot
PropertyThe questionPip's laser scannerWhy it matters
RangeHow near and how far can it measure?Up to 8 mBeyond the range the sensor reports nothing, which is not the same as "nothing is there".
ResolutionHow fine a difference can it tell apart?72 beams around a full circle: one every 5°Detail smaller than the resolution is lost.
RateHow many new readings come each second?10 full scans per secondBetween readings the sensor knows nothing new.
Field of viewWhich directions can it see?All around (360°). A camera, if fitted, sees a 70° wedge.The robot is blind to everything outside it.

These four are the reason one sensor is never enough. Each one is a limit, and a job usually needs more than a single sensor can give.

How an object slips through

Resolution is the least obvious of the four, so look at it closely. Pip's scanner sends out 72 beams, each 5° from the next. Near the robot the beams are packed tightly. Further out they spread apart like the spokes of a wheel, and a thin object can sit between two of them.

Laser beams spreading apart with distancePip on the left sends out laser beams 5 degrees apart. Four are drawn, at minus 5, 0, 5 and 10 degrees. A thin post, 30 centimetres wide and 6 metres away, stands between the beams at 0 and 5 degrees, so no beam touches it. The beams are 0.52 metres apart at that distance.-5°0°5°10°post, 30 cm wide, 6 m awaygap between neighbouring beams at 6 m: 0.52 mrange limit 8 m
The scanner works perfectly and still misses the post: it stands between two beams. The gap between beams grows in proportion to the distance.

The gap between two neighbouring beams depends on how far away you look:

The gap between two beams is about the distance times the angle between them, in radians.

gap ≈ distance × angle between beams

The angle between Pip's beams is 5°, which is 0.087 rad. At 6 m that gives 6 × 0.087 = 0.52 m.

The gap between Pip's laser beams at four distances
DistanceGap between beamsWhat can slip through
1 m9 cmMost table legs and cables
2 m17 cmMost table legs and cables
4 m35 cmA chair leg could fall between two beams
8 m70 cmOnly wide objects are certain to be hit

A reading of "nothing there" can mean the space is empty, or the object is too thin, too far, outside the field of view, or between two readings. Good robot software never treats the absence of a reading as proof that the way is clear.

Words to know

Sensor
A part that measures something physical and reports it as a number. On Pip: the laser scanner, the wheel encoders, the bumper, the camera.
Reading (measurement)
The number a sensor reports at one moment. It is close to the truth, not equal to it. On Pip: the scanner says 2.03 m, the wall is at 2.00 m.
Range
The smallest and largest values the sensor can measure. On Pip: the scanner reaches 8 m.
Resolution
The smallest difference the sensor can tell apart. On Pip: 5° between beams.
Rate
How many readings the sensor produces each second, in hertz. On Pip: 10 Hz for the scanner.
Field of view
The range of directions the sensor can see, as an angle. On Pip: the camera has 70°. The scanner has 360°.

A worked example: can the scanner see a table leg?

A table leg is 4 cm wide. Pip drives toward it. At what distances can the scanner be sure of hitting it?

  1. What is needed. To be certain of a hit, the leg must be at least as wide as the gap between two neighbouring beams.
  2. Gap formula. gap ≈ distance × 0.087. Set it equal to 0.04 m and solve for the distance: 0.04 ÷ 0.087 = 0.46 m.
  3. Result. Closer than 0.46 m, the leg is wider than the gap, so some beam must hit it. Further out, it may or may not be hit, depending on which way Pip happens to be facing.

So Pip can only be sure of a thin leg when it is under half a metre away. At 0.5 m/s that is one second from touching it, and the loop of the lesson The Robot Loop: Sense, Think, Act gets only 10 new scans in that time. The fix is not a better program. It is a second sensor: the bumper, which does not care how thin the leg is, and a camera or a finer scanner for the job of seeing thin things from further away.

Check with the table above: at 1 m the gap is 9 cm, which is just over 4 cm, and at 2 m it is 17 cm. The numbers agree.

Try it yourself

Hold your hand out at arm's length and spread your fingers wide. Look at a distant lamp-post or tree through the gaps. (a) Move your hand slowly: what happens to the objects as they go behind a finger and come out again? (b) Close one eye. What did you lose? (c) For your eyes, say what the range, resolution, rate and field of view are, roughly.

What to expect

(a) An object behind a finger vanishes while the finger passes it, even though your eyes work perfectly. That is a reading that is blocked, not an empty room. (b) With one eye shut you lose most of your sense of distance: a camera gives you the direction of things, not how far they are. (c) Range: very far, but poor in the dark. Resolution: very fine in the centre of vision and poor at the edges. Rate: about 60 updates a second. Field of view: about 200° across with both eyes. A human eye is a sensor with all four limits too.

Common mistakes

"The sensor says 2.03 m, so the wall is 2.03 m away."

It says the measurement is 2.03 m. The wall is near that, usually within a few centimetres for a good scanner. Programs that need the exact value to work are fragile.

"No reading means nothing is there."

It can mean the object is out of range, outside the field of view, too thin for the resolution, or hidden. Absence of evidence is not evidence of absence, and robots that forget this drive into things.

"A sensor with a high price has no limits."

Every sensor has range, resolution, rate and field of view limits. A better sensor moves them. It does not remove them.

Remember this

  1. A sensor turns something physical into a number. The number is a reading, not the truth.
  2. Four questions describe any sensor: its range, resolution, rate and field of view.
  3. Beams of a scanner spread out with distance: gap ≈ distance × angle between beams.
  4. No reading is not the same as nothing there.

Check yourself

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

Question 1

A scanner has beams 2° apart. Roughly how wide is the gap between neighbouring beams at 10 m? (2° is about 0.035 rad.)

Explanation

gap ≈ distance × angle = 10 × 0.035 = 0.35 m. A post 20 cm wide at that distance could stand between two beams and be missed.

Question 2

A robot reaches a doorway. Its scanner shows nothing ahead for 8 m, which is its full range. Can it conclude that the corridor is empty for 8 m? What might it have missed?

Explanation

No. It knows only that no beam returned a reading from an object in that space. A thin object could be between beams, a dark or glassy surface could fail to return the light, and anything beyond 8 m is outside the range. The robot can say the way looks clear, not that it is.

Question 3

Why would a robot with a very fast sensor (1000 readings a second) still have trouble if its own computer only handles 20 decisions a second?

Explanation

The loop rate is limited by the slowest part. The program uses only about one reading in fifty, and throws the rest away unless it processes them. Rate is a property of the whole chain, from the sensor to the decision, not of the sensor alone.

What’s next

You can now describe any sensor. The next lesson looks at the two families of sensor Pip uses to find out what is around it: those that measure distance, and those that make pictures.

Next lesson

Sensors That Look Outward: Distance and Images

Explain how ultrasonic sensors, LiDAR and cameras find out what is around the robot, and what each cannot see.

The lab of this module (after lesson 3)

Teach the Robot to Sense

Send a robot through a room with no sensor, then add a LiDAR, a camera and encoders, and choose the right sensor for each job. About 15–20 minutes.

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.