Path Planner

path_planner() is the main funtion of the library. More...
#define MAP_WIDTH   30
#define MAP_HEIGHT   21
#define WALL_COST   1000
#define MAP_WALL   0xFF
#define MAP_PATH   0xFE
#define MAP_START   0xFD
#define MAP_GOAL   0xFC
#define MAP_NEW_OBSTACLE   0xFB
#define MAP_FREE   0x00
#define SHM_MAP_KEY   555
#define GETMAPPOS(i, j)   (*(map+i+j*MAP_WIDTH))
#define GRAPHX2FIELD(x)   ((x+0.5)/10.0)
#define GRAPHY2FIELD(y)   ((abs(y-MAP_HEIGHT)-0.5)/10.0)
typedef unsigned char map_t
#define MAP_WIDTH   30
#define MAP_HEIGHT   21
#define WALL_COST   1000
#define MAP_WALL   0xFF
#define MAP_PATH   0xFE
#define MAP_START   0xFD
#define MAP_GOAL   0xFC
#define MAP_NEW_OBSTACLE   0xFB
#define MAP_FREE   0x00
#define SHM_MAP_KEY   555
#define GETMAPPOS(i, j)   (*(map+i+j*MAP_WIDTH))
#define GRAPHX2FIELD(x)   ((x+0.5)/10.0)
#define GRAPHY2FIELD(y)   ((abs(y-MAP_HEIGHT)-0.5)/10.0)
typedef unsigned char map_t
struct mapmap
#define DBG   printf

Path Planner Error Codes

#define PP_ERROR_MAP_NOT_INIT   -1
#define PP_ERROR_GOAL_IS_OBSTACLE   -2
#define PP_ERROR_GOAL_NOT_REACHABLE   -3

Functions

int path_planner (double xstart_real, double ystart_real, double xgoal_real, double ygoal_real, PathPoint **simple_path, double *angle)
void freePathMemory (PathPoint *simple_path)

Detailed Description

path_planner() is the main funtion of the library.

For working it needs refmaplibmaplibrary@endlink.Itreturnsthenumberofpointsofthepathonsuccessoranerrorcode.Theresultofthealgorithmisstockedinalistof::PathPointfinishedwithNULLcontainingthepointsofthepath.Adoublepointertothepathmustbepassedasargument.Afterusethepath,memoryshouldbefreewithfreePathMemory().Apointerofthefinalanglemustbealsopassedasargument.ThemapmemorymustbeinitwithShmapInit()beforecallingpath_planner().DonotforgettofreethismapmemorywithShmapFree(),afterusethepath,freePathMemory()..Isnotnecessarytouseotherfunctionsofthelibrary.Howeverifyouareinterested,pleaseread@refppi@sectionpp_algorithmsTheinternalalgorithmsTheprogramuseanimplementationofA*algorithm,aalgorithm()andsimplifiesitbypath_simplifier().@sectionpp_exampleAnexempleofusingthisfunction:@codeintmain()PathPoint*path;//ApointertothepathPathPoint*tmp;//Atmppointerdoubleangle;//Theangleofthefinallinedoublestartx,starty,goalx,goaly;ShmapInit();//Initsharedmapmemory//Startandgoalpointsofthepathstartx=1.1;stary=1.1;goalx=2.2;goaly=2.0;//Calcthepathif(path_planner(startx, starty, goalx, goaly, &path, &angle))printf("Path ok!\n");elseprintf("The planner can not reach the goal\n");return0;//Printthepointsofthetrajectorytmp=path;printf("The points of the trajectory are: ");while(tmp!=NULL)printf("(%f, %f)",tmp->x,tmp->y);tmp=tmp->next;printf("\n");printf("The final angle is : %f\n", angle);//MemorydeallocationfreePathMemory(path);//Donotforgettofreethepathmemoryafteruse.ShmapFree();//FreeSharedMapMemoryreturn0;@endcode


Define Documentation

#define GETMAPPOS ( i,
 )     (*(map+i+j*MAP_WIDTH))

Field width

Definition at line 24 of file map_definitions.h.

#define GETMAPPOS ( i,
 )     (*(map+i+j*MAP_WIDTH))

Field width

Definition at line 24 of file map_definitions.h.

Referenced by ShmapGetCellValue(), and ShmapSetCellValue().

#define GRAPHX2FIELD (  )     ((x+0.5)/10.0)

Convert from cell coordonates X to real coordonates. Use better cell2real_X().

Definition at line 27 of file map_definitions.h.

#define GRAPHX2FIELD (  )     ((x+0.5)/10.0)

Convert from cell coordonates X to real coordonates. Use better cell2real_X().

Definition at line 27 of file map_definitions.h.

#define GRAPHY2FIELD (  )     ((abs(y-MAP_HEIGHT)-0.5)/10.0)

Convert from cell coordonates Y to real coordonates. Use better cell2real_Y().

Definition at line 28 of file map_definitions.h.

#define GRAPHY2FIELD (  )     ((abs(y-MAP_HEIGHT)-0.5)/10.0)

Convert from cell coordonates Y to real coordonates. Use better cell2real_Y().

Definition at line 28 of file map_definitions.h.

#define MAP_FREE   0x00

Free cell. The robot can move on. White in robomon.

Definition at line 19 of file map_definitions.h.

#define MAP_FREE   0x00

