Week 29 · 4.5 Augmented reality and AI · 3 lessons
2
Sense, decide, act
Computing 8: Topic 4.5, pp. 283–299
GoalExplain sensors and autonomous programming, and trace a sensor program.
New words
sensor · an input device that measures the world around it, such as light or temperatureautonomous · working without a person controlling each stepautonomous programming · a system captures data from its surroundings and makes decisions and takes action by itself
Explanation
A sensor is an input device that takes readings from its surroundings, such as light, temperature or distance. In autonomous programming, a computer system gets readings from sensors, makes a decision from them and takes an action, all without a person controlling it. A street lamp that turns on when it gets dark is an example. Its light sensor sends a number, a program compares it with a limit, and an output switches the lamp on or off. Some autonomous systems also use AI, so they can learn from their readings and make better decisions. Robots in a factory and robots that explore dangerous places use sensors and autonomous programs, because they can work where it is unsafe or boring for people. AI can still be wrong, so people check the results.
A street lamp program. The light sensor gives a number from 0 (dark) to 100 (bright). The lamp comes on when the reading is below 30. With a reading of 12 the lamp turns on. Nobody pressed a switch.
Reading
Is light < 30?
Lamp
29
true
on
30
false
off
31
false
off
The boundary matters. With 30, the condition light < 30 is false, so the lamp stays off. If the designer meant “30 or darker”, the program needs <= instead. This is the same boundary bug as in earlier weeks.
Sensor reading
Decision
Action
parcel length 45 cm
45 > 60? no
small shelf
parcel length 80 cm
80 > 60? yes
big shelf
parcel length 60 cm
60 > 60? no
small shelf
A warehouse robot sorts parcels by size. A sensor measures the length of each parcel. If it is over 60 cm, the robot puts it on the big shelf. Otherwise, it uses the small shelf. The robot repeats this for every parcel, without a person. If its sensor gets dirty and gives a wrong number, it makes wrong decisions, so people still check.
Class activity
Be the autonomous system (no computer). Work in threes: one person is the sensor and reads out numbers, one is the decision-maker with a written rule on a card (for example, “if the number is less than 5, say ON, else say OFF”), one is the action (stands up for ON and sits down for OFF). The sensor calls ten numbers, including boundary numbers such as 4, 5 and 6. Does the decision-maker follow the rule exactly? What would happen if the sensor gave a wrong number? Write a rule for a different situation, such as a plant-watering pump that runs when the soil is dry. Swap roles and play again.
Practice
1
A designer changes the test to light <= 30. What does the changed program print when the reading is 30? What about 31?
30 gives Lamp on, because 30 <= 30 is true. 31 gives Lamp off, because 31 <= 30 is false.
2
Name the sensor, the decision and the action in a system that opens a door when someone comes near.
?→?→?
Sensor: a distance or movement sensor. Decision: is someone near enough? Action: the door opens.
3
Why do people still check robots that use AI?
AI can be wrong, for example if its sensor gives a wrong reading or its training examples were poor. People can spot and correct the mistakes.
4
Give one job where it is better for a robot to work autonomously than a person, and say why.
For example, exploring a deep cave or working in a very hot factory. It is dangerous or unpleasant for people, and the robot can work for a long time without getting tired.