This project envisions a parade of robots, in which each robot follows a common script (provided by the instructor) that specifies actions along a pre-determined route — both within the classroom and into the hall.
The parade theme for this project is based on a class project developed by Peter-Michael Osera for CSC 161 in Spring 2016.
This project builds upon the Robot Command Project. You are encouraged to reuse the functions from that project (giving credit/acknowledgement for the partners who helped develop code for that assignment). A revised program will read and respond to robot commands, with three primary changes (and some modest adjustments) from the previous project:
When the robot first begins, a few initial commands (from the keyboard) will move the robot to the location where the actual parade will begin.
Input may come from either the terminal or from a file whose name is specified on the command line.
As the program runs, it may log its actions, together with the time that each action occurred, and the current values of the Scribbler's left, middle, and right light sensors (from
The next sections describe the overall program requirements in some detail.
As preparation for the parade, each team's robots will be placed on the floor in a line, pointing in the same direction. The parade program will then follow these initial steps:
The program should use
rConnect to connect to its robot, so the robot is ready to receive commands.
The program should print a prompt, indicating the user should type a letter (and <enter>).
When the program reads a full line (one or more characters with return), the Scribbler 2 robot should move forward slowly — at speed 0.25 indefinitely.
Hint: Use the
rMotors function for this.
The program should print a second prompt, indicating the user should type another letter (and <enter>).
When the program reads a second full line (one or more characters with return), the program progresses to its "parade mode" — reading and following its parade script, as described in the next section.
For this project, the program will read commands either from the terminal or from a file.
The commands for this project are mostly from the Robot Command Project, with a few refinements. In particular, the program should respond to the following commands:
In reviewing these commands, note that
forward, turnLeft, turnRight, and beep are identical to the previous project.
quit is the same as before, except that a 10-second forward movement is added before the program terminates.
song is a new command, but it might be similar to parts of a creative function you developed earlier. In this command, note that the 2-second timing of the song segment should be reasonably precise (i. e., neither longer or shorter).
All parameters should be doubles, except the beep frequency and the number of song repetitions which are integers.
The following notes clarify various details of input.
Each command for this project must be on one line. In each case, the command name and any parameters will come first. The program should ignore any further material on the line.
If necessary, it will be safe to assume that any input line will be no more than 80 characters.
As an example of possible input lines, the program should be able read a log file, with each command's time stamp, as described in the logging section below.
If robot commands are to be entered at the terminal, the program should print a menu of commands once, at the beginning of the program, but the program should not prompt for commands or parameters thereafter.
If robot commands are to be read from a file, the program should not print any listing of commands (and no command prompts).
As commands are read, if the program identifies an ill-formatted command, the program ignore that command (and the entire line containing it) and proceed with the command on the next line of input.
As with any academic work, if you use code from an earlier lab or project, you should cite it in your academic honesty statement.
File sample-parade-script.txt provides a sample script file that might be used to test your parade program.
File robot-parade-script.txt contains the current version of the parade script.
Since input may come from either the terminal or a file, it is suggested that the program begin with a file declaration such as
FILE * infile = stdin;
In C, stdin is the name given to the input stream, initially from the terminal. With this statement, infile will designate terminal input. Then, as part of command-line processing, one could reassign infile:
infile = fopen ( ..., "r");
if the command line indicates commands are to be taken from a file.
infile identifying where to read (either stdin or an opened file), then the reading processing in the program for the Robot Command Project can be modified to reflect reading from this file. (I.e., scanf (...) becomes fscanf (infile, ...), getchar() becomes getc(infile), etc.).
infile == stdin later in the program is a simple way to determine whether or not input is from the terminal and an initial menu of commands needs to be printed.
If the command line contains the successive elements, -log <logfile>, the the program should log each command executed by the robot together with a timestamp when the command was executed and the values of the Scribbler 2's light sensors. When logging commands:
<command> [<parameter>] [<parameter>] <timestamp> ( <left brightness sensor value> , <middle brightness sensor value> , <right brightness sensor value> )
/* determine time and print it */
time_t mytime = time (NULL);
char * timeStr = ctime (&mytime);
/*remove '\n' at end of time string, if present */
if (timeStr[strlen(timeStr)-1] == '\n')
timeStr[strlen(timeStr)-1] = 0;
fprintf (logFile, " %s", timeStr);
Since a log file may or may not be needed, it is suggested that the program begin with a declaration such as
FILE * logfile = NULL;
Then, if a log file is designated on the command line, one could reassign logfile:
logfile = fopen ( ..., "w");
Within this framework, when a command is read from the terminal or from a file, the program could test
logfile == NULL to determine if the command should be logged.
(The following is taken from Peter-Michael Osera's Parade Project, with minor editing.)
On the last day of class, we will hold a Scribbler parade using our programs to control robots. A small portion of the final grade on the project is dedicated to participating in the parade. Your program does not need to work perfectly (and I do expect some chaos due to the uncertainty of the robot's behavior and differences in each robot's motors), but you and your partner should be present with your program and a Scribbler to receive credit for this part.
As noted above, initially we will position the robots in a straight line and start everyone's parade programs. All at once, we will start the robots moving forward slowly toward a starting line. Once a robot passes the starting line, that robot will begin reading commands from a script file that will be distributed to the class before the parade. Along the parade route, you should babysit your robot to ensure that it does not veer off course or otherwise behave badly.
Mr. Osera also suggests that you consider dressing up your Scribbler for the parade. He notes, "The Scribblers look an awful lot like floats. Feel free to customize your Scribbler to your heart's content for the parade!"
Global variables may not be used in this project. Use parameters to communication data into procedures.
You are encouraged to use either your command-robot.cprogram as the basis for the command input.
On the command line, the I/O options,
-input <inputfile> and
-log <logfile>, may appear in either order.
This project will be worth 25 points, based on the following rubric:
[4 points] Start up: The program waits for initial input, moves forward, waits for more input, and enters "Parade Mode".
[10 points] The program reads commands properly.
[3 points] The program correctly interprets the -log directive on the command line
[6 points] The program correctly logs entries within a designated log file.
[3 points] The robot commands are properly implemented
[2 points] Code is well documented, reasonably efficient and well-structured, and appropriately tested.
Neatness and conciseness of code
follows the style guidelines (no points earned, but difficulties could deduct points)