MIRA
TopoMapPlanner.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2013,
3  Neuroinformatics and Cognitive Robotics Labs at TU Ilmenau, Germany
4 
5 All rights reserved.
6 
7 Copying, resale, or redistribution, with or without modification, is strictly
8 prohibited.
9 
10 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
11 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
14 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES,
15 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 */
17 
26 #pragma once
27 
28 #include <topomap/TopoMap.h>
29 
30 namespace viros { namespace topomap {
31 
33 
35 {
36 
37 public:
38 
40 
41 public:
42 
44  void setLeafCostFunction(boost::function<void(NodePtr)> fn);
45 
46 
47  void precomputeCosts(TopoMapPtr map);
48 
54  void propagateUpdatedCosts(NodePtr node);
55 
63  void setConnectivityViolated(NodePtr node, bool isViolated=true);
64 
69  bool isConnectivityViolated(NodePtr node) const;
70 
76 
80  void setAdditionalLinkCosts(const std::string& fromGWName, const std::string& toGWName, double costs);
81 
86 
87 private:
88 
89  void precomputeCosts(NodePtr node);
90 
96  void computeIntraLinkCosts(NodePtr node);
97 
98 public:
99  struct GatewayCostPair {
101  double costs;
102  int hops;
103 
105  GatewayCostPair(GatewayNodePtr n, double c, int h=0) :
106  node(n), costs(c), hops(h) {}
107 
108  bool operator<(const GatewayCostPair& other) const {
109  return costs>other.costs;
110  // those with smaller costs first: hence we need to swap the
111  // cmp operator as priority_queue keeps the "largest" element on top
112  // of the queue
113  }
114  };
115  typedef std::priority_queue<GatewayCostPair> OpenList;
116 
117  struct CostInfo {
118  double costs;
119  int hops;
120 
121  CostInfo() {}
122  CostInfo(double c, int h) : costs(c), hops(h) {}
123 
124  };
125  typedef std::map<GatewayNodePtr,CostInfo> VisitedList;
126 
127  void prepareWavefront(OpenList& Q, const VisitedList& V);
128  bool propagateWavefront(OpenList& Q, VisitedList& V, const NodeSet& localizedNodes = NodeSet(), const NodeSet& ancestors = NodeSet());
129 
131  static double infinity() {
132  return std::numeric_limits<double>::max();
133  }
134 
135 public:
136 
137  struct DbgHopInfo {
139  double costs;
140  int hops;
141 
144  };
145 
146  std::list<DbgHopInfo> dbgHops;
148 
149 private:
150 
151  boost::function<void(NodePtr)> mLeafCostFunction;
152 
153  typedef std::map<std::string, double> AdditionalCostMap;
154  AdditionalCostMap mAdditionalLinkCosts;
155 };
156 
157 
159 
160 } } // namespace
std::list< DbgHopInfo > dbgHops
Definition: TopoMapPlanner.h:146
double costs
Definition: TopoMapPlanner.h:139
DbgHopInfo()
Definition: TopoMapPlanner.h:142
DbgHopInfo(GatewayNodePtr gw, double costs, int hops)
Definition: TopoMapPlanner.h:143
double costs
Definition: TopoMapPlanner.h:101
void clearAllConnecitvityViolations(TopoMapPtr map)
Clears all set and inferred flags of violated connectivity assumptions and hence resets the topologic...
boost::shared_ptr< GatewayNode > GatewayNodePtr
Definition: TopoMapFwd.h:87
bool isConnectivityViolated(NodePtr node) const
Returns true, if the full connectivity assumption of the given node is known to be violated...
Definition: TopoMapPlanner.h:117
CostInfo()
Definition: TopoMapPlanner.h:121
GatewayNodePtr node
Definition: TopoMapPlanner.h:100
std::set< NodePtr, shared_ptr_sort< Node > > NodeSet
Definition: TopoMapFwd.h:101
GatewayCostPair()
Definition: TopoMapPlanner.h:104
bool dbgEnabled
Definition: TopoMapPlanner.h:147
void precomputeCosts(TopoMapPtr map)
void setLeafCostFunction(boost::function< void(NodePtr)> fn)
Sets function for computing intra costs in leaf nodes.
std::priority_queue< GatewayCostPair > OpenList
Definition: TopoMapPlanner.h:115
void setAdditionalLinkCosts(const std::string &fromGWName, const std::string &toGWName, double costs)
Define additional costs for a specific link.
int hops
Definition: TopoMapPlanner.h:102
CostInfo(double c, int h)
Definition: TopoMapPlanner.h:122
GatewayNodePtr gw
Definition: TopoMapPlanner.h:138
static double infinity()
"infinity" costs, indicating that a link is blocked
Definition: TopoMapPlanner.h:131
void setConnectivityViolated(NodePtr node, bool isViolated=true)
Explicitly informs the TopoMapPlanner, that the general assumption, that the given node is fully conn...
bool propagateWavefront(OpenList &Q, VisitedList &V, const NodeSet &localizedNodes=NodeSet(), const NodeSet &ancestors=NodeSet())
int hops
Definition: TopoMapPlanner.h:140
void prepareWavefront(OpenList &Q, const VisitedList &V)
boost::shared_ptr< TopoMap > TopoMapPtr
Definition: TopoMapFwd.h:91
boost::shared_ptr< Node > NodePtr
Definition: TopoMapFwd.h:84
Definition: MetricCostmapTopoMapPlanner.h:45
Definition: TopoMapPlanner.h:137
bool operator<(const GatewayCostPair &other) const
Definition: TopoMapPlanner.h:108
GatewayCostPair(GatewayNodePtr n, double c, int h=0)
Definition: TopoMapPlanner.h:105
Definition: TopoMapPlanner.h:34
std::map< GatewayNodePtr, CostInfo > VisitedList
Definition: TopoMapPlanner.h:125
void resetAllAdditionalLinkCosts()
Reset all additional gateways costs to zero.
double costs
Definition: TopoMapPlanner.h:118
void propagateUpdatedCosts(NodePtr node)
Needs to be called whenever the costs between the gateways of the given node have been modified (intr...
int hops
Definition: TopoMapPlanner.h:119