navfn.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 * 
00004 *  Copyright (c) 2008, Willow Garage, Inc.
00005 *  All rights reserved.
00006 * 
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 * 
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the Willow Garage nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 * 
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 
00035 //
00036 // Navigation function computation
00037 // Uses Dijkstra's method
00038 // Modified for Euclidean-distance computation
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 // cost defs
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 // Define the cost type in the case that it is not set. However, this allows
00058 // clients to modify it without changing the file. Arguably, it is better to require it to
00059 // be defined by a user explicitly
00060 #ifndef COSTTYPE
00061 #define COSTTYPE unsigned char  // Whatever is used...
00062 #endif
00063 
00064 // potential defs
00065 #define POT_HIGH 1.0e10         // unassigned cell potential
00066 
00067 // priority buffers
00068 #define PRIORITYBUFSIZE 10000
00069 
00070 //for some datatypes
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);    // size of map
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


iri_bspline_navfn
Author(s): Maintained by IRI Robotics Lab
autogenerated on Fri Dec 6 2013 23:43:14