CSSE 120R Final Python Robotics Project—Winter 2008-2009

Disclaimer: Some details may still be vague and subject to change; we'll alert you when they do.

Project Requirements

The final project for the Python part of this course is to implement a GUI for robot control that includes an Infrared Artist!

Your project must satisfy these core requirements:

  1. You must complete the implementation of a GUI to control your robot.
  2. You must implement IRMapper and IRColor classes.
  3. All team members must contribute to and understand their project.

Most of the work on your project will be translating the guidelines provided into a working implementation. If you are having trouble planning or getting started, get help. It is much better (and easier) to get help early and start off with a good plan than to try to hack a poor design into a semi-functional program in the final days before it is due.

Milestones

To make sure that you are on-track to complete your project, you must meet the following milestones. Each milestone will contribute to your overall project grade. Each milestone must be done before the specified class session unless specified otherwise. For each milestone, you must commit your work to your repository and include a clear commit message stating that that milestone is completed.

Grading

Project grades will be based on both individual and group results. We will check off each project milestone, to make sure you are making steady progress. The final project program will be graded based on both the proper functioning of your program and an evaluation of your design, coding style, and documentation (including SVN commit messages). The grade will also depend heavily on what enhancements you add (see below).

Each team member will be required to complete an evaluation survey about his or her own performance and that of each of his or her teammates. We will use these surveys and our own observations to assign individual project grades.

Here is the rubric we will use to grade your program.

Details

GUI

Your GUI must support as a minimum:
  1. Connecting (to the specified port number) and disconnecting from your robot.
  2. Driving your robot directly at the specified speeds.
  3. Making an IR map of the room.
  4. Playing a very short song.

Example:



This is just a sample of what my GUI looked like.  You can use the given layout or make your GUI look different, but you shouldn't waste hours moving rectangles.  Focus on the interesting parts of the project, like IR Mapper. The capital letter shows the quick key for each button.

Note: the Re button is for Disconnect and Reconnect.  This button seems worthless but is a good solution to the sensing garbage problem.  With it, if one senses garbage, one can click on the Re button to disconnect and connect again, which fixed the sense garbage for us almost every time.

IRMapper Class

The purpose of the IRMapper Class is to paint a map of the IR values seen by the robot.  For example, if the robot is seeing an IR value of 248 it should be using a Red pen.  When the iRobot makes a position calculation, it makes a circle at that location and connects a line to the prior point.  In order to determine which color to use when a certain IR value is seen, the IRMapper needs to open a file which has the following format:

# IR signal, Color name, Description

There could be as many as 255 lines in the file if every IR value were defined.  Here is a sample of that file for the IR values that relate to the docking station:

242, blue, Force Field
244, green, Green Buoy
248, red, Red Buoy
255, gray, No Signal

The complete file, irNumbers.txt, is in your project folder. You will need to read this file when you construct an IRMapper object. 

To store the 3 values on a given line, you will construct an instances of the IRColor class (below). The IRMapper class will thus contain a list of IRColor objects, one object for each line of the file. (Note: we acknowledge that an alternative would be to use a list of lists, but lists of objects are the preferable way to do this, and extra practice creating objects will help with Exam 2).

The IRMapper class will be constructed by passing it the following information: a filename with the color IR information, the parameters necessary to create a new GraphWin window, and information about where the robot should start off in the window.  All constructor values should have a default set.  Here is an example of the constructor input parameters. 

filename = 'irNumbers.txt',, windowTitle = "IR Map", windowX = 600, windowY = 400, startingPoint = Point(200,200), startingAngle = 0


The primary task of the IRMapper class is to receive a new distance and angle from the robot and draw a circle at the new calculated location.  This will take a bit of math.  To make the math a bit easier we'll always use the ratio of 1 pixel = 1 centimeter.  So the default values above made a 6 meter by 4 meter window.

Example 1

