Again we'll be looking at the problem of motion planning: given a robot R and an environment (or physical space), a start and end position pstart and pend, find a path so that the robot can move from start to end, without collisisons.
For this assignment the robot is a rectangle.
Notation: we'll assume that the obstacles consist of n edges. So for us O(n) represents the complexiy of the obstacles (vertices plus edges). We assume that the robot is moving in a large bounding box B that contains all polygons.
We consider the problem in the configuration space, in addition to the physical space: the physical space is the space where the robot is moving. The configuration (or parametric) space is the parametric space where the robot is moving; put differently, it's the set of all positions for the robot.
We view the motion of the robot as a path in the physical 2D space, and associate with it a path in its parametric space. Remember that a path in physical space has to be collision-free. We have to extend the concept of obstacles. Obstacles exist in physical space, and we need to generalize them to parametric space. Consider a robot R and a physical obstacle O; the parametric obstacle PO corresponding to the real obstacle O can be defined as follows: PO is the set of all parameters (x,y) which, if the robot were placed at (x,y), it would cause a collision with O. Put differently, a point (x,y) is part of PO if placing the robot R at position (x,y) would cause a collision with obstacle O.
The free configuration space represents all points in parametric space that are not part of parametric obstacles.
The basic steps of generic motion planinng are as follows:
Heuristics: In many practical situations, computing the free configuration space and a complete roadmap is too costly or is not possible. However, this idea of framing motion planning as a search in parametric space is nice and convenient, because it allows for artificlal intelligence heuristics. A common idea in many approaches is to discretize free space and approximate it with a grid. This is what you'll implement for the second part of this assignment.
a state is a position (x,y) of the robot Q is a queue (priority queue) of states initially Q contains the start position while goal not found remove state s from Q find all successors of state s (all states where we can move from s) for each such successor s': if s' is the final goal state, then we are done; otherwise check that we have not been there (at s'); if we have, skip to next successor check whether placing the robot at s' would intersect any obstacle; if not, put s' on the queueTo guide the search towards the goal, score each state with a cost function that adds two components: the euclidian distance of that state from the goal state, and the euclidian distance form the start state.
Approximate the parametric space with a grid. What this entails, for your algorithm, is how you generate the successor states: a state (x,y) can move only to its 4 neighbors on the grid: (x, y+1), (x, y-1), (x-1, y), (x+1, y). You could also allow diagonal moves, that might speed up teh search. Assume the resolution of the space is the resolution of the window (500 by 500?).
Testing for intersections: your basic interscetion function will be to test whether the robot, when placed at (x,y), would stay completely in free space. One way to do this is to check, for each of its 4 edges, whether it intersects any obstacle edge (you'll need to think of something to detect when robot is completely inside a polygon). Another idea is to pre-process the scene in an occupancy grid: this is a grid that stores, for each pixel in your discretized parrametric space, whether that pixel is free, or occupied (falls inside an obstacle). If you have an occupancy grid, then you can use it to determine whether a state is intersection free, by essentially checking every pixel that the robot occupies to see if it is free or not.
Keeping track of the path: During the search, whenever a state discovers another state, set parent pointers appropriately. At the end, you'll be able to start from the goal and move through the parent pointers and find the path. The goal of the program woudl be to find and render this path.
How to turn in: Please check in your code to teh svn folder provided, and I will access them in your svn folder.
Enjoy!