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.
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.
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?
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.