00001 #ifndef __MAP_H
00002 #define __MAP_H
00003
00109 #define MAP_WIDTH 30
00110 #define MAP_HEIGHT 21
00111 #define MAP_CELL_SIZE 100
00112 #define MAP_PLAYGROUND_WIDTH_MM (MAP_WIDTH*MAP_CELL_SIZE)
00113 #define MAP_PLAYGROUND_HEIGHT_MM (MAP_HEIGHT*MAP_CELL_SIZE)
00121 #define MAP_NOT_IN_MAP 255
00122 #define MAP_WALL 254
00123 #define MAP_WALL_CSPACE 253
00124 #define MAP_PATH 252
00125 #define MAP_START 251
00126 #define MAP_GOAL 250
00127 #define MAP_NEW_OBSTACLE 249
00128 #define MAP_NEW_OBSTACLE_CSPACE 248
00129 #define MAP_FREE 0x00
00136 #define MAP_FLAG_NO_FLAG 0
00137 #define MAP_FLAG_WALL 1
00138 #define MAP_FLAG_PATH 2
00139 #define MAP_FLAG_START 4
00140 #define MAP_FLAG_GOAL 8
00141 #define MAP_FLAG_ERROR 255
00142
00145 #define SHM_MAP_KEY 555
00146 // Some macros useful to convert from Graph coordonates to robot field
00147 #define GRAPHX2FIELD(x) ((x+0.5)/10.0)
00148 #define GRAPHY2FIELD(y) ((abs(y-MAP_HEIGHT)-0.5)/10.0)
00153 #ifdef __cplusplus
00154 extern "C" {
00155 #endif
00156 typedef unsigned char MapCellValue;
00157 typedef unsigned char MapCellFlag;
00158
00159 typedef struct MapCell {
00160 MapCellFlag flag;
00161 MapCellValue value;
00162 } MapCell;
00163
00164
00165 typedef struct _Map {
00166 MapCell cells[MAP_HEIGHT][MAP_WIDTH];
00167
00168 } Map;
00170 void ShmapClearOldPath(void);
00171 void ShmapAllFreeSpace(void);
00172 int ShmapInit(int init_flag);
00173 void ShmapFree(void);
00174 void ShmapDt(void);
00175 int ShmapIsMapInit(void);
00176
00177 int ShmapPoint2Cell_X(double x);
00178 int ShmapPoint2Cell_Y(double y);
00179
00180 double ShmapCell2Point_X(int x);
00181 double ShmapCell2Point_Y(int y);
00182
00183
00184 int ShmapSetCellValue(int x, int y, MapCellValue value);
00185 int ShmapSetPointValue(double x_m, double y_m, MapCellValue value);
00186
00187 MapCellValue ShmapGetCellValue(int x, int y);
00188 MapCellValue ShmapGetPointValue(double x_m, double y_m);
00189
00190 int ShmapSetCellFlag(int x, int y, MapCellFlag value);
00191 int ShmapSetPointFlag(double x_m, double y_m, MapCellFlag value);
00192
00193 MapCellFlag ShmapGetCellFlag(int x, int y);
00194 MapCellFlag ShmapGetPointFlag(double x_m, double y_m);
00195
00196 int ShmapIsCellInMap(int x, int y);
00197 int ShampIsPointInMap(double x_m, double y_m);
00198
00199 void ShmapUpdateTmpObstacles(unsigned char val);
00200
00201 int ShmapIsFreeCell(int x, int y);
00202 int ShmapIsFreePoint(double x_m, double y_m);
00203
00204 int ShmapSetRectangleType(double x1, double y1, double x2, double y2, MapCellValue cell);
00205
00206 #ifdef __cplusplus
00207 }
00208 #endif
00209
00210 #endif //__MAP_H_
00211