Library to manage the map

This libary implements a discrete map use wich can be use in robotics. More...

Map constaints



#define MAP_CELL_SIZE_MM   50
 Size of a cell in mm.
#define MAP_CELL_SIZE_M   (MAP_CELL_SIZE_MM/1000.0)
 Size of a cell in mm.
#define MAP_WIDTH   (PLAYGROUND_WIDTH_MM / MAP_CELL_SIZE_MM)
 Field width.
#define MAP_HEIGHT   (PLAYGROUND_HEIGHT_MM / MAP_CELL_SIZE_MM)
 Field height.
#define MAP_PLAYGROUND_WIDTH_MM   (MAP_WIDTH*MAP_CELL_SIZE_MM)
 Playground width depends on width and cell size.
#define MAP_PLAYGROUND_WIDTH_M   (MAP_PLAYGROUND_WIDTH_MM/1000.0)
 Size of a cell in mm.
#define MAP_PLAYGROUND_HEIGHT_MM   (MAP_HEIGHT*MAP_CELL_SIZE_MM)
 Playground width depends on height and cell size.
#define MAP_PLAYGROUND_HEIGHT_M   (MAP_PLAYGROUND_HEIGHT_MM/1000.0)
 Size of a cell in mm.

Cell Flags



#define MAP_FLAG_WALL   1
 Known wall.
#define MAP_FLAG_PATH   2
 Known wall.
#define MAP_FLAG_START   4
 Known wall.
#define MAP_FLAG_GOAL   8
 Known wall.
#define MAP_FLAG_DET_OBST   16
 Set when an obstacle is detected, cleard on every "map forget cycle".
#define MAP_FLAG_SIMULATED_WALL   32
 Used by robomon to simulate obstacles.
#define MAP_FLAG_IGNORE_OBST   64
 If obstacle is detected here, ignore it.
#define MAP_FLAG_PLAN_MARGIN   128
 "Safety margin" around obstacle - used only during A* planning and not during runtime obstacle avoidance.
#define MAP_FLAG_INVALIDATE_WALL   256
 Area, where the wall should be forgotten.

Shared Memory macros



#define SHM_MAP_KEY   555
 Key use to share the memory SHM.

Detailed Description

This libary implements a discrete map use wich can be use in robotics.

The features are:

Shared Memory Map

There are two important methods to access the shared map. Before using shmap, it should be init by the function ShmapInit(). After finishing using it the shmap should be clear by ShmapFree().

Warning:
If the program exit without a ShmapFree(), the memory will stay in Linux SHM. You can verify it with command "ipcs -m". For further details, read shm documentation.

The map

The real space

The map size is (MAP_PLAYGROUND_WIDTH_MM x MAP_PLAYGROUND_HEIGHT_MM). This space discretization is explained in section The discrete Map .

                                0                                       MAP_PLAYGROUND_WIDTH_MM
 MAP_PLAYGROUND_HEIGHT_MM       +---------------------------------------+
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                                |                                       |
                           y=0  +---------------------------------------+ 0
                               x=0                                      MAP_PLAYGROUND_WIDTH_MM

The discrete Map

Map library uses a discrete representation of the space. This representation has been implemented as a cell grid (matrix). Each cell (pixel) is represents MAP_CELL_SIZE mm square. We can consider a cell as a set of points. All the points of a cell have the same value that the cell. The origin is located in up left corner.

There are only a coordonates difference between points and cells. Cell which cordonates [0,0] represents all the points contained in a square sited up left corner.

                                X 0   1   2   3   4   5   6   7   8   MAP_WIDTH-1
                              Y +---+---+---+---+---+---+---+---+---+---+
                              0 |0,0|   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                              1 |   |   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                                |   |   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                                |   |   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                                |   |   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                                |   |   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                                |   |   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                                |   |   |   |   |   |   |   |   |   |   |
                                +---+---+---+---+---+---+---+---+---+---+
                                MAP_HEIGHT-1
