Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

grid Class Reference

A class to solve a basic maze using the flood fill algorithm. More...

#include <grid.h>


Public Member Functions

 grid (void)
 Default constructor.

 grid (int x, int y)
 Constructor specifying size of maze.

CELL_STATE state (int x, int y) const
CELL_STATE heading (int x, int y, atomic_rotation) const
void solve_maze (int cx, int cy, atomic_rotation face, const pose_chain &waypoints, int itarget, motion_chain &path, bool obstacles)
 Solves maze starting from point cx,cy heading direction "face".

void wall (int x, int y, CELL_STATE ctype)
 Fills specified coordinate with specified cell state. (blocked open, etc.).

int height (void) const
 Returns height of maze.

int width (void) const
 Returns width of maze.

void save_rom_map (long ROM_ADDRESS) const
 Save internal map to ROM (or battery backed RAM).

void load_rom_map (long ROM_ADDRESS)
 Load internally stored map from ROM/RAM.

bool obstacles (void)
 Returns whether obstacles are present or not.

void branches (short)
 Sets how many branches from each map cell.


Private Member Functions

CELL_TYPE value (int x, int y) const
void whipitgood (motion_chain &path)
void generate_bellman_matrix (void)
void update_frontiers (int, int, atomic_rotation)
void process_frontiers (int, int)
bool unique_frontier (int, int)
void traverse_back2goal (motion_chain &path)
bool check_heading (atomic_rotation AR, int x, int y, int &imin)
void init (void)
void reinit (void)

Private Attributes

pose_chain _frontiers
pose_chain _visited
maze_cell _maze [22][22]
int _starting_x
int _starting_y
int _starting_face
int _destination_x
int _destination_y
atomic_rotation _destination_face
atomic_rotation _new_face
int _new_x
int _new_y
int _size_x
int _size_y
bool _done
bool _obstacles
short BRANCHES


Detailed Description

A class to solve a basic maze using the flood fill algorithm.

Warning:
Maze initialization is very particular to the application; thus, the maze is initialized to all open. be sure to initialize the maze with walls; otherwise, the robot will try to leave the defined grid. Example:
Ref. OGrid for new A* implementation. This grid is no longer supported and will be probably be replaced with the A* with heuristic set to 0 to generate a floodfill.

  void init_maze()
{
  for (int j=0; j<maze.height(); j++)
  {
    for (int i=0; i<maze.width(); i++)
    {
      // this is general micro mouse initialization (just walls around side.)
      if (i == (maze.width()-1)) maze.wall(i,j,WALL);
      if (i == 0) maze.wall(i,j,WALL);
      if (j == 0) maze.wall(i,j,WALL);
      if (j == (maze.height()-1)) maze.wall(i,j,WALL);
    }
  }
}


Constructor & Destructor Documentation

grid void   ) 
 

Default constructor.

grid int  x,
int  y
 

Constructor specifying size of maze.


Member Function Documentation

void branches short   ) 
 

Sets how many branches from each map cell.

bool check_heading atomic_rotation  AR,
int  x,
int  y,
int &  imin
[private]
 

void generate_bellman_matrix void   )  [private]
 

CELL_STATE heading int  x,
int  y,
atomic_rotation 
const
 

int height void   )  const
 

Returns height of maze.

void init void   )  [private]
 

void load_rom_map long  ROM_ADDRESS  ) 
 

Load internally stored map from ROM/RAM.

bool obstacles void   ) 
 

Returns whether obstacles are present or not.

void process_frontiers int  ,
int 
[private]
 

void reinit void   )  [private]
 

void save_rom_map long  ROM_ADDRESS  )  const
 

Save internal map to ROM (or battery backed RAM).

void solve_maze int  cx,
int  cy,
atomic_rotation  face,
const pose_chain waypoints,
int  itarget,
motion_chain path,
bool  obstacles
 

Solves maze starting from point cx,cy heading direction "face".

Parameters:
cx : starting X coordinate
cy : starting Y coordinate
face : starting orientation
waypoints : list of waypoints to go to.
itarget : starts solving from waypoint number specified by itarget.
path : output commands to be executed by a mobilerobot to follow solution path.
obstacles: whether to solve as maze or as a open space where it simply goes from waypoint to waypoint.

CELL_STATE state int  x,
int  y
const
 

Returns state of given cell. Returns state of cell from point x,y and heading in direction specified with atomic_rotation.

void traverse_back2goal motion_chain path  )  [private]
 

bool unique_frontier int  ,
int 
[private]
 

void update_frontiers int  ,
int  ,
atomic_rotation 
[private]
 

CELL_TYPE value int  x,
int  y
const [private]
 

void wall int  x,
int  y,
CELL_STATE  ctype
 

Fills specified coordinate with specified cell state. (blocked open, etc.).

void whipitgood motion_chain path  )  [private]
 

int width void   )  const
 

Returns width of maze.


Field Documentation

atomic_rotation _destination_face [private]
 

int _destination_x [private]
 

int _destination_y [private]
 

bool _done [private]
 

pose_chain _frontiers [private]
 

maze_cell _maze[22][22] [private]
 

atomic_rotation _new_face [private]
 

int _new_x [private]
 

int _new_y [private]
 

bool _obstacles [private]
 

int _size_x [private]
 

int _size_y [private]
 

int _starting_face [private]
 

int _starting_x [private]
 

int _starting_y [private]
 

pose_chain _visited [private]
 

short BRANCHES [private]
 


Generated on Mon Oct 8 19:32:24 2007 for OOMRM Mapping API by doxygen1.3