What you will learn
  • Explain reactive obstacle avoidance in plain language.
  • Trace information from input to output.
  • Test one subsystem independently.
  • Recognize a common failure and respond safely.
  • Modify the example without changing several variables at once.

The central idea: reactive obstacle avoidance

Obstacle avoidance converts range or contact observations into safe movement choices. It needs detection limits, stopping distance, a recovery action, and a fail-safe response to invalid data.

Treat the system as a chain of observable inputs, explicit processing, a decision, and an output. That makes the design easier to explain and gives you a place to test when something fails. A working result is not enough: record what input produced it and what evidence shows the result is correct.

Follow the information through the system

Read the diagram from left to right. Each arrow is a boundary where data, electrical signals, or commands move between parts. Test those boundaries separately before combining the whole system.

A rover stops at 30 cm, checks left and right, turns toward the clearer side, then measures again before moving.

  • Measure stopping distance at actual speed.
  • Treat invalid range as unsafe.
  • Prevent repeated left-right oscillation.
range → valid? → clearance rule → stop/turn/forward → new range

Test before you trust the result

Start with a normal case, then test a boundary case and a failure case. For software, try empty, unexpected, and extreme inputs. For hardware, begin with wheels raised or actuators disconnected, keep a physical power switch within reach, and verify safe stopping behavior.

Write down the expected result before each test. If the observation differs, stop and find the first boundary where the expected signal disappeared. This method is slower than changing many things at once, but it produces evidence instead of guesses.

  • Test one input with a known value.
  • Observe the intermediate value before the final action.
  • Confirm a safe response when input is missing or invalid.
  • Repeat the same test to check consistency.

Important terms

Clearance
Required free space around a robot.
Stopping distance
Distance traveled after a stop decision begins.
Reactive control
Choosing actions directly from current observations.
Fail-safe
A response that moves toward a safer state after failure.
Oscillation
Repeated switching between competing actions.

Mini project: practice reactive obstacle avoidance

  1. Test the range sensor against known distances.
  2. Measure stopping distance.
  3. Set a conservative threshold.
  4. Test with wheels raised.
  5. Run in an enclosed clear area.

Common mistakes and debugging

  • Choosing a threshold smaller than stopping distance.
  • Treating no echo as no obstacle.
  • Using one front sensor to detect stairs.
  • Increasing speed before validating stops.

Independent challenge

Add a short decision memory so a rover does not alternate left and right in a narrow space.

Check your understanding: 10 questions

  1. What is the main purpose of reactive obstacle avoidance?

  2. What does “Clearance” mean in this lesson?

  3. How is “Stopping distance” used?

  4. Why should you test one boundary or subsystem at a time?

  5. What should the system do when an input is missing or invalid?

  6. In your own words, what does “Clearance” mean?

  7. In your own words, what does “Stopping distance” mean?

  8. In your own words, what does “Reactive control” mean?

  9. In your own words, what does “Fail-safe” mean?

  10. In your own words, what does “Oscillation” mean?

Quiz answers

Reveal all 10 answers after your attempt
  1. Obstacle avoidance converts range or contact observations into safe movement choices. It needs detection limits, stopping distance, a recovery action, and a fail-safe response to invalid data.
  2. Required free space around a robot.
  3. Distance traveled after a stop decision begins.
  4. It reveals where the expected value or behavior first changes, so debugging is based on evidence.
  5. It should reject the input, report the problem, or move to a documented safe state instead of guessing.
  6. Required free space around a robot.
  7. Distance traveled after a stop decision begins.
  8. Choosing actions directly from current observations.
  9. A response that moves toward a safer state after failure.
  10. Repeated switching between competing actions.

Summary

reactive obstacle avoidance becomes manageable when you identify the input, processing, decision, output, and evidence of success. Build the smallest version, test it, then make one measured change.

Continue learning

Continue to the next lesson, which builds on this model with one additional capability.

Choose a connected learning path

Sources and further reading

Prepared 2026-10-02. Editorially completed for the course. Software examples are designed for current Python 3; verify board, operating-system, library, and hardware details against the linked primary documentation before a physical build.