1020: Introduction to Programming Winter 2014

Assignment 2

Due: Feb. 3 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 three C++ functions that work together to drive the robot around a 2'x2' square. 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 assign2.cpp and in it give definitions for the functions described below. You must include appropriate commenting for your file and for each function.

The functions you are to implement work together to cause the 3pi to drive around a square measuring 2 feet (0.6096 m) on each side, and end facing in the same direction as when it started (i.e., it should make four right turns of 90 degrees and four straight segments of 2 feet each). Testing Tip: The floor tiles in most of the S.J. Carew building are 1 foot square tiles. Also note that are not expected to get this to work perfectly, but you should tune your solution so that you finish reasonably close to the starting position.

The functions you are to implement are as follows:

  1. void makeBox()
    A function to cause the 3pi to drive around a square measuring 2 feet (0.6096 m) on each side, and end facing in the same direction as when it started (i.e., it should make four right turns of 90 degrees and four straight segments of 2 feet each). This function must call the other two functions, below.

  2. void turnRight()
    A function to cause the 3pi to turn on the spot 90 degrees to the right.

  3. void driveAhead(double distance)
    A function to cause the 3pi to drive straight ahead the given distance, in metres.

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 assign2.cpp using websubmit.


Last modified $LastChangedDate: 2014-01-27 10:09:11 -0330 (Mon, 27 Jan 2014) $