path_planner.c

Go to the documentation of this file.
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         // Init the map
00034         if (! ShmapIsMapInit()) {DBG("ERROR: shared map memory is not init.\n"); return PP_ERROR_MAP_NOT_INIT;}
00035 
00036         // Clear previous path
00037         ShmapClearOldPath();
00038         
00039         // If the goal map is not free, abort.
00040         if (!ShmapIsFreePoint(xgoal_real, ygoal_real)) {DBG("ERROR: the goal cell is an obstacle.\n"); return PP_ERROR_GOAL_IS_OBSTACLE;}
00041         
00042         // Call to A* algorithm
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         // DBG("Simplifing the path\n");
00047         // Calc a simplest path 
00048         (*simple_path) = (PathPoint *) malloc(sizeof(PathPoint));
00049         count = path_simplifier(original_path, nbpoints, (*simple_path), angle);
00050         // Do not send the first point
00051         tmp=(*simple_path);
00052         (*simple_path)= (*simple_path)->next;
00053         free(tmp);
00054         free(original_path);
00055         
00056         // All is OK
00057         return 1;
00058 
00059 
00060 }

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