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:
- This file contains a simple driver main that calls the makeBox function. You can use it for testing your functions, although you may want to change it to help you get your program right.
- This file contains the declarations for the functions that you are to implement.
- This file contains the declarations for the functions that are defined in util3pi.cpp.
- This file contains some useful function definitions. You can call any of these functions in your implementation. Note that you are not expected to understand all of the code in this file at this point in the course.
To complete this assignment, download the above files as for previous
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:
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.
A function to cause the 3pi to turn on the spot 90 degrees to the right.
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
assign2.cpp using websubmit.
Last modified $LastChangedDate: 2014-01-27 10:09:11 -0330 (Mon, 27 Jan 2014) $