Lesson 21 of 2255 minutes

Paths, Obstacle Avoidance, and Recovery

Start with the lesson question, connect the representations, and test the model with evidence.

path planningcostmaplocal controlobstacle avoidancerecovery

Learning objectives

  • Explain odometry, drift, landmarks, and state estimation.
  • Interpret an occupancy map and the purpose of SLAM.
  • Diagnose failures across localization, planning, and control.
Lesson flowHook, model, explanationShow guidance

Inspect the opening phenomenon

Predict what changes, then name the evidence.

Apply in the lab

Name the evidence before reading the answer.

Read only what helps

Then use the lab and recall check.

More when needed

Transcript and resources stay available below.

Course progress

AI & Robotics Foundations · Localization, Mapping, and Navigation · Lesson 21

Paths, Obstacle Avoidance, and Recovery

In progress

Decision challenge

Observe the phenomenon. Then connect the representations.

Use the opening example to make a prediction, identify evidence, and explain which model supports it.

Why Can a Robot Have a Valid Path but Still Stop?

Watch for the core concept, then connect the evidence to the lesson explanation.

Reference drawerTranscript, source notes, scripts, and package status stay tucked away until you need them.6 files

Lesson reading

live

55 min

Video script

draft

Transcript fallback

available

courses/ai-robotics/modules/07-localization-mapping-and-navigation/lessons/03-paths-obstacle-avoidance-and-recovery/video-transcript.md

Diagnose a Blocked Robot Before Retrying

draft

30 min

Mastery check

live

5 questions / 10 min

Transcript for accessibility and fallback

# Transcript: Why can a robot have a valid path but still stop? A robot can have a valid route and still stop. Why? The global planner chooses where to go. The local controller must find a safe motion right now. Watch each candidate path. The straight option crosses the person's safety zone, so it is rejected. This robot cannot slide sideways; it must choose a feasible curve. If every candidate is blocked, stopping is the correct command. Then diagnose the cause. For a fresh obstacle, wait or replan. For stale sensor data, clear only the stale region and sense again. For a bad pose or transform, stop and repair the state estimate. Recovery is safe only when something changes: new evidence, corrected state, or different geometry. What must change before this robot retries?

Reading lab

Core explanation

Connect the lesson's words, diagrams, graphs, evidence, and equations.

Why can a robot have a valid path and still be unable to move?

A path is a geometric proposal from the current pose to a goal. It is not a promise that every segment remains executable. A newly observed person or lethal collision margin, localization error, stale obstacle evidence, or a motion constraint can invalidate the next control action even while the original global line still looks clear.

Mental model: plan, test, move, verify

Treat navigation as a repeated evidence loop:

  1. The global planner searches a cost representation for a route to the goal.
  2. The controller generates candidate short-horizon motions that respect the robot's kinematics.
  3. Each candidate is checked against the robot footprint, nearby costs, path progress, and goal alignment.
  4. The robot executes only a bounded command, observes again, and repeats.
  5. If progress fails, recovery should change the information or geometry before retrying.

The shortest route may carry excessive nonlethal proximity cost, violate the lethal collision margin, exceed the robot's turning capability, or become newly blocked. A longer candidate can be the correct executable choice.

Worked example: a person enters the aisle

A mobile robot is following a global path around a shelf. At time t₀, the aisle is free. At t₁, a person enters the local sensor field. The obstacle layer marks new evidence; the costmap represents a lethal collision region plus graded nonlethal proximity costs around it.

  • Continuing the old velocity would intersect the footprint buffer, so that candidate must be rejected.
  • A side-step is invalid for a differential-drive robot because it cannot move laterally.
  • A curved slowdown trajectory may remain valid if its swept footprint avoids occupied and lethal-cost cells; entering nonlethal inflated cost makes it less desirable rather than automatically invalid.
  • If every candidate is invalid, the controller reports failure rather than inventing a motion.
  • The navigation policy may wait, request a new global path, or perform a bounded recovery after checking that the recovery motion itself is clear.

Recovery is diagnosis, not ritual

Blindly repeating plan → fail → clear everything → retry can hide the true fault. Ask what changed:

  • Dynamic obstacle: wait or replan using fresh observations.
  • Stale obstacle evidence: clear only the relevant stale region, then observe again.
  • Robot too close to geometry: perform a checked backup or rotation only if the swept footprint is free.
  • Localization or transform failure: stop navigation and restore trustworthy state; motion cannot repair invalid frames.
  • No feasible route: report failure or request human assistance rather than exhausting retries forever.

Nav2 behavior trees formalize bounded retry and escalation. A contextual recovery can improve the chance that planning or following succeeds; a system-level recovery follows only when the local repair fails.

