Robot Foundations · Module 5: Reaching a Goal
Goals, Paths and Plans
Deciding where to go and driving there are separate jobs, done at different speeds by different parts of the software.
Feedback from module 3 is enough to drive Pip to a goal in an empty room: measure the distance, measure the heading error, correct both. Put a wall between Pip and the goal and the same program drives straight into it, politely and persistently, getting more precise the closer it gets. The controller is working perfectly. The robot has no idea there is a problem, because nothing in the controller knows about walls. Something else must.
What you will be able to do
- State a navigation task as a start, a goal and obstacles.
- Explain why a controller alone cannot get around a wall.
- Say what a path and a waypoint are, and what a planner adds.
- Say which part of the software runs fast and which runs slowly, and why.
The idea
A navigation task has three ingredients: where the robot is (the start), where it should be (the goal), and what is in the way (the obstacles). The answer to the task is not a single command. It is a route.
The green line in the figure is a path: a route from start to goal that avoids every obstacle, written as a list of points to pass through, called waypoints. Finding it is planning. Driving along it is control, the feedback you already know, aimed at one waypoint after another instead of at the goal itself.
Two jobs, two speeds
The two jobs are so different that they are done by two separate programs.
| Planner | Controller | |
|---|---|---|
| Question it answers | Which way around everything should I go? | How do I steer right now to stay on the way? |
| Looks at | The whole map, start to goal | Only the next waypoint and the robot's pose |
| Produces | A path: a list of waypoints | Wheel speeds: v and ω |
| How often it runs | Rarely: once at the start, then when the world changes (about once a second at most) | Every pass of the loop (20 times a second for Pip) |
| Cost of a mistake | A long detour or a dead end | A wobble or a clipped corner |
This split is the picture from the lesson The Robot Loop: Sense, Think, Act, with a slow loop around a fast one. The planner thinks about the whole route a few times. The controller, many times a second, makes sure that each step goes the way the latest plan says. Neither can do the other's job: a planner running at 20 Hz would waste the computer, and a controller with no plan would drive into the wall.
A plan says where to go. A controller says how to steer. A robot that reaches goals through clutter needs both.
What makes a path good?
Many paths avoid the wall. A good one is:
- Safe. It keeps a margin from obstacles. Pip is 0.35 m across, so a path that scrapes past a corner with 1 cm to spare is a path that will touch it.
- Short. A shorter path takes less time and battery. The planner measures this as the sum of its straight pieces: 5.13 m in the figure.
- Followable. A path with a hairpin turn is hard to drive. Smooth turns are easier for a robot that cannot move sideways.
These pull against each other: the shortest path hugs the corner, and the safest one swings wide. Planners balance them. The next lesson builds the simplest planner there is, and lab 3 lets you use one.
Planning needs a map. To go around a wall, the robot must already know where the wall is, which is why this module is followed by "Building a map" and "Knowing where you are". For now, the map is given.
Words to know
- Start, goal
- Where the robot is at the beginning, and where it must end up. On Pip: start (1, 1), goal (5, 3).
- Obstacle
- Anything the robot must not touch. On Pip: a wall, a bench, a person.
- Path
- A route from start to goal that avoids the obstacles. On Pip: the green route, 5.13 m long.
- Waypoint
- One of the points a path passes through, in order. On Pip: the two corners of the green route.
- Planning
- Choosing a path from the map, the start and the goal. On Pip: done once at the start and again when the world changes.
- Path following
- Steering along a path with feedback. On Pip: the controller aims at each waypoint in turn.
- Clearance
- The distance kept between the robot and an obstacle. On Pip: at least a few centimetres on every side of its 35 cm body.
A worked example: how far is the detour?
Pip is at (1, 1) and the goal is at (5, 3). The wall occupies x from 2.5 to 3.5 and y from 0 to 2.5. Compare going straight with going around.
- Straight line. Differences: 4 in x and 2 in y. Distance = √(16 + 4) = 4.47 m.
- Is it blocked? The line climbs 2 m over 4 m, so at x = 3 it is at y = 1 + 2 × (3 − 1) ÷ 4 = 2 m. The wall is 2.5 m tall at that spot, so the line goes through it: blocked.
- The detour. Three legs: (1, 1) to (2.2, 3), then to (3.8, 3), then to (5, 3). Their lengths are 2.33 m, 1.6 m and 1.2 m, which add up to 5.13 m.
- The cost of avoiding the wall. 5.13 − 4.47 = 0.66 m extra, about 15% longer. At 0.5 m/s that is 1.3 seconds.
- Clearance. The path runs at y = 3.0 m past a wall that ends at y = 2.5 m, a margin of 0.5 m, comfortably more than Pip's half-width of 0.17 m.
A detour of about a metre buys a safe arrival. The blocked straight line is shorter and ends at the wall.
Try it yourself
Draw a 6 by 4 grid on paper with the robot at (1, 1), the goal at (5, 3) and the wall of the figure. (a) Is there a way under the wall? (b) Now cut a doorway through the wall, 1 m wide, from y = 1 to y = 2. Draw a path through the middle of the doorway, at (3, 1.5). How long is it, and would you drive it or the detour over the top?
Answer
(a) No. The wall touches the floor, so every route goes over its top, around the end at y = 2.5. (b) The path (1, 1) to (3, 1.5) to (5, 3) has legs of 2.06 m and 2.5 m, 4.56 m in all, against 5.13 m for the detour: 0.57 m shorter. But the doorway is 1 m wide and Pip is 0.35 m across, which leaves about 0.33 m each side. A robot that is sure of its position should take the doorway. One that is not sure should take the longer way. Short and safe often disagree.
Common mistakes
"A better controller will get the robot around the wall."
A controller reacts to an error between where the robot is and a target. If the target is on the other side of a wall, the error says "go straight", and a better controller does that more smoothly. Avoiding walls needs knowledge of the walls, which the planner has.
"The shortest path is the best path."
The shortest path touches every corner. Real robots have width, slip and measure imperfectly, so they need margin. The best path trades length for safety.
"Plan once and then drive."
That is open loop, with all the problems of module 3. Plans go stale, which is the subject of the last lesson of this module.
Remember this
- A navigation task is a start, a goal and obstacles. Its answer is a path.
- A path is a list of waypoints. Planning chooses it. Control follows it.
- The planner runs rarely and sees the whole map. The controller runs every loop and sees the next waypoint.
- A good path is safe first, then short, and smooth enough to drive.
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 at (0, 0) must reach (6, 8) with no obstacles. How long is the best path, and what would a planner contribute?
Explanation
The straight line: √(36 + 64) = 10 m. With no obstacles the path is just the line, so the planner adds almost nothing and a controller alone suffices. Planning earns its place only when something is in the way.
Question 2
Why does the planner run about once a second while the controller runs 20 times a second?
Explanation
The route changes only when the world does, which is slow, and finding it takes real computation. The steering must be corrected on every step to keep the robot on the path. Running the planner 20 times a second would use up the computer for no gain, and running the controller once a second would let the robot wander off the path between corrections.
Question 3
A path passes a wall corner with 2 cm of clearance. The robot is 35 cm wide and its position estimate is typically off by 5 cm. Is the path good?
Explanation
No. A 5 cm error in position is larger than the 2 cm margin, so the robot will often touch the corner. The planner should keep a clearance larger than the position error plus half the robot width, which is why planners "inflate" obstacles.
What’s next
You know what a plan is. The next lesson builds the simplest planner that works: spread outward from the start, one step at a time, until you reach the goal.
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.
- LaterNavigation
Sixty lessons on planning and driving, from costmaps to fleets.
- LaterA* Search with a Heuristic
The grid search of this module, made fast.