Building a scanning sonar
Using the distance sensor we attached in Chapter 8, Programming Distance Sensors with Python, with the pan and tilt mechanism allows us to set up an interesting experiment. If we attach the distance sensor to the head, and then slowly sweep in a direction (for example, the pan direction), we can create a sensor sweep of an area. We can then use some Python code to plot this, making a small map of things in front of the robot.
A sensor similar to this combination is found in advanced robots (like those from Boston Dynamics) and autonomous cars. LIDAR and RADAR sensors use laser light or radio frequencies with a fast spinning drum to perform the same kind of sweeps far faster than our example. LIDAR sensors are starting to appear on the hobbyist market, but are still a little costly.
To visualize this, we are going to use a special kind of chart – a polar plot. This plots around a circle, with the x-axis being where we are around a circle (in radians...