This project is primarily about code organization and software architecture. The end goal is to have the robot navigate a simple maze.
Since this project involves refactoring your code, it may be wise to make a new subdirectory for this project. Copy over only the code you need into the new organization.
The overall concept of the software architecture you will build this
week is that of a state machine. Your main function will be a simple
loop that has three steps.
- State update step: this should call a function that evaluates the current sensors, internal robot status, and current state, and sets the next state and goals of the robot.
- Nav step: this should call a function that takes in the state and any other status information and determines the appropriate velocities for the robot.
- Action step: this is a simple call to vm(v, w). You may want to implement limits on v and w in the main loop, just before calling vm.
Your nav function should take in a robot state data structure that contains the current state and any necessary additional information, such as the current goal angle, distance, or position.
The nav function should have a big case statement based on the current state. Each case should call a function that specifies the translational and rotational velocities given the state and the current goals.
After the case statement, the nav function should evaluate the sensors for local obstacles, and modify the velocities appropriately. In some states, such as the rotate state, this step may be optional. In other states, such as wall following, obstacle avoidance may be built into the function.
- The first task is to have your robot read in a set of x, y locations and have it go from point to point to point until it reaches the last point. This of this as a POINT_FOLLOW state with an index, an array of points, and the number of points. The index indicates which point the robot is currently trying to achieve. When it achieves the current point, it should increment index and go to the next point, until index is equal to the number of points, in which case it is finished and should return to an IDLE state. It is fine for the robot to stop at each point. You can assume there are no obstacles between points, but the robot should be sensitive to obstacles in the environment and not run into anything.
The second task is to generalize your wall following so the robot can
go to a wall if one is not near and turn appropriately given internal
and external corners. You can treat this task as one having four
states: WALL_FIND, WALL_FOLLOW, WALL_ECORNER, WALL_ICORNER.
Alternatively, you build it all into a single WALL_FOLLOW state.
Next week we'll build a simple maze in the lobby and see if the robots can traverse it. We'll put a circular obstacle at the end of the maze, and it will be an extension to recognize the obstacle and stop a set distance away from it.
- Try to get smooth motion as the robot goes from point to point.
- Add other states and capabilities to your system, including ROTATE, TRANSLATE, ACHIEVE, or WANDER.
- Add some kind of feature estimation to your wall follow, trying to identify line segments.
- Create some type of obstacle that could be placed at the end of the maze so the robot knows it has found the end.
The writeup for each project should be a brief summary of what you did along with some code examples, terminal output, or screen shots, depending upon the assignment. Please organize the writeup as follows.
- Title of the project and your name
- An abstract describing what you did in 200 words or less.
- A brief description of code you wrote and experiments you ran.
- A brief description of what you learned.
Make your writeup for the project a wiki page in your personal space. If you have questions about making a wiki page, stop by my office or ask in class.
Once you have written up your assignment, give the page the label:
You can give any page a label when you're editing it using the label field at the bottom of the page.
Do not put code on your writeup page or anywhere it can be publicly accessed. To hand in code, attach it to an email and send it to the prof.