Free cell. The robot can move on. White in robomon.

Definition at line 19 of file map_definitions.h.

Referenced by robomon::paintMap(), ShmapAllFreeSpace(), ShmapClearOldPath(), ShmapIsFreeCell(), ShmapUpdateTmpObstacles(), and trajctory_recalc().

#define MAP_GOAL   0xFC

Goal cell. Green in robomon.

Definition at line 17 of file map_definitions.h.

#define MAP_GOAL   0xFC

Goal cell. Green in robomon.

Definition at line 17 of file map_definitions.h.

Referenced by getPathLength(), robomon::paintMap(), ShmapIsFreeCell(), and trajctory_recalc().

#define MAP_HEIGHT   21

Field height

Definition at line 10 of file map_definitions.h.

#define MAP_HEIGHT   21

Field height

Definition at line 10 of file map_definitions.h.

Referenced by calculateMapHeuristic(), initGraphStructure(), robomon::paintMap(), ShmapAllFreeSpace(), ShmapCell2Point_Y(), ShmapClearOldPath(), ShmapIsCellInMap(), ShmapPoint2Cell_Y(), ShmapUpdateTmpObstacles(), and robomon::showMap().

#define MAP_NEW_OBSTACLE   0xFB

Fouded obstacle cell. Blue in robomon.

Definition at line 18 of file map_definitions.h.

#define MAP_NEW_OBSTACLE   0xFB

Fouded obstacle cell. Blue in robomon.

Definition at line 18 of file map_definitions.h.

Referenced by robomon::paintMap(), ShmapUpdateTmpObstacles(), and trajctory_recalc().

#define MAP_PATH   0xFE

Path cell. Darkred in robomon.

Definition at line 15 of file map_definitions.h.

#define MAP_PATH   0xFE

Path cell. Darkred in robomon.

Definition at line 15 of file map_definitions.h.

Referenced by getPathLength(), robomon::paintMap(), ShmapIsFreeCell(), and trajctory_recalc().

#define MAP_START   0xFD

Start cell. Red in robomon.

Definition at line 16 of file map_definitions.h.

#define MAP_START   0xFD

Start cell. Red in robomon.

Definition at line 16 of file map_definitions.h.

Referenced by getPathLength(), robomon::paintMap(), and ShmapIsFreeCell().

#define MAP_WALL   0xFF

Wall cell. Black in robomon.

Definition at line 14 of file map_definitions.h.

#define MAP_WALL   0xFF

Wall cell. Black in robomon.

Definition at line 14 of file map_definitions.h.

Referenced by robomon::paintMap(), and trajctory_recalc().

#define MAP_WIDTH   30

Field width

Definition at line 9 of file map_definitions.h.

#define MAP_WIDTH   30

Field width

Definition at line 9 of file map_definitions.h.

Referenced by calculateMapHeuristic(), initGraphStructure(), robomon::paintMap(), ShmapAllFreeSpace(), ShmapCell2Point_X(), ShmapClearOldPath(), ShmapIsCellInMap(), ShmapUpdateTmpObstacles(), and robomon::showMap().

#define SHM_MAP_KEY   555

Key use to share the memory SHM

Definition at line 21 of file map_definitions.h.

#define SHM_MAP_KEY   555

Key use to share the memory SHM

Definition at line 21 of file map_definitions.h.

Referenced by ShmapInit(), and robomon::showMap().

#define WALL_COST   1000

Cost fo jumping a wall.

Definition at line 12 of file map_definitions.h.

#define WALL_COST   1000

Cost fo jumping a wall.

Definition at line 12 of file map_definitions.h.

Referenced by cFunction().


Typedef Documentation

typedef unsigned char map_t

Field width

Definition at line 30 of file map_definitions.h.

typedef unsigned char map_t

Field width

Definition at line 30 of file map_definitions.h.


Function Documentation

void freePathMemory ( PathPoint simple_path  ) 

Free memory allocated for simple path

Parameters:
first_point A pointer to the list of points of simplest path

Definition at line 208 of file path_simplifier.c.

Referenced by new_goal().

Here is the caller graph for this function:

int path_planner ( double  xstart_real,
double  ystart_real,
double  xgoal_real,
double  ygoal_real,
PathPoint **  simple_path,
double *  angle 
)

Returns a list of PathPoints of the path

Parameters:
xstart X coordinate in meters
ystart Y coordinate in meters
xgoal X coordinate in meters
ygoal Y coordinate in meters
simple_path A pointer to where the simple path will be stocked
angle A pointer to a double variable where the final angle of the trajectory will be stocked.
Returns:
1 if a path is founded, 0 if not
Warning:
The Shared Map Memory must be init before.

Do not forget to free allocated memory with freePathMemory(). It takes parameters of start and goal points. It returns the number of points of the trajectory and the caller must specify pointers to path and angle.

Definition at line 27 of file path_planner.c.

References aAlgorithm(), DBG, _PathPoint::next, path_simplifier(), PP_ERROR_GOAL_IS_OBSTACLE, PP_ERROR_GOAL_NOT_REACHABLE, PP_ERROR_MAP_NOT_INIT, ShmapClearOldPath(), ShmapIsFreePoint(), and ShmapIsMapInit().

Here is the call graph for this function:


Variable Documentation

struct map* map

Field width

Definition at line 18 of file robot-planning.cc.


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