Rescuer Learn 3: Following a Wall

This is the third challenge within the Robotics with GoPiGo and Python Curriculum.

Your task is to design a robot program that can navigate through the maze-like jungle without trampling over any plants or getting stuck in any dead ends.

Learn how to use the Distance Sensor and practice using the left-hand rule of maze-solving.

5. Correcting for “Drift”

If your robot is drifting away from the box you can make a minor adjustment to the code to correct for this and ensure that it continues to run parallel to the box.

There is a template notebook function called align_with_left_wall() . To use it, add the code highlighted below in the image in bold red font to the Main Code cell just below the while left_values[-1] < large_distance_cm:line.

The code is provided here for readability.


Pay attention to proper indentation (either 4 spaces or 1 tab, don't mix them)

For the curious among you, the align_with_left_wall() function uses trigonometry to correct the angle of orientation of the robot. Correction angles are based on the change in distance to the left wall between the last two sample measurements and the straight line distance the robot is known to have travelled between these two sample points (sampling_distance_cm).