Misconception checks

  • “A path is a list of motor commands.” No. A path is geometric guidance; the controller still computes feasible velocity commands from current evidence.
  • “Clearing the costmap removes the obstacle.” It removes stored cost evidence, not the physical object. Sensors must observe again before motion is justified.
  • “Collision avoidance proves safety.” No. Planning and CPU-level monitoring reduce risk but do not replace safety-rated sensing, controllers, stopping analysis, or operational limits.

Retrieval pause

The robot has a valid global path, but all local trajectories overlap occupied or lethal-cost cells around a newly observed obstacle. Which evidence should change before retrying, and what would make a backup defensible?

Summary

A robust navigation system separates global intent from local executable motion. It represents nearby evidence as cost, checks the swept robot footprint, executes short commands, verifies progress, and uses bounded, diagnosis-driven recovery. When evidence or state is untrustworthy, stopping is a valid navigation outcome.

Further learning

Practice labDiagnose a Blocked Robot Before RetryingOpen this when you are ready to apply the model, collect evidence, and check your explanation.30 min

Lab: Diagnose a Blocked Robot Before Retrying

Objective

Compare global paths with locally executable trajectories, test a swept robot footprint against costs, and select an evidence-based recovery.

Materials

  • Graph paper or spreadsheet software
  • The lesson's 16×16 cost grid
  • Four colored markers or distinct text symbols
  • Optional calculator; a text table is an accessible fallback

Setup

Use a 16×16 grid at 0.25 m/cell, with coordinates from 0 through 15. The robot footprint is a 0.50 m × 0.40 m rectangle, so it occupies more than its center cell. Mark a shelf from cells (9,6) through (9,10). Place the robot at (3,8) facing right and the goal at (13,8).

Steps

  1. Draw a global path that passes below the shelf near row 14 and reaches the goal. Keep the robot footprint inside the grid boundary.
  2. Keep shelf cells marked occupied. Around them, mark an inner lethal/collision-margin band and an outer graded-cost band, extending no more than two cells. Explain why these costs guide clearance rather than making the physical shelf wider.
  3. Add a newly observed person at (5,8) and inflate that observation by two cells. Confirm that this blocks the immediate straight candidate without erasing the still-valid global detour below the shelf.
  4. Sketch three short local candidates: straight, shallow-up curve, and shallow-down curve.
  5. Move the full rectangular footprint along each candidate. Reject a candidate if the swept footprint overlaps an occupied or lethal-cost cell. Do not automatically reject a candidate merely for entering a nonlethal inflated-cost cell; record and compare that cost instead.
  6. Record for each candidate: path distance, maximum encountered cost, minimum clearance, collision result, and progress toward the goal.
  7. If no candidate remains, classify the likely cause as dynamic obstacle, stale evidence, impossible geometry, or invalid localization/transform.
  8. Choose one response: wait and resense, compute a new global path, clear only stale local evidence, checked backup/rotation, or stop and request assistance.
  9. State what new evidence must be observed before retrying.
  10. Repeat after removing the person but leaving one stale marked cell. Compare indiscriminate clearing with clearing only the stale region and observing again.

Expected Result

  • The global path can remain geometrically valid while every current local trajectory is unsafe.
  • Center-point clearance alone is insufficient; the swept footprint can collide.
  • Inflation changes traversal cost around an obstacle but does not enlarge the physical object; nonlethal inflated cost is not automatically a collision.
  • Clearing stored evidence does not remove the person; retry requires a fresh observation or a new feasible route.
  • Invalid localization or transforms lead to stopping and repairing state, not motion-based recovery.

Troubleshooting

  • If all candidates appear safe, move the full footprint rather than checking only the robot center.
  • If every inflated cell is treated as a collision, separate lethal collision cost from the outer graded-cost band and compare the surviving candidates by cost and clearance.
  • If the robot slides sideways, redraw candidates with forward motion and curvature consistent with differential drive.
  • If clearing makes the physical obstacle disappear, keep the person symbol separate from the cost layer.
  • If retries are infinite, add a retry counter and a terminal assistance state.

Accessibility fallback

Use a table with one row per candidate and columns for footprint cells, maximum cost, minimum clearance, validity, and recovery decision. Use symbols plus labels; color is optional.

Reflection Questions

  1. Why is a nav_msgs/Path not sufficient to command wheel motion directly?
  2. Which cost evidence changed when the person entered the aisle?
  3. What distinguishes a defensible costmap clear from deleting inconvenient evidence?
  4. When is stopping the correct recovery outcome?

Extension Challenge

Increase the robot footprint by 20% while keeping the same global path. Re-evaluate all candidates and explain why platform geometry must be included in navigation configuration.