Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
NavGraph.hpp
Go to the documentation of this file.
00001 
00013 #ifndef LGL_NAVIGATION_GRAPH_HPP
00014 #define LGL_NAVIGATION_GRAPH_HPP
00015 
00016 #include <vector>
00017 #include <math.h>
00018 
00019 #include <lgl/GeoData.hpp>
00020 #include <lgl/Decomp.hpp>
00021 #include <lgl/Quadtree.hpp>
00022 #include <lgl/PositionManager.hpp>
00023 #include <lgl/CostManager.hpp>
00024 #include <lgl/GraphPath.hpp>
00025 #include <lgl/Graphs.hpp>
00026 #include <lgl/NavGEdge.hpp>
00027 #include <lgl/NavGNode.hpp>
00028 #include <lgl/NavAStar.hpp>
00029 
00030 #include <boost/noncopyable.hpp>
00031 
00032 using namespace boost;
00033 
00034 #ifndef PRUNE_NAVGRAPH
00035 
00036 #define PRUNING_ENABLED true
00037 #define PRUNING_DISABLED false
00038 
00039 #define DEFAULT_PRUNING_THRESHOLD 0.5
00040 
00041 #endif
00042 
00043 namespace jafar { // namespace jafar
00044   namespace lgl { // namespace lgl
00045 
00051     typedef std::pair<NavLocation, Attributes> NavVertex;
00052 
00054     typedef GraphPath<NavVertex> NavPath;
00055 
00059   class NavGraph : public boost::noncopyable {
00060 
00062     typedef double COST_TYPE;
00063 
00064   public:
00065 
00066     enum verbose_tag { 
00067       VERBOSE_SILENT=0,
00068       VERBOSE_ERRORS,
00069       VERBOSE_WARNINGS,
00070       VERBOSE_INFO,
00071       VERBOSE_DEBUG
00072     };
00073 
00075     verbose_tag verbose;
00076 
00078     typedef NavGraphT<NavGEdge,NavGNode,COST_TYPE> NavGraphContainer;
00079 
00081     typedef NavAStar<NavGraphContainer::GraphContainer,NavGraphContainer::Vertex,COST_TYPE> AStarPlanner;
00082 
00084     typedef std::pair<NavGraphContainer::Vertex, double> frontierPoint;
00085 
00087     NavGraph();
00088 
00097     NavGraph(GeoData* _geodata,
00098       Quadtree<double,GeoData>* _quadtree = NULL,
00099       bool       _doNavGraphPruning = PRUNING_DISABLED,
00100       double        _pruningThreshold = DEFAULT_PRUNING_THRESHOLD,
00101       PositionManager*    _posManager = NULL,
00102       CostManager*       _costManager = NULL,
00103       //void (*_displayHook)(const NavGraphContainer::Vertex&, int)   = NULL),
00104       boost::function<void(const NavGNode& , int )> displayHook   = NULL
00105       );
00106 
00108     ~NavGraph();
00109 
00111     NavGraphContainer* getGraph();
00112 
00114     Quadtree<double,GeoData>* getQuadtree();
00115 
00119     bool rebuildGraph();
00120 
00127     bool findPath(const NavLocation& locstart, const NavLocation& locend, NavPath& navpath);
00128 
00133     bool fastFindPath(const NavLocation& locstart, const NavLocation& locend, NavPath& navpath);
00134 
00136     bool findPath(const NavLocation& locstart, const NavLocation& locend, NavPath& navpath, double& pCost);
00137 
00142     bool fastFindPath(const NavLocation& locstart, const NavLocation& locend, NavPath& navpath, double& pCost);
00143 
00154     bool findPathOnUtility(const NavLocation& start, const NavLocation& end, NavPath& navpath, double authDist = 0.0);
00155 
00157     double navCostAtNode(const NavLocation& _loc);
00158 
00160     double navCostAtNode(const NavGraphContainer::Vertex& vn);
00161 
00163     double getPathCost();
00164 
00166     double getCoopPathCost();
00167 
00169     int getNumberOfVertices();
00170 
00172     int getNumberOfEdges();
00173 
00182     void getNavGNodeFromNavLocation(NavGNode& nnode, const NavLocation& v);
00183 
00190     void getOffClusterFromVertex(const NavGraphContainer::Vertex& A, DecompCluster** dcluster, int& i, int& j);
00191 
00193     NavLocation getNavLocFromVertex(const NavGraphContainer::Vertex& A);
00194 
00198     bool areClose( const NavGraphContainer::Vertex& a, const NavGraphContainer::Vertex& b);
00199 
00201     double euclideanDistance( const NavGraphContainer::Vertex& a, const NavGraphContainer::Vertex& b);
00202 
00205     bool saveAnyField(const std::string& outfile, attributeKey _at);
00206 
00208     bool resetGoalReachingPotential();
00209 
00211     bool updateNavigationUtility();
00212 
00214     double* getPotential();
00215 
00220     void calculateNavigationUtility(bool bsetter);
00221 
00226     void calculateGoalReachingPotential(bool bsetter);
00227 
00234     void setGeodataPotential(bool bsetter);
00235 
00242     void setGeodataUtility(bool bsetter);
00243 
00250     void calculateTerrainFactor();
00251 
00263     void addNode(const NavLocation& atThisLoc,  NavGraphContainer::Vertex& vloc);
00264 
00269     bool isOnFrontier(NavGraphContainer::Vertex& vloc);
00270 
00277     bool extendFrontiers(NavGraphContainer::Vertex& vfrontier, double vcost);
00278 
00283     void setNavGraphPruningOption(bool _doNavGraphPruning) ;
00284 
00290     bool getNavGraphPruningOption();
00291 
00296     void setPathPruningOption(bool _doPathPruning) ;
00297   
00302     bool getPathPruningOption();
00303 
00308     void setPruningThreshold(double _pruningThreshold) ;
00309 
00312     double getPruningThreshold();
00313 
00315     PositionManager* getPositionManager();
00316 
00323     std::list<frontierPoint> getFrontiers();
00324 
00330     double getNSP(const NavGraphContainer::Vertex& v);
00331 
00333     bool isCalculateGRP();
00334 
00336     bool isSetGeodataPotential();
00337 
00338   protected:
00339 
00340     // the raster data representing the terrain
00341     GeoData* geodata;
00342 
00344     Quadtree<double,GeoData>* quadtree;
00345 
00350     bool doNavGraphPruning ;
00351 
00356     double pruningThreshold ;
00357 
00368     bool doPathPruning;
00369 
00371     PositionManager* posManager;
00372 
00374     CostManager* costManager;
00375 
00377     NavGraphContainer* graph;
00378 
00380     AStarPlanner* planner;
00381 
00383     boost::function<void(const NavGNode& , int )> displayHook;
00384 
00385     void setDisplayHookFunction(boost::function<void(const NavGNode&, int)>_displayHook );
00386 
00387   private:
00388 
00390     bool m_quadtree_madeinhere;
00391 
00393     bool m_costmanager_madeinhere;
00395     bool m_posmanager_madeinhere;
00396 
00398     double m_closeDistance;
00399 
00404     bool buildGraph();
00405 
00410     bool set_geodata_gru;
00411 
00416     bool set_geodata_grp;
00417 
00419     bool calculate_navutil;
00420 
00422     bool calculate_grp;
00423 
00427     double terrainFactor[((T_OBSTACLE-T_FREE)+1)];
00428 
00430     double pathCost;
00431 
00433     double coopPathCost;
00434 
00439     std::list<frontierPoint> frontiers;
00440 
00441 
00442   };
00443 
00444 }
00445 }
00446 
00447 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:24 for Jafar by doxygen 1.7.6.1
LAAS-CNRS