Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef _NAVFN_H
00042 #define _NAVFN_H
00043
00044 #include <math.h>
00045 #include <stdint.h>
00046 #include <string.h>
00047 #include <stdio.h>
00048 #include <vector>
00049
00050
00051 #define COST_UNKNOWN_ROS 255 // 255 is unknown cost
00052 #define COST_OBS 254 // 254 for forbidden regions
00053 #define COST_OBS_ROS 253 // ROS values of 253 are obstacles
00054 #define COST_NEUTRAL 50 // Set this to "open space" value
00055 #define COST_FACTOR 3 // Used for translating costs in NavFn::setCostmap()
00056
00057
00058
00059
00060 #ifndef COSTTYPE
00061 #define COSTTYPE unsigned char // Whatever is used...
00062 #endif
00063
00064
00065 #define POT_HIGH 1.0e10 // unassigned cell potential
00066
00067
00068 #define PRIORITYBUFSIZE 10000
00069
00070
00071 #include <tf/transform_datatypes.h>
00072 #include <geometry_msgs/PoseStamped.h>
00073 #include <Eigen/Dense>
00074 #include <Eigen/Geometry>
00075 #include <Eigen/StdVector>
00076 #include <Eigen/Core>
00077 #include <iostream>
00078 #include <math.h>
00079
00080 namespace iri_bspline_navfn {
00095 int create_nav_plan_astar(const COSTTYPE *costmap, int nx, int ny,
00096 int* goal, int* start,
00097 float *plan, int nplan);
00098
00099
00100
00105 class NavFn
00106 {
00107 public:
00113 NavFn(int nx, int ny);
00114
00115 ~NavFn();
00116
00122 void setNavArr(int nx, int ny);
00123 int nx, ny, ns;
00131 void setCostmap(const COSTTYPE *cmap, bool isROS=true, bool allow_unknown = true);
00137 bool calcNavFnAstar();
00142 bool calcNavFnDijkstra(bool atStart = false);
00143
00144 void setNavPoses(const geometry_msgs::PoseStamped& goal_, const geometry_msgs::PoseStamped& start_, const double resolution_, const double costmap_ox_, const double costmap_oy_);
00145
00146 geometry_msgs::PoseStamped w_goal;
00147 geometry_msgs::PoseStamped w_start;
00148 double resolution;
00149 double costmap_ox;
00150 double costmap_oy;
00151 float theta1;
00152 float theta2;
00153 float theta3;
00154 float theta4;
00155 int m_goal[2];
00156 float p1[2];
00157 float p2[2];
00158 float p3[2];
00159 float p4[2];
00160
00161
00162
00167 float *getPathX();
00173 float *getPathY();
00179 int getPathLen();
00181
00186 void spline();
00187
00188
00189
00194 float getLastPathCost();
00197 COSTTYPE *obsarr;
00198 COSTTYPE *costarr;
00199 float *potarr;
00200
00201 int world_s;
00202 int S_map[303][2];
00203
00204 bool *pending;
00205 int nobs;
00208 int *pb1, *pb2, *pb3;
00209 int *curP, *nextP, *overP;
00210 int curPe, nextPe, overPe;
00213 float curT;
00214 float priInc;
00221 void setGoal(int *goal);
00222
00227 void setStart(int *start);
00228
00229 int goal[2];
00230 int start[2];
00236 void initCost(int k, float v);
00239 void setObs();
00240
00247 void updateCell(int n);
00253 void updateCellAstar(int n);
00255 void setupNavFn(bool keepit = false);
00263 bool propNavFnDijkstra(int cycles, bool atStart = false);
00269 bool propNavFnAstar(int cycles);
00272 float *gradx, *grady;
00273 float *pathx, *pathy;
00274 int npath;
00275 int npathbuf;
00277 float last_path_cost_;
00285 int calcPath(int n, int *st = NULL);
00287 float gradCell(int n);
00288 float pathStep;
00291 void display(void fn(NavFn *nav), int n = 100);
00292 int displayInt;
00293 void (*displayFn)(NavFn *nav);
00296 void savemap(const char *fname);
00298 };
00299 };
00300
00301
00302 #endif // NAVFN