Autonomous decision making
What you’ll learn
- The difference between remote-controlled and autonomous robots
- The sense–plan–act cycle
- How behaviours combine, with priorities
Remote control vs autonomy
A remote-controlled robot needs a person to make every decision. An autonomous robot makes its own decisions from its sensors. Many real robots are in between: they handle the details themselves and take high-level goals from people.
Sense, plan, act
- Sense: read the sensors and build a picture of the world (the robot’s model).
- Plan: decide what to do to reach the goal.
- Act: move, then sense again.
Simple robots skip the planning and react directly (“too close → turn”). Advanced robots build maps and plan routes.
Behaviours with priorities
A practical way to build autonomy is to stack simple behaviours, with the most important one winning:
| Priority | Behaviour | When |
|---|---|---|
| 1 (highest) | Avoid collision | Something very close |
| 2 | Follow the wall | Wall on the right |
| 3 | Wander | Otherwise |
This is called subsumption: higher behaviours take over (subsume) lower ones when they’re triggered.
Autonomy needs fail-safes
- Stop if sensors give impossible readings.
- Stop if the robot hasn’t moved when it should have (stuck).
- Always have a physical off switch.
Example: behaviours in code
function loop() { if (distance() < 15) return motors(-50, 50); // 1: avoid if (distanceRight() < 30) return motors(60, 55); // 2: follow wall motors(55, 60); // 3: wander (gentle curve)}Example: a stuck detector
let lastD = 0, sameSince = 0;function loop() { const d = distance(); if (Math.abs(d - lastD) > 1) sameSince = millis(); lastD = d; if (millis() - sameSince > 2000) { motors(-50, -50); return; } // stuck: back off motors(60, 60);}Try it
Robot commands
motors(left, right): wheel power, −100 to 100lineLeft(),lineRight():trueover the black linedistance(): cm to the nearest thing ahead (max 200)distanceLeft(),distanceRight(): cm to the sideslinePosition(): where the line is, −1 (left) to 1 (right), ornullmillis(): milliseconds since Runprint(value): show a message belowsetup()runs once;loop()runs 50 times a second
Re-orderEasy
Swap the priorities so “follow wall” comes before “avoid”. What goes wrong? When following a wall into a corner the robot doesn’t turn away in time, because avoiding is no longer the top priority.
Cover the roomMedium
Change the wander behaviour so the robot visits all parts of the room within 60 seconds.
Rate the autonomyHard
Place these on a scale from teleoperated to fully autonomous: a drone flown by remote; a robot vacuum; a Mars rover; a self-driving car with a safety driver. Remote drone (teleoperated) → car with safety driver (semi-autonomous) → Mars rover (mostly autonomous, with goals set from Earth) → robot vacuum (fully autonomous in its small world).
Quick check
Finished this lesson?