The robot is at (0,0) and currently at a 0 degree angle. We will define pointing directly to the right as zero degrees and CCW as positive (so 90 degree is straight up).  If the robot moves 8 centimeters and rotates 0.2 radians then you need to calculate the new location and position.

 averageAngle = old angle + the 0.2 radian change / 2   # note: your solution might not need to divide by 2; ask your instructor about this.
 deltaX = 8 * cos(averageAngle)
 deltaY = 8 * sin(averageAngle)

new X = old X + deltaX
new Y = old Y - deltaY    # Since positive numbers are down
new Angle = old angle + angleChange

This makes the current location
    x = 207.960033322224 centimeters/pixels   y = 199.201332666825 centimeters/pixels  angle = 0.2 radians

Example 2

This time the robot moves 12 centimeters and -0.8 radians
 (see if you can do the math manually)

This move makes the current location
    x = 219.720832256319 centimeters   y = 201.585364636366 centimeters  angle = -0.6 degrees

Required methods

The class must support the following methods:
  constructor as defined above
  moveDistanceAndAngle(distanceTraveled, angleTraveled, irValue)
  setCircleDiameter(newCircleDiameter)

Suggestions

It might be helpful for the class to have things like the following:

Instance fields to store the following information:
  The current location of the robot stored in centimeters/pixels as a Point
  The current angle of the robot stored in radians
  A window to draw in
  Circle diameter to use when drawing (default = 3)
  A list of IRColor objects
  The window X and Y sizes for gridlines and message box
  A text message that displays the description of the IR value being seen

I also found it handy to make methods to the IRMapper that would let me control the window:
    def getMouse(self):
        self.win.getMouse()

def close(self):
        self.win.close()

Your IR Map should have a white background and grid lines clearly showing 1 meter grids.  Here is a sample image (obviously from fake sample data, with some extra colors).  I think when you run the test #1, you will see the yellow and purple showing up in red.  This image is a 600 x 400 image with the iRobot starting at 200 x 200 (the default values).

IRMap

Here is a map coming from real data following the track:
 (You can see colors where the iRobot is picking up an IR value)
Real IR Map
Then I also made a log of moving back and forth in front of a home base.  It looked like this:
Home Base Log

Admittedly I made a log file from my iRobot then went in and did a little doctoring to make the images look better.

To test the IRMapper class I provided you with these files, and the code necessary in main to test your IRMapper when you finish it.  Test your classes with simulated data before you try to use the robot real time.

IRColor Class

This class is a simple data structure for objects that store the irNumbers.txt info. It is common to make small classes to do simple functions. In this case, the constructor will take as a parameter a line (string) of the irNumbers.txt file containing the IR Value, color to use when painting, and the description of the IR value. It will then split it and store the IR value, color, and description.  It must implement the following functions.

class IRColor:

"""Simple data structure to store the IR number, color, and description"""

def __init__(self,fileLine):

def getIRNumber(self):

def getIRColor(self):

def getIRDescription(self):

Hardware

  1. Omnidirectional IR Transmitter. Place it on top of your BAM (wireless receiver) module and plug the red wire into +5V and the black wire into LD1, both on the back of the BAM.

Demo

Each team will have a short amount of time (~5 min) in class to demonstrate their program, especially your enhancements to the instructor. You will be judged on your program's functionality and how well each of the team members can explain the code. (This is to encourage you all to work on the code together and to contribute to it.)

Art Contest

Bringing it all together in a controlled drive competition!

  You will use your direction buttons to drive your robot around a 6 foot by 4 foot area.  The area will be setup by your instructors to have some IR values in the 6' by 4' area.  We might have a docking station, an iRobot or two transmitting values (which might change with time), and maybe even a virtual wall (which you haven't seen).  You will be driving around the area (with your IR off) painting the canvas!  Doing well in the Art Contest will help your enhancements score (see below about enhancements).

Suggestions

Enhancements

Once you are done with the project requirements, you will then add some enhancements. You will earn a higher grade for doing more challenging ones, and the more, the better. Here are some suggestions, to get you thinking.