Project: Obstacle Avoidance
You will write a program governing robot behavior so that it avoids obstacles. Since one obstacle might be boring, you will also make the robot do something novel when it has been repetitive and dance every so often because life is too short not to.
Working in pairs, you will develop a program that includes these elements:
- The robot should move so as to avoid obstacles in the room.
If the robot performs the same two turns consecutively
(e.g. two right turns), the robot beeps and turns for a
second or two (before performing any further movements).
- Note: The beep/turn around activity applies only when there are two turns, so going forward or backward twice in a row does not count!
- The turning that accompanies a beep should not count as an action.
- To accomplish this requirement, you likely will need at least one variable that keeps track of the previous robot activity. This variable is updated after each action. After a turn left or right, this variable can be consulted to determine if the previous action (turn or movement) was the same type of turn.
- Every ten actions, the robot performs a short dance three times in a row (the dance can just be a few actions).
- Actions are:
- ANY forward or backward movement that is not part of your dance
- ANY turn that is not part of the dance or beep/turn around segments
- In short, count as an action ANY movement that is not part of the dance or the beep/turn segments.
The program contains at least
The program contains a
switchstatement or a second
The program contains at least three loops; at least one must be
forloop, and at least one must be a
- The program displays an indicative message each time it turns, each time it moves forward or backward, and each time it performs its short dance after ten other actions.
Note: The robot's motion need not be continual; you can interleave short motions with sensing operations.
Together with the program, your test plan (aka "commentary") must describe what steps are needed to demonstrate the program is working correctly (this can be narrative, pseudocode, or a combination).
Beeps during the "moving about"/"avoid obstacles" phase should not
count as actions. Thus,
right right beep/turn rightwould be followed by a beep and that sequence contains only three actions.
- The robot need not beep if there are two same turns in a row during its dance; it only needs to beep during its "moving about"/"avoid obstacles" phase.
- The robot need not avoid obstacles during its dance.
The robot should keep executing the behaviors until the program
This is one of the few times you are allowed to use an infinite
You MUST include your program (the .c file) AND a separate document (as a text file) in both the printout and the email to the grader account.
The test file must include a description of how you intend to test your program, a statement that you DID follow your test plan, a statment that you DID see the robot acting as expected, and THEREFORE your program is functioning correctly. Failure to follow these instructions will cost points under the testing category.
Global variables are STRONGLY DISCOURAGED and should not be needed in this project.
To create a transcript, see these instructions.
- [3 points] Program guides robot through a sequence of moves
- [3 points] Robot avoids obstacles encountered
- [2 points] Robot beeps and turns if it performs two turns in a row
- [2 points] Every ten actions, the robot performs a short dance three times
- [2 points] Terminal display identifies actions
- [2 points] Uses at least two if statements or one if statement and one switch statement
- [3 points] Uses at least three loops (as specified)
- [8 points] Testing
- [2 points] Test plan enumerates problem circumstances.
- [2 points] Test plan lists cases with expected outcomes
- [1 points] Transcript records compilation and test runs
- [3 points] Summary statement describes outcomes and explains why the program behavior is correct.
Points may be deducted for poor program format, readability, comments, etc.