Please see path_planner() documentation, the main funtion of the library. More...
Functions | |
int | path_planner (double xstart_real, double ystart_real, double xgoal_real, double ygoal_real, PathPoint **simple_path, double *angle) |
Returns the number of points of the path on success or an error code. | |
void | freePathMemory (PathPoint *simple_path) |
Free memory allocated for simple path. | |
| |
#define | DBG printf |
Returns the number of points of the path on success or an error code. | |
| |
#define | WALL_COST 1000 |
Cost fo jumping a wall. | |
#define | MAP_WALL 0xFF |
Wall cell. | |
#define | MAP_PATH 0xFE |
Path cell. | |
#define | MAP_START 0xFD |
Start cell. | |
#define | MAP_GOAL 0xFC |
Goal cell. | |
#define | MAP_NEW_OBSTACLE 0xFB |
Fouded obstacle cell. | |
#define | MAP_FREE 0x00 |
Free cell. | |
#define | SHM_MAP_KEY 555 |
Key use to share the memory SHM. | |
#define | GETMAPPOS(i, j) (*(map+i+j*MAP_WIDTH)) |
Cost fo jumping a wall. | |
typedef unsigned char | map_t |
Cost fo jumping a wall. | |
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 |
Please see path_planner() documentation, the main funtion of the library.
For working it needs map library . Is not necessary to use other functions of the library. However if you are interested, please read Path planer internal functions
The program use an implementation of A* algorithm, aalgorithm() and simplifies it by path_simplifier().
int main(){ PathPoint * path; // A pointer to the path PathPoint * tmp; // A tmp pointer double angle; // The angle of the final line double startx, starty, goalx, goaly; ShmapInit(); //Init shared map memory // Start and goal points of the path startx= 1.1; stary=1.1; goalx= 2.2; goaly = 2.0; //Calc the path if (path_planner(startx, starty, goalx, goaly, &path, &angle)) printf("Path ok!\n"); else { printf("The planner can not reach the goal\n"); return 0; } // Print the points of the trajectory tmp = 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); //Memory deallocation freePathMemory(path); // Do not forget to free the path memory after use. ShmapFree(); //Free Shared Map Memory return 0; }
#define DBG printf |
Returns the number of points of the path on success or an error code.
xstart_real | X coordinate in meters | |
ystart_real | Y coordinate in meters | |
xgoal_real | X coordinate in meters | |
ygoal_real | 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. |
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.
The result of the algorithm is stored in a list of PathPoint, terminated by NULL, containing the points of the path. This memory is allocated dynamicaly and its address will be returned as a double pointer to the path (simple_path) passed as argument. After use the path, memory should be free with freePathMemory(). A pointer of the final angle must be also passed as argument.
The map memory must be init with ShmapInit() before calling path_planner(). Do not forget to free this map memory with ShmapFree().
#define MAP_FREE 0x00 |
Free cell.
The robot can move on. White in robomon.
#define MAP_GOAL 0xFC |
Goal cell.
Green in robomon.
#define MAP_NEW_OBSTACLE 0xFB |
Fouded obstacle cell.
Blue in robomon.
#define MAP_PATH 0xFE |
Path cell.
Darkred in robomon.
#define MAP_START 0xFD |
Start cell.
Red in robomon.
#define MAP_WALL 0xFF |
Wall cell.
Black in robomon.
#define PP_ERROR_GOAL_IS_OBSTACLE -2 |
#define PP_ERROR_GOAL_NOT_REACHABLE -3 |
#define PP_ERROR_MAP_NOT_INIT -1 |
#define SHM_MAP_KEY 555 |
Key use to share the memory SHM.
#define WALL_COST 1000 |
Cost fo jumping a wall.
typedef unsigned char map_t |
Cost fo jumping a wall.
void freePathMemory | ( | PathPoint * | simple_path | ) |
Free memory allocated for simple path.
simple_path | A pointer to the list of points of simplest path |
int path_planner | ( | double | xstart_real, | |
double | ystart_real, | |||
double | xgoal_real, | |||
double | ygoal_real, | |||
PathPoint ** | simple_path, | |||
double * | angle | |||
) |
Returns the number of points of the path on success or an error code.
xstart_real | X coordinate in meters | |
ystart_real | Y coordinate in meters | |
xgoal_real | X coordinate in meters | |
ygoal_real | 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. |
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.
The result of the algorithm is stored in a list of PathPoint, terminated by NULL, containing the points of the path. This memory is allocated dynamicaly and its address will be returned as a double pointer to the path (simple_path) passed as argument. After use the path, memory should be free with freePathMemory(). A pointer of the final angle must be also passed as argument.
The map memory must be init with ShmapInit() before calling path_planner(). Do not forget to free this map memory with ShmapFree().