Module dynamicGridMap :: Class DynamicGridMap
[frames] | no frames]

Class DynamicGridMap

gridMap.GridMap --+
                  |
                 DynamicGridMap

Implements the GridMap interface.

Instance Methods
 
__init__(self, xMin, xMax, yMin, yMax, gridSquareSize)
Basic initializer that determines the number of cells, and calls the makeStartingGrid method that any subclass must provide, to get the initial values.
 
makeStartingGrid(self)
Returns the initial value for self.grid.
 
squareColor(self, indices)
Returns: a color string indicating what color that cell should be drawn in.
 
setCell(self, (xIndex, yIndex))
Takes indices for a grid cell, and updates it, given information that it contains an obstacle.
 
clearCell(self, (xIndex, yIndex))
Takes indices for a grid cell, and updates it, given information that it does not contain an obstacle.
 
robotCanOccupy(self, (xIndex, yIndex))
Returns True if the robot's center can be at any location within the cell specified by (xIndex, yIndex) and not cause a collision.
 
occupied(self, (xIndex, yIndex))
Returns True if there is an obstacle in any part of this cell.

Inherited from gridMap.GridMap: boxDim, drawNewSquare, drawPath, drawSquare, drawWorld, indexToX, indexToY, indicesToPoint, makeWindow, pointToIndices, undrawPath, xToIndex, yToIndex

Method Details

__init__(self, xMin, xMax, yMin, yMax, gridSquareSize)
(Constructor)

 

Basic initializer that determines the number of cells, and calls the makeStartingGrid method that any subclass must provide, to get the initial values. Makes a window and draws the initial world state in it.

Parameters:
  • xMin - least real x coordinate
  • xMax - greatest real x coordinate
  • yMin - least real y coordinate
  • yMax - greatest real y coordinate
  • gridSquareSize - size, in world coordinates, of a grid square
  • windowWidth - size, in pixels, to make the window for drawing this map
Overrides: gridMap.GridMap.__init__
(inherited documentation)

makeStartingGrid(self)

 

Returns the initial value for self.grid. Can depend on self.xN and self.yN being set.

In this case, the grid is an array filled with the value False, meaning that the cells are not occupied.

squareColor(self, indices)

 

Default color scheme: squares that the robot can occupy are white and others are black.

Parameters:
  • indices - (ix, iy) indices of a grid cell
Returns:
a color string indicating what color that cell should be drawn in.
Overrides: gridMap.GridMap.squareColor

setCell(self, (xIndex, yIndex))

 

Takes indices for a grid cell, and updates it, given information that it contains an obstacle. In this case, it sets the cell to True, and redraws it if its color has changed.

clearCell(self, (xIndex, yIndex))

 

Takes indices for a grid cell, and updates it, given information that it does not contain an obstacle. In this case, it sets the cell to True, and redraws it if its color has changed.

robotCanOccupy(self, (xIndex, yIndex))

 

Returns True if the robot's center can be at any location within the cell specified by (xIndex, yIndex) and not cause a collision. This implementation is very slow: it considers a range of boxes around the spcified box, and ensures that none of them is self.occupied.

occupied(self, (xIndex, yIndex))

 

Returns True if there is an obstacle in any part of this cell. Note that it can be the case that a cell is not occupied, but the robot cannot occupy it (because if the robot's center were in that cell, some part of the robot would be in collision.