Go to the documentation of this file.00001
00012 #ifndef LGL_NAVIGATION_HEURISTICS_HPP
00013 #define LGL_NAVIGATION_HEURISTICS_HPP
00014
00015 #include <math.h>
00016
00017 #include <lgl/Location.hpp>
00018 #include <lgl/NavHeuDistances.hpp>
00019
00020 namespace jafar {
00021 namespace lgl {
00022
00027
00028 template <
00029 class Graph,
00030 class CostType,
00031 typename Vertex
00032 >
00033 class nav_heuristic : public boost::astar_heuristic<Graph, CostType>
00034 {
00035 public:
00036
00037
00038 nav_heuristic(const Graph& _g, const Vertex& _goal)
00039 : g(_g), goal(_goal) {}
00040
00041 CostType operator()(const Vertex& u)
00042 {
00043 return Euclidean2DDist<NavLocation,CostType>(g[u].pos, g[goal].pos);
00044 }
00045
00046 private:
00047 Graph g;
00048 Vertex goal;
00049 };
00050
00051
00052 template <
00053 class Graph,
00054 class CostType,
00055 typename Vertex
00056 >
00057 class nav_heuristic_rdv: public boost::astar_heuristic<Graph, CostType>
00058 {
00059 public:
00062 nav_heuristic_rdv(const Graph& g_, const Vertex& goal_, CostType authDist_, std::vector<Vertex> &predMap_)
00063 : g(g_), goal(goal_), authDist(authDist_), predMap(predMap_) {}
00064
00065 CostType operator()(const Vertex& u)
00066 {
00067 CostType eucDist = Euclidean2DDist<NavLocation,CostType>(g[u].pos, g[goal].pos);
00068
00069
00070 CostType pathLength = 0.0;
00071 for(Vertex ui = u;; ui = predMap[ui]) {
00072 if(predMap[ui] == ui)
00073 {
00074 break;
00075 }
00076 pathLength += Euclidean2DDist<NavLocation,CostType>(
00077 g[predMap[ui]].pos,
00078 g[ui].pos);
00079 }
00080
00081
00082
00083 pathLength = fabs(authDist - pathLength);
00084
00085
00086 return (eucDist + pathLength);
00087
00088 }
00089
00090 private:
00091 Graph g;
00092 Vertex goal;
00093 Vertex start;
00094 CostType authDist;
00095 std::vector<Vertex> predMap;
00096 };
00097 }
00098 }
00099 #endif
00100
00101