Note:
Matrix convention is usally (row, column). In this program the convention will be (column, row) in order to keep real coordonates relation. C language stockes matrix in rows, so a cell coordonate (x,y) will be in a C matrix [y][x].

Map Content

Each cell/point of the map (MapCell) contains two types of information:

Map Values

This information is of the type MapCellValue.The value that the map contains can be:

One special type is MAP_NOT_IN_MAP. It is a error code return when we try to acces to a space wich is not in the map. (i.e. the request cell/point exceeds map dimensions.)

Note:
The configuration space is a special obstacle type that depends on the geometry of the robot. For more information, read a book about robotics.

Cell Flags

The possible cell flags are:

One special type is MAP_FLAG_ERROR. It is a error code return when we try to acces to a space wich is not in the map. (i.e. the request cell/point exceeds map dimensions.)

Accessing to map information

FIXME: Obsolete: ShmapGetPointValue(), ShmapSetPointValue(), ShmapSetPointValue(), ShmapSetCellValue() do not exist

To read and write cell values, use functions ShmapGetCellValue() and ShmapSetCellValue(). If you want to acces directly to points, you can also use ShmapGetPointValue() and ShmapSetPointValue().

There are similar functions to get and set flags: ShmapGetCellFlag() and ShmapSetCellFlag(), ShmapGetPointValue() and ShmapSetPointFlag().

It can be possible also to edit more than a point at the same time with function ShmapSetRectangleType().

If you want to know if a cell is free see ShmapIsFreeCell() and ShmapIsFreePoint().

ShmapUpdateTmpObstacles() is a specific function created for Eurobot Project. Please, see an example in testmap.c file


Define Documentation

#define MAP_CELL_SIZE_M   (MAP_CELL_SIZE_MM/1000.0)

Size of a cell in mm.

The cell is a square.

#define MAP_CELL_SIZE_MM   50

Size of a cell in mm.

The cell is a square.

#define MAP_FLAG_DET_OBST   16

Set when an obstacle is detected, cleard on every "map forget cycle".

Examples:
testmap.c.
#define MAP_FLAG_GOAL   8

Known wall.

#define MAP_FLAG_IGNORE_OBST   64

If obstacle is detected here, ignore it.

#define MAP_FLAG_INVALIDATE_WALL   256

Area, where the wall should be forgotten.

#define MAP_FLAG_PATH   2

Known wall.

#define MAP_FLAG_PLAN_MARGIN   128

"Safety margin" around obstacle - used only during A* planning and not during runtime obstacle avoidance.

#define MAP_FLAG_SIMULATED_WALL   32

Used by robomon to simulate obstacles.

#define MAP_FLAG_START   4

Known wall.

#define MAP_FLAG_WALL   1

Known wall.

Examples:
testmap.c.
#define MAP_HEIGHT   (PLAYGROUND_HEIGHT_MM / MAP_CELL_SIZE_MM)

Field height.

#define MAP_PLAYGROUND_HEIGHT_M   (MAP_PLAYGROUND_HEIGHT_MM/1000.0)

Size of a cell in mm.

The cell is a square.

#define MAP_PLAYGROUND_HEIGHT_MM   (MAP_HEIGHT*MAP_CELL_SIZE_MM)

Playground width depends on height and cell size.

#define MAP_PLAYGROUND_WIDTH_M   (MAP_PLAYGROUND_WIDTH_MM/1000.0)

Size of a cell in mm.

The cell is a square.

#define MAP_PLAYGROUND_WIDTH_MM   (MAP_WIDTH*MAP_CELL_SIZE_MM)

Playground width depends on width and cell size.

#define MAP_WIDTH   (PLAYGROUND_WIDTH_MM / MAP_CELL_SIZE_MM)

Field width.

#define SHM_MAP_KEY   555

Key use to share the memory SHM.