CSCI 108 Lab 8

Description

This week is the first part of a three week lab that involves building a Trashbot. The goal of the Trashbot is to find and move garbage. In this phase you will program your robot to use sonar to detect and approach trash.

Your robot will be placed on a flat surface, which you can assume to be empty, except for a piece of trash - specifically, a two-liter soda bottle. Your robot must detect and move to that soda bottle.

You cannot assume anything about the starting location of the robot relative to the trash. However, you can assume that the closest object to the robot will be the soda bottle.

Writing the program

Before you do anything else, be sure to call the function sonar_init().

Now you can concentrate on the task at hand. One way to go about accomplishing this task is as follows. Begin by doing a 360o scan, noting the direction in which the trash appears to be. Don't attempt to continuously monitor distances using sonar. Instead, stop at various points in the 360o turn, using the sonar to find distances while the robot is at rest.

Once the direction of the trash has been determined, begin to move in that direction.

Remember that robots are imperfect. Even if the direction selected is reasonable, there is a significant possibility that the robot will drift off course. Therefore, you might find it useful to move forward only a little at a time. Whenever you stop, note the current distance of the target. Then scan a little to the right and a little to the left. Make an adjustment to the direction of the robot, if necessary.

When you reach the target item, stop.

Better determination of distance

While our ultrasonic range finders are quite good, they aren't perfect. Therefore, rather than relying on only one measurement of distance for a given robot orientation, you should compute the average of several (say, five) distance measures. This will obviously take longer, but you will likely find the averages to be quite a bit more reliable than single readings. Also remember that distance measures can be negative. This occurs when the sonar device does not detect a returned "chirp" in a reasonable amount of time. You will have to handle such readings in a special way.

Testing

Place the robot on a flat surface, where the closest item is the target trash item (i.e., the soda bottle). Remember that you will need to move out of the way, so that the robot doesn't detect you rather than the bottle.

Don't stop at just a single test. Place the robot and the target in a variety of positions and distances from each other. What happens if there are multiple bottles to be found?

Requirements

You will need to demonstrate to me that your robot successfully locates target items.

You should turn in your program. Turn it in both electronically and on paper. Don't forget to put your name on everything submitted. It is particularly helpful if you put your name (or initials) in the name of the file you submit electronically.

This lab must be completed by Monday, November 10 at 10:00 PM.

Before leaving the lab

Before you leave the lab, please be sure to do the following: