Skip to main content

Section 4.4 ActiveCode Exercise: Reactive Wall Avoidance Steering Logic

This exercise models a reactive controller that uses three distance inputs: left, front, and right. The goal is to return one steering command at each update step: move forward, steer left, or steer right.

Subsection 4.4.1 Controller Rules

Use a clear-path threshold of 1.0 meter and a danger threshold of 0.5 meters.

Subsection 4.4.2 Try It

Run the code below, then edit the front, left, and right values in test_cases to explore other sensor readings.

Subsection 4.4.3 Test Case Interpretation

Example sensor readings are front = 0.4 m, left = 1.2 m, and right = 0.3 m. Since the front path is blocked and the left side has more clearance than the right side, the expected action is to steer left.
You have attempted of activities on this page.