Variables

map.c File Reference

Useful functions related map. More...

#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:

Functions

Shared Memory Map related functions

struct map * ShmapInit (int init_flag)
 Init Shared Map memory.
void ShmapFree (void)
 Free Shared Map memory.
void ShmapDt (void)
 Deatach Shared Map memory.
struct map * ShmapIsMapInit (void)
 Check if Shared Map memory is init.
Coordonates translation

void ShmapPoint2Cell (double x, double y, int *ix, int *iy, bool *valid)
 Translates real point coordinates (in meters) to cell grid coordinates.
int ShmapCell2Point (int ix, int iy, double *x, double *y)
 Translates from cell grid coordinates to real coordinates.

Variables

struct map * map = NULL
int shmap_id

Map manage



struct map_cell ShmapNoCell
 See ShmapCellAtPoint().
void ShmapAllFreeSpace (void)
 Initialize Map Memory with MAP_FREE value and MAP_FLAG_NO_FLAG flag.
struct map_cell * ShmapCellAtPoint (double x_m, double y_m)
 Put a value in a point.
int ShmapIsFreeCell (int x, int y)
 Give information about if a cell is free.
int ShmapIsFreePoint (double x_m, double y_m)
 See ShmapCellAtPoint().
int ShmapSetCircleFlag (double xs, double ys, double r, map_cell_flag_t set_flags, map_cell_flag_t clear_flags)
 Creates an obstacle in the map with a square shape.
int ShmapSetRectangleFlag (double x1, double y1, double x2, double y2, map_cell_flag_t set_flags, map_cell_flag_t clear_flags)
 Creates an obstacle in the map.

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! It necessary in multi-thread programs. If while we are doing something in the map, somewhere the function ShmapFree() is called, segfault occurs.

Function Documentation

void ShmapAllFreeSpace ( void   ) 

Initialize Map Memory with MAP_FREE value and MAP_FLAG_NO_FLAG flag.

See also:
map MAP_FREE

Here is the caller graph for this function:

int ShmapCell2Point ( int  ix,
int  iy,
double *  x,
double *  y 
)

Translates from cell grid coordinates to real coordinates.

Coordinates set to x and *y are coordinates of the center of given cell.

Parameters:
ix given x index of grid cell
iy given y index of grid cell
*x is set to real x coordinate corresponding to given ix
*y is set to real y coordinate corresponding to given iy
Returns:
0 if and only if given grid indices fall into playground, otherwise returns -1

Here is the caller graph for this function:

struct map_cell* ShmapCellAtPoint ( double  x_m,
double  y_m 
) [read]

Put a value in a point.

Parameters:
x_m Coordonate X (in m) of a point
y_m Coordonate Y (in m) of a point
value Value of the point
Returns:
Pointer to the cell. If coordinates are outside of the map, pointer to ShmapNoCell is returned.

Here is the call graph for this function:

void ShmapDt ( void   ) 

Deatach Shared Map memory.

void ShmapFree ( void   ) 

Free Shared Map memory.

Examples:
testmap.c.

Here is the caller graph for this function:

struct map* ShmapInit ( int  init_flag  )  [read]

Init Shared Map memory.

Parameters:
init_flag 1 to init the map memory and set all cells with MAP_FREE and MAP_FLAG_NO_FLAG, 0 only init map
Returns:
Pointer to the map. In case of error, exit() is called.

This function allocates memory for shared map if this memory does not exists.

Examples:
testmap.c.

Here is the call graph for this function:

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.

Here is the caller graph for this function:

int ShmapIsFreePoint ( double  x_m,
double  y_m 
)

See ShmapCellAtPoint().

Here is the call graph for this function:

Here is the caller graph for this function:

struct map* ShmapIsMapInit ( void   )  [read]

Check if Shared Map memory is init.

Returns:
Pointer to the map or NULL if not initialized.

Here is the caller graph for this function:

void ShmapPoint2Cell ( double  x,
double  y,
int *  ix,
int *  iy,
bool *  valid 
)

Translates real point coordinates (in meters) to cell grid coordinates.

Parameters:
x given x coordinate [meters]
y given y coordinate [meters]
*ix referenced int is set to grid index corresponding to x
*iy referenced int is set to grid index corresponding to y
*valid referenced bool is set to true if and only if position given by (x,y) falls into playground

Here is the caller graph for this function:

int ShmapSetCircleFlag ( double  xs,
double  ys,
double  r,
map_cell_flag_t  set_flags,
map_cell_flag_t  clear_flags 
)

Creates an obstacle in the map with a square shape.

Parameters:
xs Coordonate X (in m) of the central point
ys Coordonate Y (in m) of the central point
r Radius (in m)
cell Type of obstacle.

Here is the call graph for this function:

Here is the caller graph for this function:

int ShmapSetRectangleFlag ( double  x1,
double  y1,
double  x2,
double  y2,
map_cell_flag_t  set_flags,
map_cell_flag_t  clear_flags 
)

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.
Examples:
testmap.c.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct map* map = NULL
int shmap_id