The Light-Seeking Robot
For this assignment, you should develop a robot that seeks the light. You should use two touch sensors, used to avoid collisions, connected to the inputs A and C of the robot, and a light sensor, used to detect the light levels, attached to port B. The motors should be connected to outputs A and C, respectively.
Behavior
The light-seeking robot should follow the following general behavior:
Orientation phase: When started, the robot should orient itself and find the direction where the light is strongest, then start moving in that direction. The orientation can be accomplished via a 360 degree rotation, with an appropriate control logic.
Cruise phase: Once oriented, the robot should proceed in the direction where the light is strongest, periodically making small corrections to the trajectory to ensure that the light is effectively seeked. If during the cruise phase, the robot notices that the light level drops considerably, a new orientation phase should be entered.
Obstacle avoidance phase: At all times, when the robot collides with an object, it should:
- Back off
- Turn away from the object
- Possibly move forward a bit
- Enter an orientation phase
Programming
You should program your robot as an event machine. You do not need to have a single variable implementing the state: rather, you can have a set of variables, which together describe the state of the robot. Clearly indicate in your code which ones are the state variables. Model your code after the code in eventrover.c
Evaluation
I will evaluate the assignment both on the basis of the code, and on the basis of its peformance. For the code, I will look at:
- Elegance, clarity to a reader
- Clean design
- Documentation
- Use of event-based approach
For the performance, we will construct some interesting situations for the robots, with various light sources and obstacles -- a sort of obstacle course -- and we will see how the robots do.
