00001
00009 #include "path_planner.h"
00010 #define DBG printf
00011
00012
00027 int path_planner(double xstart_real,double ystart_real, double xgoal_real, double ygoal_real , PathPoint ** simple_path, double * angle)
00028 {
00029 int nbpoints, count;
00030 double *original_path;
00031 PathPoint * tmp;
00032
00033
00034 if (! ShmapIsMapInit()) {DBG("ERROR: shared map memory is not init.\n"); return PP_ERROR_MAP_NOT_INIT;}
00035
00036
00037 ShmapClearOldPath();
00038
00039
00040 if (!ShmapIsFreePoint(xgoal_real, ygoal_real)) {DBG("ERROR: the goal cell is an obstacle.\n"); return PP_ERROR_GOAL_IS_OBSTACLE;}
00041
00042
00043 nbpoints = aAlgorithm(xstart_real,ystart_real, xgoal_real, ygoal_real, &original_path);
00044 if (nbpoints < 0) return PP_ERROR_GOAL_NOT_REACHABLE;
00045
00046
00047
00048 (*simple_path) = (PathPoint *) malloc(sizeof(PathPoint));
00049 count = path_simplifier(original_path, nbpoints, (*simple_path), angle);
00050
00051 tmp=(*simple_path);
00052 (*simple_path)= (*simple_path)->next;
00053 free(tmp);
00054 free(original_path);
00055
00056
00057 return 1;
00058
00059
00060 }