1020: Introduction to Programming Winter 2014

Assignment 4

Due: Thursday February 20, 2014 at 12:00 noon

This assignment is to be done in pairs. Each pair of students should submit only one solution, but both names must be listed in the code.

In this assignment you will create a C++ function to drive the robot around a course following a black line. We have provided the following files:

To complete this assignment, download the above files as for previous assignments, and save them in the project directory. You must then create assign4.cpp and in it give definitions for the function described below. You must include appropriate commenting for your file and for each function.

The function you are to implement is as follows:

  1. void followLineLaps(int count))
    Image of track A function to cause the 3π to drive around an oblong track (the shape should be irrelevant as long as the corners are not too tight), as pictured to the right, following a black line for count laps. The laps are marked by a gap in the line of approximately 3 cm in length, which you can assume to occur on a relatively straight part of the course. Once it has completed the requisite number of laps it should stop (see demo video). Tip: to help you know what your program is doing, it is helpful if the 3π gives an audible signal when it finishes each lap. You can do this using the play function.

While you are welcome to change the code in assign4_3pi.cpp, there are some aspects of it that are important for correct functioning. In particular, lineCalibration must be used before the sensors will function correctly. To run the test program, after you have written your followLineLaps function, compiled it and downloaded it to the 3π, follow the following steps (see demo video):
  1. Set the 3π down so that the sensors are approximately centered over the line at the start of the course.
  2. Press B to start the calibration. After a short pause the 3π will turn left about a half turn, then turn right twice as much, and then left again so that it ends up where it started. During this motion the line sensors must pass over the black line and on to clear white space so that they are calibrated.
  3. You may want to adjust the position of the 3π at this point so that the number displayed is about 2000.
  4. Press B again to start following the line.
  5. When your function ends the 3π will play the success song, and print "Done." on the LCD.

After you have tested your program and are confident it is right, have a TA observe your robot functioning correctly and check you off, then submit assign4.cpp using websubmit.


Last modified $LastChangedDate: 2014-02-07 20:59:14 -0330 (Fri, 07 Feb 2014) $