#include "map.h"
#include <sys/shm.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <math.h>
Go to the source code of this file.
Defines | |
#define | GETMAPPOS(i, j) (map->cells[j][i].value) |
This is an internal macro, do not use out of map.c. | |
#define | GETFLAG(i, j) (map->cells[j][i].flag) |
This is an internal macro, do not use out of map.c. | |
Functions | |
Shared Memory Map related functions | |
int | ShmapInit (int init_flag) |
void | ShmapFree (void) |
void | ShmapDt (void) |
int | ShmapIsMapInit (void) |
Map manage | |
void | ShmapAllFreeSpace (void) |
void | ShmapClearOldPath (void) |
int | ShmapIsCellInMap (int x, int y) |
Gives information about a cell. | |
int | ShampIsPointInMap (double x_m, double y_m) |
int | ShmapSetCellValue (int x, int y, MapCellValue value) |
Puts the specified cell type in the given map position. | |
int | ShmapSetPointValue (double x_m, double y_m, MapCellValue value) |
void | ShmapUpdateTmpObstacles (MapCellValue val) |
MapCellValue | ShmapGetCellValue (int x, int y) |
MapCellValue | ShmapGetPointValue (double x_m, double y_m) |
int | ShmapIsFreeCell (int x, int y) |
int | ShmapIsFreePoint (double x_m, double y_m) |
int | ShmapSetRectangleType (double x1, double y1, double x2, double y2, MapCellValue cell) |
Coordonates translation | |
int | ShmapPoint2Cell_X (double x) |
int | ShmapPoint2Cell_Y (double y) |
double | ShmapCell2Point_X (int x) |
double | ShmapCell2Point_Y (int y) |
Functions to manage the flags | |
int | ShmapSetCellFlag (int x, int y, MapCellFlag flag) |
int | ShmapSetPointFlag (double x_m, double y_m, MapCellFlag flag) |
MapCellFlag | ShmapGetCellFlag (int x, int y) |
MapCellFlag | ShmapGetPointFlag (double x_m, double y_m) |
Variables | |
static Map * | map = NULL |
int | shmap_id |
Definition in file map.c.
int ShampIsPointInMap | ( | double | x_m, | |
double | y_m | |||
) |
Give information about if a point is in map
x_m | Coordonate X (in m) of a point | |
y_m | Coordonate Y (in m) of a point |
Definition at line 146 of file map.c.
References ShmapIsCellInMap(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().
void ShmapAllFreeSpace | ( | void | ) |
Initialize Map Memory with MAP_FREE value and MAP_FLAG_NO_FLAG flag.
Definition at line 105 of file map.c.
References MAP_FREE, MAP_HEIGHT, MAP_WIDTH, ShmapSetCellFlag(), and ShmapSetCellValue().
double ShmapCell2Point_X | ( | int | x | ) |
Translates from cell X coordonate to real coordonate.
x | Coodonte X of a cell. |
Definition at line 332 of file map.c.
References MAP_WIDTH.
Referenced by aAlgorithm().
double ShmapCell2Point_Y | ( | int | y | ) |
Translates from cell Y coordonate to real coordonate.
y | Coodonte Y of a cell. |
Definition at line 343 of file map.c.
References MAP_HEIGHT.
Referenced by aAlgorithm().
void ShmapClearOldPath | ( | void | ) |
Clear old path in the map.
Definition at line 119 of file map.c.
References MAP_FREE, MAP_HEIGHT, MAP_WIDTH, ShmapIsFreeCell(), and ShmapSetCellValue().
Referenced by path_planner().
void ShmapFree | ( | void | ) |
MapCellFlag ShmapGetCellFlag | ( | int | x, | |
int | y | |||
) |
Get cell flag
x | Coordonate X of a cell | |
y | Coordonate Y of a cell |
Definition at line 385 of file map.c.
References GETFLAG, and ShmapIsCellInMap().
Referenced by ShmapGetPointFlag().
MapCellValue ShmapGetCellValue | ( | int | x, | |
int | y | |||
) |
Give information about a cell
x | Coordonate of a cell | |
y | Coordonate of a cell |
Definition at line 210 of file map.c.
References GETMAPPOS, ShmapIsCellInMap(), and ShmapIsMapInit().
Referenced by ShmapGetPointValue(), ShmapIsFreeCell(), ShmapUpdateTmpObstacles(), and trajctory_recalc().
MapCellFlag ShmapGetPointFlag | ( | double | x_m, | |
double | y_m | |||
) |
Get point flag
x_m | Coordonate X (in m) of a point | |
y_m | Coordonate Y (in m) of a point |
Definition at line 395 of file map.c.
References ShmapGetCellFlag(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().
MapCellValue ShmapGetPointValue | ( | double | x_m, | |
double | y_m | |||
) |
Get point value
x_m | Coordonate X (in m) of a point | |
y_m | Coordonate Y (in m) of a point |
Definition at line 222 of file map.c.
References ShmapGetCellValue(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().
int ShmapInit | ( | int | init_flag | ) |
Init Shared Map memory
init_flag | 1 to init with MAP_FREE value |
Definition at line 39 of file map.c.
References SHM_MAP_KEY, shmap_id, and ShmapAllFreeSpace().
Referenced by robomon::obstackleSimulation().
int ShmapIsCellInMap | ( | int | x, | |
int | y | |||
) |
Gives information about a cell.
x | Coordonate of a cell | |
y | Coordonate of a cell |
Definition at line 136 of file map.c.
References MAP_HEIGHT, and MAP_WIDTH.
Referenced by aAlgorithm(), calculateMapHeuristic(), ShampIsPointInMap(), ShmapGetCellFlag(), ShmapGetCellValue(), ShmapIsFreeCell(), ShmapSetCellFlag(), and ShmapSetCellValue().
int ShmapIsFreeCell | ( | int | x, | |
int | y | |||
) |
Give information about if a cell is free.
x | Coordonate of a cell | |
y | Coordonate of a cell |
Definition at line 233 of file map.c.
References MAP_FREE, MAP_GOAL, MAP_PATH, MAP_START, ShmapGetCellValue(), and ShmapIsCellInMap().
Referenced by aAlgorithm(), cFunction(), ShmapClearOldPath(), and ShmapIsFreePoint().
int ShmapIsFreePoint | ( | double | x_m, | |
double | y_m | |||
) |
Give information about if a point is free.
x_m | Coordonate X (in m) of a point | |
y_m | Coordonate Y (in m) of a point |
Definition at line 255 of file map.c.
References ShmapIsFreeCell(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().
Referenced by path_planner(), and trajctory_recalc().
int ShmapIsMapInit | ( | void | ) |
Check if Shared Map memory is init
Definition at line 89 of file map.c.
Referenced by path_planner(), ShmapGetCellValue(), and ShmapUpdateTmpObstacles().
int ShmapPoint2Cell_X | ( | double | x | ) |
Translates from real X coordonate (in meters) to grid cell coordonates
x | Coodonte of X |
Definition at line 305 of file map.c.
Referenced by aAlgorithm(), ShampIsPointInMap(), ShmapGetPointFlag(), ShmapGetPointValue(), ShmapIsFreePoint(), ShmapSetPointFlag(), ShmapSetPointValue(), ShmapSetRectangleType(), and trajctory_recalc().
int ShmapPoint2Cell_Y | ( | double | y | ) |
Translates from real y (in meters) coordonate to grid cell coordonates
y | Coodonte of Y in m |
Definition at line 319 of file map.c.
References MAP_HEIGHT.
Referenced by aAlgorithm(), ShampIsPointInMap(), ShmapGetPointFlag(), ShmapGetPointValue(), ShmapIsFreePoint(), ShmapSetPointFlag(), ShmapSetPointValue(), ShmapSetRectangleType(), and trajctory_recalc().
int ShmapSetCellFlag | ( | int | x, | |
int | y, | |||
MapCellFlag | flag | |||
) |
Set cell flag
x | Coordonate X of a cell | |
y | Coordonate Y of a cell | |
flag | Flag setting |
Definition at line 361 of file map.c.
References GETFLAG, and ShmapIsCellInMap().
Referenced by ShmapAllFreeSpace(), and ShmapSetPointFlag().
int ShmapSetCellValue | ( | int | x, | |
int | y, | |||
MapCellValue | value | |||
) |
Puts the specified cell type in the given map position.
x | Coordonate of a cell | |
y | Coordonate of a cell | |
type | Type of cell |
Definition at line 159 of file map.c.
References GETMAPPOS, and ShmapIsCellInMap().
Referenced by getPathLength(), ShmapAllFreeSpace(), ShmapClearOldPath(), ShmapSetPointValue(), ShmapSetRectangleType(), ShmapUpdateTmpObstacles(), and trajctory_recalc().
int ShmapSetPointFlag | ( | double | x_m, | |
double | y_m, | |||
MapCellFlag | flag | |||
) |
Set point flag
x_m | Coordonate X (in m) of a point | |
y_m | Coordonate Y (in m) of a point | |
flag | The flag to set |
Definition at line 375 of file map.c.
References ShmapPoint2Cell_X(), ShmapPoint2Cell_Y(), and ShmapSetCellFlag().
int ShmapSetPointValue | ( | double | x_m, | |
double | y_m, | |||
MapCellValue | value | |||
) |
Put a type in a point
x_m | Coordonate X (in m) of a point | |
y_m | Coordonate Y (in m) of a point |
Definition at line 172 of file map.c.
References ShmapPoint2Cell_X(), ShmapPoint2Cell_Y(), and ShmapSetCellValue().
int ShmapSetRectangleType | ( | double | x1, | |
double | y1, | |||
double | x2, | |||
double | y2, | |||
MapCellValue | cell | |||
) |
Creates an obstacle in the map
x1 | Coordonate X (in m) of the first point | |
y1 | Coordonate Y (in m) of the first point | |
x2 | Coordonate X (in m) of the second point | |
y2 | Coordonate Y (in m) of the second point | |
cell | Type of obstacle. |
Definition at line 268 of file map.c.
References ShmapPoint2Cell_X(), ShmapPoint2Cell_Y(), and ShmapSetCellValue().
void ShmapUpdateTmpObstacles | ( | MapCellValue | val | ) |
Decrease MAP_NEW_OBSTACLE cells in val units
val | Value to decrease obstacle life. |
Go across the map.
Get cell value.
If the cell value is between MAP_NEW_OBSTACLE and MAP_FREE
decreases cell value in val units.
Definition at line 182 of file map.c.
References MAP_FREE, MAP_HEIGHT, MAP_NEW_OBSTACLE, MAP_WIDTH, ShmapGetCellValue(), ShmapIsMapInit(), and ShmapSetCellValue().
Referenced by thread_update_map().