]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/pathplan/path_planner.h
eb_jaws: Use expansion port number defines + do not use FSM for servo control.
[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
62
63 /**
64  * @name Path Planner Error Codes 
65  * @{
66  */
67 #define PP_ERROR_MAP_NOT_INIT           -1
68 #define PP_ERROR_GOAL_IS_OBSTACLE       -2
69 #define PP_ERROR_GOAL_NOT_REACHABLE     -3
70 /**@}*/
71
72 #ifdef __cplusplus
73 extern "C" {
74 #endif 
75         
76         int path_planner(double xstart_real,double ystart_real, double xgoal_real, double ygoal_real , PathPoint ** simple_path, double * angle);
77 #ifdef __cplusplus
78 }
79 #endif 
80
81
82 /**@}*/
83 /**
84  * @defgroup ppi        Path planer internal functions
85  * @section ppi_arch Path Planer Architecture
86  * PathPlaner is composed of three sublibraries or modules:
87  * - aalgorithm.c : is the implementation of A* Algorithm. More details in aalgorithm().
88  * - 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().
89  * - pathqueue.c : It is an implementation of a points queue used by the others modules.
90  */
91