Project: Robot Parade

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.

Acknowledgment

The parade theme for this project is based on a class project developed by Peter-Michael Osera for CSC 161 in Spring 2016.

Robot Commands with File Input and Logging

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:

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

  2. Input may come from either the terminal or from a file whose name is specified on the command line.

  3. 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 rGetLightTxt or rGetLightAll functions).

The next sections describe the overall program requirements in some detail.

Robot Start Up

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:

"Parade Mode" - Reading Commands

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

Additional Command Specifications

The following notes clarify various details of input.

Handling Input

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.

With 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.).

Also, testing 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.

Logging

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:

Writing a log file

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 Scribbler Parade

(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!"

Final Notes

Grading

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)