map.c File Reference

#include "map.h"
#include <sys/shm.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <math.h>

Include dependency graph for map.c:

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 Mapmap = NULL
int shmap_id


Detailed Description

Useful functions related map
Author:
Jose Maria Martin Laguna <jmmartin@etud.insa-toulouse.fr> This file contains functions to manage map. The map should be accessed only by this library.
Todo:
Lock the map! if while we are doing something in the map, somewhere the function ShmapFree() is called, segfault occurs.

Definition in file map.c.


Function Documentation

int ShampIsPointInMap ( double  x_m,
double  y_m 
)

Give information about if a point is in map

Parameters:
x_m Coordonate X (in m) of a point
y_m Coordonate Y (in m) of a point
Returns:
1 if point is in map, 0 otherwise

Definition at line 146 of file map.c.

References ShmapIsCellInMap(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().

Here is the call graph for this function:

void ShmapAllFreeSpace ( void   ) 

Initialize Map Memory with MAP_FREE value and MAP_FLAG_NO_FLAG flag.

See also:
map MAP_FREE

Definition at line 105 of file map.c.

References MAP_FREE, MAP_HEIGHT, MAP_WIDTH, ShmapSetCellFlag(), and ShmapSetCellValue().

Here is the call graph for this function:

double ShmapCell2Point_X ( int  x  ) 

Translates from cell X coordonate to real coordonate.

Parameters:
x Coodonte X of a cell.
Returns:
X value in real coordonate, -1 if the coordonate is not in map

Definition at line 332 of file map.c.

References MAP_WIDTH.

Referenced by aAlgorithm().

Here is the caller graph for this function:

double ShmapCell2Point_Y ( int  y  ) 

Translates from cell Y coordonate to real coordonate.

Parameters:
y Coodonte Y of a cell.
Returns:
Y value in real coordonate, -1 if the coordonate is not in map

Definition at line 343 of file map.c.

References MAP_HEIGHT.

Referenced by aAlgorithm().

Here is the caller graph for this function:

void ShmapClearOldPath ( void   ) 

Clear old path in the map.

See also:
map MAP_FREE

Definition at line 119 of file map.c.

References MAP_FREE, MAP_HEIGHT, MAP_WIDTH, ShmapIsFreeCell(), and ShmapSetCellValue().

Referenced by path_planner().

Here is the call graph for this function:

Here is the caller graph for this function:

void ShmapDt ( void   ) 

Deatach Shared Map memory

Definition at line 80 of file map.c.

void ShmapFree ( void   ) 

Free Shared Map memory

Definition at line 69 of file map.c.

References shmap_id.

MapCellFlag ShmapGetCellFlag ( int  x,
int  y 
)

Get cell flag

Parameters:
x Coordonate X of a cell
y Coordonate Y of a cell
Returns:
the flag of the cell

Definition at line 385 of file map.c.

References GETFLAG, and ShmapIsCellInMap().

Referenced by ShmapGetPointFlag().

Here is the call graph for this function:

Here is the caller graph for this function:

MapCellValue ShmapGetCellValue ( int  x,
int  y 
)

Give information about a cell

Parameters:
x Coordonate of a cell
y Coordonate of a cell
Returns:
The value of the cell

Definition at line 210 of file map.c.

References GETMAPPOS, ShmapIsCellInMap(), and ShmapIsMapInit().

Referenced by ShmapGetPointValue(), ShmapIsFreeCell(), ShmapUpdateTmpObstacles(), and trajctory_recalc().

Here is the call graph for this function:

Here is the caller graph for this function:

MapCellFlag ShmapGetPointFlag ( double  x_m,
double  y_m 
)

Get point flag

Parameters:
x_m Coordonate X (in m) of a point
y_m Coordonate Y (in m) of a point
Returns:
the flag of the point

Definition at line 395 of file map.c.

References ShmapGetCellFlag(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().

Here is the call graph for this function:

MapCellValue ShmapGetPointValue ( double  x_m,
double  y_m 
)

Get point value

Parameters:
x_m Coordonate X (in m) of a point
y_m Coordonate Y (in m) of a point
Returns:
the value of point

Definition at line 222 of file map.c.

References ShmapGetCellValue(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().

Here is the call graph for this function:

int ShmapInit ( int  init_flag  ) 

Init Shared Map memory

Parameters:
init_flag 1 to init with MAP_FREE value
Returns:
1 This function allocates memory for shared map if this memory does not exists.

Definition at line 39 of file map.c.

References SHM_MAP_KEY, shmap_id, and ShmapAllFreeSpace().

Referenced by robomon::obstackleSimulation().

Here is the call graph for this function:

int ShmapIsCellInMap ( int  x,
int  y 
)

Gives information about a cell.

Parameters:
x Coordonate of a cell
y Coordonate of a cell
Returns:
1 if cell is in map, 0 otherwise

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().

Here is the caller graph for this function:

int ShmapIsFreeCell ( int  x,
int  y 
)

Give information about if a cell is free.

Parameters:
x Coordonate of a cell
y Coordonate of a cell
Returns:
1 if the cell is not an obstacle, -1 if the cell is not in the map, 0 otherwise Following cells are consider as free cells: MAP_START, MAP_GOAL, MAP_PATH, MAP_FREE.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

int ShmapIsFreePoint ( double  x_m,
double  y_m 
)

Give information about if a point is free.

Parameters:
x_m Coordonate X (in m) of a point
y_m Coordonate Y (in m) of a point
Returns:
1 if the cell is not an obstacle, -1 if the cell is not in the map, 0 otherwise Following points are consider as free points: MAP_START, MAP_GOAL, MAP_PATH, MAP_FREE.

Definition at line 255 of file map.c.

References ShmapIsFreeCell(), ShmapPoint2Cell_X(), and ShmapPoint2Cell_Y().

Referenced by path_planner(), and trajctory_recalc().

Here is the call graph for this function:

Here is the caller graph for this function:

int ShmapIsMapInit ( void   ) 

Check if Shared Map memory is init

Returns:
1 if it is, 0 otherwise

Definition at line 89 of file map.c.

Referenced by path_planner(), ShmapGetCellValue(), and ShmapUpdateTmpObstacles().

Here is the caller graph for this function:

int ShmapPoint2Cell_X ( double  x  ) 

Translates from real X coordonate (in meters) to grid cell coordonates

Parameters:
x Coodonte of X
Returns:
X value in cell position, -1 if the coordonate is not in map

Definition at line 305 of file map.c.

Referenced by aAlgorithm(), ShampIsPointInMap(), ShmapGetPointFlag(), ShmapGetPointValue(), ShmapIsFreePoint(), ShmapSetPointFlag(), ShmapSetPointValue(), ShmapSetRectangleType(), and trajctory_recalc().

Here is the caller graph for this function:

int ShmapPoint2Cell_Y ( double  y  ) 

Translates from real y (in meters) coordonate to grid cell coordonates

Parameters:
y Coodonte of Y in m
Returns:
Y value in cell position, -1 if the coordonate is not in map

Definition at line 319 of file map.c.

References MAP_HEIGHT.

Referenced by aAlgorithm(), ShampIsPointInMap(), ShmapGetPointFlag(), ShmapGetPointValue(), ShmapIsFreePoint(), ShmapSetPointFlag(), ShmapSetPointValue(), ShmapSetRectangleType(), and trajctory_recalc().

Here is the caller graph for this function:

int ShmapSetCellFlag ( int  x,
int  y,
MapCellFlag  flag 
)

Set cell flag

Parameters:
x Coordonate X of a cell
y Coordonate Y of a cell
flag Flag setting
Returns:
1 on succes, 0 otherwise

Definition at line 361 of file map.c.

References GETFLAG, and ShmapIsCellInMap().

Referenced by ShmapAllFreeSpace(), and ShmapSetPointFlag().

Here is the call graph for this function:

Here is the caller graph for this function:

int ShmapSetCellValue ( int  x,
int  y,
MapCellValue  value 
)

Puts the specified cell type in the given map position.

Parameters:
x Coordonate of a cell
y Coordonate of a cell
type Type of cell
Returns:
1 if cell is in map, 0 otherwise

Definition at line 159 of file map.c.

References GETMAPPOS, and ShmapIsCellInMap().

Referenced by getPathLength(), ShmapAllFreeSpace(), ShmapClearOldPath(), ShmapSetPointValue(), ShmapSetRectangleType(), ShmapUpdateTmpObstacles(), and trajctory_recalc().

Here is the call graph for this function:

Here is the caller graph for this function:

int ShmapSetPointFlag ( double  x_m,
double  y_m,
MapCellFlag  flag 
)

Set point flag

Parameters:
x_m Coordonate X (in m) of a point
y_m Coordonate Y (in m) of a point
flag The flag to set
Returns:
1 on succes, 0 otherwise

Definition at line 375 of file map.c.

References ShmapPoint2Cell_X(), ShmapPoint2Cell_Y(), and ShmapSetCellFlag().

Here is the call graph for this function:

int ShmapSetPointValue ( double  x_m,
double  y_m,
MapCellValue  value 
)

Put a type in a point

Parameters:
x_m Coordonate X (in m) of a point
y_m Coordonate Y (in m) of a point
Returns:
the type of point

Definition at line 172 of file map.c.

References ShmapPoint2Cell_X(), ShmapPoint2Cell_Y(), and ShmapSetCellValue().

Here is the call graph for this function:

int ShmapSetRectangleType ( double  x1,
double  y1,
double  x2,
double  y2,
MapCellValue  cell 
)

Creates an obstacle in the map

Parameters:
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().

Here is the call graph for this function:

void ShmapUpdateTmpObstacles ( MapCellValue  val  ) 

Decrease MAP_NEW_OBSTACLE cells in val units

Parameters:
val Value to decrease obstacle life.
See also:
map MAP_NEW_OBSTACLE
Todo:
Do faster this process. Use a cell's list to update.

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().

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Thu Sep 13 11:28:29 2007 for DCE-Eurobot by  doxygen 1.5.3