CS 273 Lab 10: Mars Rover

Dept. of Computer Science, NMSU

Fall 2006

Due Date: December 7

This is a team assignment. Individuals do not need to work on their own solution. Team members should work together, and should avoid trying to solve the problem on their own. This is a 200 point lab. Note: this lab cannot be turned in or demo’d late! The lab must be demo’d, and the robot cars then dismantled, on Nov 30, 2006.

1 Overview

Your job is to write the software of a (simplified) Mars Rover. Our Mars Rovers are semi-autonomous. They are sent a plan through communication, but can impulsively react to their environment as well. The Martian surface will be represented by a white surface with some occasional black marks on it.

2 The Plan for Mars Rover

When it starts the Mars Rover will be connected to the docking base (a PC). It will receive a driving plan from the base. The driving plan will be in the form of a sequence of characters including the digits ‘1’ through ‘9’, the character ‘L’, the character ‘R’, the character ‘A’, and the character ‘B’. A plan will never be longer than 25 characters, and the character ‘B’ will always end the input sequence. The rover should echo the characters by transmitting them back to the PC as they are received.

After receiving the plan, the Rover will be disconnected from the base and rocketed to Mars (i.e., you will place it on the big white sheet). The Rover will begin executing the plan when the IRQ button is pressed.

Each digit represents driving forward for a duration equal to one quarter of a second times the value of the digit. The character ‘L’ means a 45 degree left turn and the character ‘R’ means a 45 degree right turn. For example, Reading in “42LL5RRR222” means drive forward for 1.5 seconds, take a 90 degree left turn, drive forward for 1.25 seconds, take a 135 degree right turn, and drive forward again for 1.5 seconds.

The character ‘A’ means analyze the rocks in front of you. Your Rover should sit in place for two seconds, and light up one green LED (with no motor connected), indicating it is analyzing. After it is done it should continue the maneuvering sequence.

Any time the Rover is going forward, it might happen to pass over an interesting rock that should be analyzed. This is detected by passing over a dark surface. The Rover should stop for two seconds, do an ad-hoc analysis, indicated by a lit red LED (no motor connected), and then continue. Objects will never be bigger than 2 inches in diameter, and each object should only trigger one analysis. (I.e., you need to be able to drive away from it without re-triggering another ad-hoc analysis.)

An input sequence will always end with the character ‘B’ (And ‘B’ will not occur anywhere else in the sequence). This means “return to base”. Your Rover should remember which direction the base is in (where it started), and it should turn towards the base and head there in a straight line. It should NOT simply reverse the outgoing sequence of moves. It does not need to know how far the base is away from it. It does not need to try to figure out the detailed angle at which to return – all it needs to do is to turn back to the opposite heading from what it originally started out at. For example, if the robot had turned 45 degrees to the right and then 90 degrees to the left, and then needed to return to base, it should turn 135 degrees left (or 225 right) and then move forward to take it back to the base.

When the Rover returns to the base and docks (indicated by a switch contact being pressed), it should stop and report what it did. To report, the Rover waits to be connected to the docking base (the PC with a phone cable!), and waits until it receives an ‘R’ character. It then sends four characters back to the base: a ‘P’, then a single digit that is the number of planned analyses accomplished, then an ‘A’ and another digit that is the number of ad-hoc analyses accomplished.

NOTE: The following capabilities are worth extra credit: - After finishing the reporting, without power cycling the Rover should then clear out all of its data, and accept a new travel plan, and start all over. (1.5pts) - Instead of just reporting the counts of analyses done, the Rover can report back the actual light sensor readings for each of its analyses (in hex). (20 pts)

3 Grading

Point breakdown for the different functionality will be as follows:

Since this lab is due at the end of the semester, there will be no late submissions accepted. Your car will have to be dismantled during your lab period, and the parts turned in. As a team, you must check in two red motors, a phone cord with its serial port adapter, and the grey toolbox with all the tools. All other small lego parts must be turned in as well, but those that are listed must be checked in, or their cost will be charged to your team.

4 Lab Turnin

For this assignment, you should submit your assembly programs through the web, and you should demonstrate a working car to the TA or professor. Make sure you write clean, well-designed, well-documented programs!