Module on Integrated Robotics

Project: A Robot Parade

This project envisions a parade of robots, in which each robot follows a common script 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 of Module 011. 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 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).

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), 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



created 19 July 2011 by Erik Opavsky
revised 16 August 2011 by Erik Opavsky
revised 14 May 2011 by Dilan Ustek, Erik Opavsky, and Henry M. Walker
revised 14 February 2012 by Henry M. Walker
revised 30 April 2012 by Henry M. Walker
revised 8 May 2012 by Henry M. Walker
minor editing 24 August 2012 by Henry M. Walker
updated 1 September 2012, 1 January 2013, 30 April 2013, 14 August 2013, 26 October 2013, 1 November 2013, 12 June 2014, 14 January 2015 by Henry M. Walker
rewritten as a parade 6 November 2016 by Henry M. Walker
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.