Purpose:
So far we've learned how to control any pin we want and use that ability to drive the wheel motors on our robots. Now we need to understand how to get information from various sensors that we might need to be sure our robot doesn't run into walls or other objects.
The specific sensor we will be exploring in this lab is the ultrasonic ranger which uses sound pulses to measure the distance to a reflective surface in front of it. On the Qbot the ultrasonic range are the 'eyes' on top of the robot.
Procedure:
For this lab you need your Qbot and the Arduino IDE and your usual sense of curiousity. We'll assume that you have the IDE up and running and the IDE 'sees' your robot on the port. As usual I am providing you with the basic test code for each step. Your responsibility is to copy, save your own version of the code, and upload that code to the robot. There will also be a guide which walks you through the new tools in the code to help you understand what is happening.
- If you want a deeper dive into the ultrasonic ranger works you can visit this engineering page that is also linked in the Sensors II breadcrumb. The core concepts that we need to know are that we have to tell the robot when to send out a pulse of sound. There are some special tools that the Arduino uses to measure how long it took the pulse of sound to return from hitting the reflective surface. Once we know that time we have to calculate how far away the object it just as we did in the homework problem.
- Before we can explore how the ranger works we need to learn about a tool that allows us to communicate with our robot. In the motor labs we can watch the wheels and see whether the robot is doing what we expect. When we are reading sensors we need to use the Serial Monitor so the robot can communicate what it is doing. The serial monitor is a tool very much like the one your mechanic uses to communicate with the ECU (Electronic Control Unit) in a modern car. This tool, called a diagnostic scanner, allows the car to tell the mechanic what it is measuring from all it's sensors that it uses. The Serial Monitor is our 'diagnostic scanner'. Here is a short guide to using the Serial Monitor that uses a small peice of code to explore how we access the serial motor and how the IDE uses it to communicate.
- Now that we understand (a little) how the robot can communicate with us it's time to try out the Ultrasonic Ranger! Here is the usual basic code and guide to get the ranger up and working. When you return form this side trip you should be able to set the robot in front of some surface and accurately measure the distance to that surface using the ranger.
- Now that you have your Ultrasonic ranger working set it some distance less than 0.5 m from a wall and let it measure the distance. Find a ruler or tape measure and measure the physical distance (remember that 1 inch = 2.54 cm). Compare the ranger's distance with your physical measurement. Repeat this process for a distance more than 2 m from the wall. You may find that the robot 'sees' things like chair legs or low tables even when they are not directly in front of it. If the ranger and the physical measurement seem out of agreement check for this problem.
- In the next lab we will explore how to determine the field of view of the sonic ranger and what sorts of objects are more difficult to detect.
LAB DELIVERABLES: (Turn in on Bb)
I) After your name etc at the top of the document include a screenshot of your serial window showing that the ranger is making measurements.
II) Report both the ranger measurement and your physical measurement for the short and long experiments described above. By how much do they differ?