]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/pathplan/path_planner.h
robotfsm, pathplan: add angle for pathplan start point
[eurobot/public.git] / src / pathplan / path_planner.h
1 #include "aalgorithm.h"
2 #include "path_simplifier.h"
3 #include "pathqueue.h"
4 #include "map.h"
5 #include <stdlib.h>
6 #include <math.h>
7 /**
8  * @defgroup pp Path Planner
9  * 
10  * 
11  * Please see path_planner() documentation, the main funtion of the library. For working it needs @link maplib map library @endlink. 
12  * Is not necessary to use other functions of the library. However if you are interested, please read @ref ppi
13  * 
14  * @section pp_algorithms       The internal algorithms
15  * The program use an implementation of A* algorithm, aalgorithm() and simplifies it by path_simplifier().
16  * 
17  * @section pp_example An exemple of using this function:
18  * 
19  * @code
20  * int main(){
21  *      PathPoint * path;       // A pointer to the path
22  *      PathPoint * tmp;        // A tmp pointer
23  *      double angle;           // The angle of the final line
24  *      double startx, starty, goalx, goaly;
25  * 
26  *      ShmapInit();    //Init shared map memory
27  * 
28  *      // Start and goal points of the path
29  *      startx= 1.1; stary=1.1;
30  *      goalx= 2.2; goaly = 2.0;
31  * 
32  *      //Calc the path
33  *      if (path_planner(startx, starty, goalx, goaly, &path, &angle)) 
34  *              printf("Path ok!\n");
35  *      else    {
36  *              printf("The planner can not reach the goal\n");
37  *              return 0;
38  *      }
39  * 
40  *      // Print the points of the trajectory
41  *      tmp = path;
42  *      printf("The points of the trajectory are: ");
43  *      while (tmp!= NULL) {
44  *              printf("(%f, %f) ", tmp->x, tmp->y);
45  *              tmp = tmp->next;
46  *      }
47  *      printf("\n");
48  *      printf("The final angle is : %f\n", angle);
49  *      
50  *      //Memory deallocation
51  *      freePathMemory(path);   // Do not forget to free the path memory after use.
52  *
53  *      ShmapFree();            //Free Shared Map Memory
54  * 
55  *      return 0;
56  * }
57  * @endcode
58  * @{
59  */
60
61 enum _astar_method {
62 ASTAR_METHOD_POINT,
63 ASTAR_METHOD_SHAPE
64 };
65
66 /**
67  * @name Path Planner Error Codes 
68  * @{
69  */
70 #define PP_ERROR_MAP_NOT_INIT           -1
71 #define PP_ERROR_GOAL_IS_OBSTACLE       -2
72 #define PP_ERROR_GOAL_NOT_REACHABLE     -3
73 /**@}*/
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif 
78                 
79         int path_planner(double xstart_real, double ystart_real, double xgoal_real, double ygoal_real, PathPoint** simple_path, double* start_angle , double* goal_angle, enum _astar_method astar_method);
80                 
81 #ifdef __cplusplus
82 }
83 #endif 
84
85
86 /**@}*/
87 /**
88  * @defgroup ppi        Path planer internal functions
89  * @section ppi_arch Path Planer Architecture
90  * PathPlaner is composed of three sublibraries or modules:
91  * - aalgorithm.c : is the implementation of A* Algorithm. More details in aalgorithm().
92  * - path_simplifier.c : The result path of A* is a set of discrete cells (or pixels) that should be simplify. More details in path_simplifier().
93  * - pathqueue.c : It is an implementation of a points queue used by the others modules.
94  */
95