Computer Science 014
LEGO Robot Engineering

Williams College
Winter 2007


Lab 7: Trashbot
Due: 10:00 AM, Wednesday, January 17, 2007


For the last pre-designed lab, you will be building a "Trashbot" - a robot whose goal is to find and move garbage. First, you will use sonar to detect and move to trash. Then you will add a gripper that will allow the robot to carry the trash away to a designated area.

Everyone will demonstrate the status of their Trashbot's behavior during our meeting on Wednesday, January 17, but you may continue working on the trashbot for lab credit until the end of the week. That said, I would like everyone to make an effort to wrap up this lab as quickly as possible so you can begin work on your final projects.

Finding the Trash

The first task is to write a program to get your robot to find a single piece of trash - a plastic bottle - on a flat, open surface. Your robot must find and move to that soda bottle. You should assume anything about the starting location of the robot relative to the bottle. However, you may assume that the closest object to the robot will be the bottle.

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

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.

Once the direction of the trash has been determined, orient your robot and begin to move in that direction.

Remember that robots are imperfect. Even if the direction selected is reasonable, there is a strong 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, don't stop. Instead, push it out of the way. Your robot should only stop when the stop button is pressed.

To test your robot, place it on a flat surface, where the closest item is the target trash item. 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 at a variety of positions and distances from each other. What happens if there are multiple bottles to be found?

Demonstrate this functionality before moving on. If you would like feedback on your program at this point, you may turn in a hard copy.

Adding a Gripper

Now you will add a gripper that will enable the robot to grip and carry away trash.

As before, your robot will be placed on a flat surface, which you can assume to be empty, except for trash in the form of plastic bottles. Your robot must find and remove all of the trash. You cannot assume anything about the starting location of the robot relative to the trash. However, you can assume that the closest objects will be the plastic bottles.

You will build the gripper from LEGO parts, using a motor to control the open/close mechanism of the device. While you are free to design the gripper any way you would like, I recommend starting with one of the designs in Robotic Explorations by Fred Martin.

The gripper does not need to be very strong - the heaviest item it will be expected to grip is an empty plastic bottle. However, it must be quite large. You will likely find it necessary to rebuild parts of your robot to fit this new mechanism onto it.

Remember that sonar will continue to be a vital component of this lab. Keep the sonar device on your robot, but be sure to mount it a reasonable distance away from the gripper. You don't want the gripper to get in the way of the sonar's "chirp."

Standard Trashbot Behavior

Now you will need to extend your program from the first part of this lab to do the following:

As the robot moves toward the detected trash, it should check how far the trash appears to be. When the trash is fairly close (6 inches or so is probably a good distance), the robot should move just a little more and close the gripper around it. This will be a good test of how well your robot aims for the detected item.

Once the robot has gripped the item, it should move it forward a bit (the distance is up to you) and should then release it. At this point, it should wait long enough for someone to move the trash out of the way so that it can begin another search for trash.

If your trash-finding program did a good job of hitting trash head-on, then the extensions you need to write for this part of the lab will be minimal.

You will need to demonstrate your robot's correct behavior and submit a printout of your program.

Advanced Trashbot Behavior

Your final trashbot functionality involves dragging the trash to a specified "trash disposal area." Your robot should begin within this area, which will be a white area bounded by a black line (white paper taped to the floor by black electrical tape). It should use the same techniques to locate trash items that it did before, but instead of just pushing the trash out of the way, it should push or pull it into the trash disposal area. You can use your light sensors to determine when you are in the trash disposal area, but you will want to remember how far you've moved to make it easier to find after picking up the trash.

Demonstrate your program's behavior once again, and submit an updated printout.

Extensions

If you have the time and the energy, invent and implement extensions to this project.