RoutingGraph.cpp
Go to the documentation of this file.
2 
6 #include <lanelet2_core/geometry/Lanelet.h>
7 #include <lanelet2_core/primitives/Area.h>
8 #include <lanelet2_core/primitives/Point.h>
10 
11 #include <algorithm>
12 #include <boost/graph/reverse_graph.hpp>
13 #include <cassert> // Asserts
14 #include <memory>
15 #include <utility>
16 
19 #include "lanelet2_routing/Route.h"
25 
26 // needs to be included after shotestPath due to some overload resolution quirks
28 
29 namespace lanelet {
30 namespace routing {
31 
32 #if __cplusplus < 201703L
33 constexpr const char RoutingGraph::ParticipantHeight[];
34 #endif
35 
36 namespace {
38 using internal::DijkstraStyleSearch;
42 using internal::RoutingGraphGraph;
43 using internal::VertexVisitInformation;
44 
45 template <typename T>
46 T reservedVector(size_t size) {
47  T t;
48  t.reserve(size);
49  return t;
50 }
51 
53 struct PossibleRoutesInfo;
54 using PossibleRoutesInfoUPtr = std::unique_ptr<PossibleRoutesInfo>;
55 struct PossibleRoutesInfo {
56  uint32_t vertexId{};
57  double totalDistance{0};
58  size_t numLaneChanges{0};
60  explicit PossibleRoutesInfo(uint32_t startVertex, const ConstLaneletOrArea& startLanelet) : vertexId(startVertex) {
61  laneletsOrAreas.emplace_back(startLanelet);
62  }
63 };
64 
66 struct MoreLaneChanges {
67  bool operator()(const PossibleRoutesInfo& lhs, const PossibleRoutesInfo& rhs) const {
68  if (lhs.numLaneChanges == rhs.numLaneChanges) {
69  return lhs.totalDistance > rhs.totalDistance;
70  }
71  return lhs.numLaneChanges > rhs.numLaneChanges;
72  }
73 };
74 
76 template <typename T, typename U>
77 bool addToPath(T& path, const Optional<U>& newElements) {
78  if (newElements) {
79  path.insert(path.end(), ++newElements->begin(), newElements->end());
80  return true; // NOLINT
81  }
82  return false;
83 }
84 
86 template <typename PointT>
87 PointT createPoint(const ConstLaneletOrArea& ll) {
88  PointT p;
89  p.setId(ll.id());
90  p.setAttribute("id", Attribute(ll.id()));
91  if (ll.isLanelet()) {
92  boost::geometry::centroid(utils::toHybrid(ll.lanelet()->polygon2d()), p);
93  }
94  if (ll.isArea()) {
95  boost::geometry::centroid(utils::toHybrid(utils::to2D(ll.area()->outerBoundPolygon())), p);
96  }
97  return p;
98 }
99 
106 Optional<ConstLaneletOrArea> neighboringImpl(const GraphType::vertex_descriptor vertex,
107  const FilteredRoutingGraph& graph, bool throwOnError = false) {
108  auto outEdges = boost::out_edges(vertex, graph);
109  if (throwOnError && std::distance(outEdges.first, outEdges.second) > 1) {
110  std::string ids;
111  std::for_each(outEdges.first, outEdges.second, [&graph, &ids](const auto& edge) {
112  ids += " " + std::to_string(graph[boost::target(edge, graph)].laneletOrArea.id());
113  });
114  throw RoutingGraphError("More than one neighboring lanelet to " + std::to_string(graph[vertex].laneletOrArea.id()) +
115  " with this relation:" + ids);
116  }
117  if (outEdges.first != outEdges.second) {
118  return graph[boost::target(*(outEdges.first), graph)].laneletOrArea;
119  }
120  return {};
121 }
122 
123 Optional<ConstLanelet> neighboringLaneletImpl(const GraphType::vertex_descriptor vertex,
124  const FilteredRoutingGraph& graph, bool throwOnError = false) {
125  auto value = neighboringImpl(vertex, graph, throwOnError);
126  if (!!value && value->isLanelet()) {
127  return value->lanelet();
128  }
129  return {};
130 }
131 
132 template <typename Func>
133 Optional<ConstLaneletOrArea> ifInGraph(const RoutingGraphGraph& g, const ConstLaneletOrArea& llt, Func f) {
134  auto vertex = g.getVertex(llt);
135  if (!vertex) {
136  return {};
137  }
138  return f(*vertex);
139 }
140 
141 template <typename Func>
142 Optional<ConstLanelet> ifLaneletInGraph(const RoutingGraphGraph& g, const ConstLanelet& llt, Func f) {
143  auto laneletVertex = g.getVertex(llt);
144  if (!laneletVertex) {
145  return {};
146  }
147  return f(*laneletVertex);
148 }
149 
150 template <typename Func>
151 ConstLanelets getUntilEnd(const ConstLanelet& start, Func next) {
152  auto result = reservedVector<ConstLanelets>(3);
153  Optional<ConstLanelet> current = start;
154  while (!!(current = next(*current))) {
155  result.emplace_back(*current);
156  }
157  return result;
158 }
159 
160 ConstLaneletOrAreas getAllEdgesFromGraph(const RoutingGraphGraph& graph, const FilteredRoutingGraph& subgraph,
161  const ConstLaneletOrArea& laneletOrArea, bool edgesOut) {
162  ConstLaneletOrAreas result;
163  auto laneletVertex = graph.getVertex(laneletOrArea);
164  if (!laneletVertex) {
165  return result;
166  }
167  auto processEdges = [&](auto edgeRange) {
168  result.reserve(size_t(std::distance(edgeRange.first, edgeRange.second)));
169  for (; edgeRange.first != edgeRange.second; edgeRange.first++) {
170  auto node =
171  edgesOut ? boost::target(*edgeRange.first, graph.get()) : boost::source(*edgeRange.first, graph.get());
172  result.emplace_back(graph.get()[node].laneletOrArea);
173  }
174  return result;
175  };
176  return edgesOut ? processEdges(boost::out_edges(*laneletVertex, subgraph))
177  : processEdges(boost::in_edges(*laneletVertex, subgraph));
178 }
179 
180 ConstLanelets getLaneletEdgesFromGraph(const RoutingGraphGraph& graph, const FilteredRoutingGraph& subgraph,
181  const ConstLanelet& lanelet, bool edgesOut) {
182  ConstLanelets result;
183  auto allEdges = getAllEdgesFromGraph(graph, subgraph, lanelet, edgesOut);
184  result = reservedVector<ConstLanelets>(allEdges.size());
185  for (auto& edge : allEdges) {
186  if (edge.isLanelet()) {
187  result.push_back(*edge.lanelet());
188  }
189  }
190  return result;
191 }
192 
193 template <bool Backw>
194 struct GetGraph {};
195 template <>
196 struct GetGraph<true> {
197  template <typename G>
198  auto operator()(const G& g) {
199  return boost::make_reverse_graph(g);
200  }
201 };
202 template <>
203 struct GetGraph<false> {
204  template <typename G>
205  auto operator()(const G& g) {
206  return g;
207  }
208 };
209 
210 template <bool Backw, typename OutVertexT, typename GraphT>
211 std::vector<OutVertexT> buildPath(const DijkstraSearchMap<LaneletVertexId>& map, LaneletVertexId vertex, GraphT g) {
212  const auto* currInfo = &map.at(vertex);
213  auto size = currInfo->length;
214  std::vector<OutVertexT> path(size);
215  while (true) {
216  auto idx = Backw ? size - currInfo->length : currInfo->length - 1;
217  path[idx] = static_cast<OutVertexT>(g[vertex].laneletOrArea);
218  if (currInfo->predecessor == vertex) {
219  break;
220  }
221  vertex = currInfo->predecessor;
222  currInfo = &map.at(vertex);
223  }
224  return path;
225 }
226 
227 template <typename Cost1, typename Cost2>
228 struct CombinedCost {
229  CombinedCost(const Cost1& c1, const Cost2& c2) : c1{c1}, c2{c2} {}
230  template <typename T>
231  inline bool operator()(const T& v) const {
232  return c1(v) && c2(v);
233  }
234  Cost1 c1;
235  Cost2 c2;
236 };
237 
238 template <bool Eq = false>
239 struct StopIfLaneletsMoreThan {
240  explicit StopIfLaneletsMoreThan(size_t n) : n{n} {}
241  template <typename T>
242  inline bool operator()(const T& v) const {
243  return Eq ? v.length <= n : v.length < n;
244  }
245  size_t n;
246 };
247 
248 template <bool Eq = false>
249 struct StopIfCostMoreThan {
250  explicit StopIfCostMoreThan(double c) : c{c} {}
251  template <typename T>
252  inline bool operator()(const T& v) const {
253  return Eq ? v.cost <= c : v.cost < c;
254  }
255 
256  template <typename Other>
257  CombinedCost<StopIfCostMoreThan, Other> operator&&(const Other& o) {
258  return {*this, o};
259  }
260  double c;
261 };
262 
263 template <bool Backw, bool KeepShorter, typename OutVertexT, typename OutContainerT, typename Func>
264 std::vector<OutContainerT> possiblePathsImpl(const GraphType::vertex_descriptor& start,
265  const FilteredRoutingGraph& graph, Func stopCriterion) {
266  auto g = GetGraph<Backw>{}(graph);
267  DijkstraStyleSearch<decltype(g)> search(g);
268  search.query(start, stopCriterion);
269  auto keepPath = [&](auto& vertex) { return vertex.second.isLeaf && (KeepShorter || !vertex.second.predicate); };
270  auto numPaths = size_t(std::count_if(search.getMap().begin(), search.getMap().end(), keepPath));
271  std::vector<OutContainerT> result;
272  result.reserve(numPaths);
273  for (auto& vertex : search.getMap()) {
274  if (!keepPath(vertex)) {
275  continue;
276  }
277  result.emplace_back(buildPath<Backw, OutVertexT>(search.getMap(), vertex.first, graph));
278  }
279  return result;
280 }
281 
282 template <bool Backw, typename OutVertexT, typename OutContainerT>
283 std::vector<OutContainerT> possiblePathsImpl(const GraphType::vertex_descriptor& start,
284  const FilteredRoutingGraph& graph, const PossiblePathsParams& params) {
285  if (params.routingCostLimit && !params.elementLimit && !params.includeShorterPaths) {
286  return possiblePathsImpl<Backw, false, OutVertexT, OutContainerT>(start, graph,
287  StopIfCostMoreThan<>(*params.routingCostLimit));
288  }
289  if (params.routingCostLimit && !params.elementLimit && params.includeShorterPaths) {
290  return possiblePathsImpl<Backw, true, OutVertexT, OutContainerT>(start, graph,
291  StopIfCostMoreThan<>(*params.routingCostLimit));
292  }
293  if (!params.routingCostLimit && params.elementLimit && !params.includeShorterPaths) {
294  return possiblePathsImpl<Backw, false, OutVertexT, OutContainerT>(start, graph,
295  StopIfLaneletsMoreThan<>(*params.elementLimit));
296  }
297  if (!params.routingCostLimit && params.elementLimit && params.includeShorterPaths) {
298  return possiblePathsImpl<Backw, true, OutVertexT, OutContainerT>(start, graph,
299  StopIfLaneletsMoreThan<>(*params.elementLimit));
300  }
301  if (params.routingCostLimit && params.elementLimit && !params.includeShorterPaths) {
302  return possiblePathsImpl<Backw, false, OutVertexT, OutContainerT>(
303  start, graph, StopIfCostMoreThan<>(*params.routingCostLimit) && StopIfLaneletsMoreThan<>(*params.elementLimit));
304  }
305  if (params.routingCostLimit && params.elementLimit && params.includeShorterPaths) {
306  return possiblePathsImpl<Backw, true, OutVertexT, OutContainerT>(
307  start, graph, StopIfCostMoreThan<>(*params.routingCostLimit) && StopIfLaneletsMoreThan<>(*params.elementLimit));
308  }
309  throw InvalidInputError("Possible paths called with invalid cost limit AND invalid element limit!");
310 }
311 
312 template <bool Backw, typename OutVertexT, typename Func>
313 std::vector<OutVertexT> reachableSetImpl(const GraphType::vertex_descriptor& start, const FilteredRoutingGraph& graph,
314  Func stopCriterion) {
315  auto g = GetGraph<Backw>{}(graph);
316  DijkstraStyleSearch<decltype(g)> search(g);
317  search.query(start, stopCriterion);
318  std::vector<OutVertexT> result;
319  result.reserve(search.getMap().size());
320  for (auto& vertex : search.getMap()) {
321  if (vertex.second.predicate) {
322  result.emplace_back(static_cast<OutVertexT>(graph[vertex.first].laneletOrArea));
323  }
324  }
325  return result;
326 }
327 
328 template <typename PathT, typename PrimT>
329 Optional<PathT> shortestPathImpl(const PrimT& from, const PrimT& to, RoutingCostId routingCostId, bool withLaneChanges,
330  bool withAreas, const internal::RoutingGraphGraph& graph) {
331  auto startVertex = graph.getVertex(from);
332  auto endVertex = graph.getVertex(to);
333  if (!startVertex || !endVertex) {
334  return {};
335  }
336  auto filteredGraph =
337  withLaneChanges
338  ? withAreas ? graph.withAreasAndLaneChanges(routingCostId) : graph.withLaneChanges(routingCostId)
339  : withAreas ? graph.withAreasWithoutLaneChanges(routingCostId) : graph.withoutLaneChanges(routingCostId);
340  DijkstraStyleSearch<FilteredRoutingGraph> search(filteredGraph);
341  class DestinationReached {};
342  try {
343  search.query(*startVertex, [endVertex](const internal::VertexVisitInformation& i) {
344  if (i.vertex == *endVertex) {
345  throw DestinationReached{};
346  }
347  return true;
348  });
349  } catch (DestinationReached) { // NOLINT
350  return PathT{buildPath<false, PrimT>(search.getMap(), *endVertex, filteredGraph)};
351  }
352  return {};
353 }
354 
355 template <typename RetT, typename Primitives, typename ShortestPathFunc>
356 Optional<RetT> shortestPathViaImpl(Primitives routePoints, ShortestPathFunc&& shortestPath) {
357  Primitives path;
358  for (size_t it = 0; it < routePoints.size() - 1; it++) {
359  auto results = shortestPath(routePoints[it], routePoints[it + 1]);
360  if (!!results && !results->empty() && path.empty()) {
361  path.push_back(results->front());
362  }
363  if (!addToPath(path, results)) {
364  return Optional<RetT>();
365  }
366  }
367  return RetT(path);
368 }
369 } // namespace
370 
371 RoutingGraph::RoutingGraph(RoutingGraph&& /*other*/) noexcept = default;
372 RoutingGraph& RoutingGraph::operator=(RoutingGraph&& /*other*/) noexcept = default;
373 RoutingGraph::~RoutingGraph() = default;
374 
375 RoutingGraphUPtr RoutingGraph::build(const LaneletMap& laneletMap, const traffic_rules::TrafficRules& trafficRules,
376  const RoutingCostPtrs& routingCosts, const RoutingGraph::Configuration& config) {
377  return internal::RoutingGraphBuilder(trafficRules, routingCosts, config).build(laneletMap);
378 }
379 
380 RoutingGraphUPtr RoutingGraph::build(const LaneletSubmap& laneletSubmap,
381  const traffic_rules::TrafficRules& trafficRules,
382  const RoutingCostPtrs& routingCosts, const RoutingGraph::Configuration& config) {
383  return internal::RoutingGraphBuilder(trafficRules, routingCosts, config).build(laneletSubmap);
384 }
385 
386 Optional<Route> RoutingGraph::getRoute(const ConstLanelet& from, const ConstLanelet& to, RoutingCostId routingCostId,
387  bool withLaneChanges) const {
388  auto optPath{shortestPath(from, to, routingCostId, withLaneChanges)};
389  if (!optPath) {
390  return {};
391  }
392  return internal::RouteBuilder(*graph_).getRouteFromShortestPath(*optPath, withLaneChanges, routingCostId);
393 }
394 
395 Optional<Route> RoutingGraph::getRouteVia(const ConstLanelet& from, const ConstLanelets& via, const ConstLanelet& to,
396  RoutingCostId routingCostId, bool withLaneChanges) const {
397  auto optPath{shortestPathVia(from, via, to, routingCostId, withLaneChanges)};
398  if (!optPath) {
399  return {};
400  }
401  return internal::RouteBuilder(*graph_).getRouteFromShortestPath(*optPath, withLaneChanges, routingCostId);
402 }
403 
404 Optional<LaneletPath> RoutingGraph::shortestPath(const ConstLanelet& from, const ConstLanelet& to,
405  RoutingCostId routingCostId, bool withLaneChanges) const {
406  return shortestPathImpl<LaneletPath, ConstLanelet>(from, to, routingCostId, withLaneChanges, false, *graph_);
407 }
408 
409 Optional<LaneletOrAreaPath> RoutingGraph::shortestPathIncludingAreas(const ConstLaneletOrArea& from,
410  const ConstLaneletOrArea& to,
411  RoutingCostId routingCostId,
412  bool withLaneChanges) const {
413  return shortestPathImpl<LaneletOrAreaPath, ConstLaneletOrArea>(from, to, routingCostId, withLaneChanges, true,
414  *graph_);
415 }
416 
417 Optional<LaneletPath> RoutingGraph::shortestPathVia(const ConstLanelet& start, const ConstLanelets& via,
418  const ConstLanelet& end, RoutingCostId routingCostId,
419  bool withLaneChanges) const {
420  ConstLanelets routePoints = utils::concatenate({ConstLanelets{start}, via, ConstLanelets{end}});
421  return shortestPathViaImpl<LaneletPath>(
422  routePoints, [&](auto& from, auto& to) { return this->shortestPath(from, to, routingCostId, withLaneChanges); });
423 }
424 
425 Optional<LaneletOrAreaPath> RoutingGraph::shortestPathIncludingAreasVia(const ConstLaneletOrArea& start,
426  const ConstLaneletOrAreas& via,
427  const ConstLaneletOrArea& end,
428  RoutingCostId routingCostId,
429  bool withLaneChanges) const {
431  return shortestPathViaImpl<LaneletOrAreaPath>(routePoints, [&](auto& from, auto& to) {
432  return this->shortestPathIncludingAreas(from, to, routingCostId, withLaneChanges);
433  });
434 }
435 
436 Optional<RelationType> RoutingGraph::routingRelation(const ConstLanelet& from, const ConstLanelet& to,
437  bool includeConflicting) const {
438  auto edgeInfo = includeConflicting ? graph_->getEdgeInfo(from, to)
439  : graph_->getEdgeInfoFor(from, to, graph_->withoutConflicting());
440  if (!!edgeInfo) {
441  return edgeInfo->relation;
442  }
443  return {};
444 }
445 
446 ConstLanelets RoutingGraph::following(const ConstLanelet& lanelet, bool withLaneChanges) const {
447  auto subgraph = withLaneChanges ? graph_->withLaneChanges() : graph_->withoutLaneChanges();
448  return getLaneletEdgesFromGraph(*graph_, subgraph, lanelet, true);
449 }
450 
451 LaneletRelations RoutingGraph::followingRelations(const ConstLanelet& lanelet, bool withLaneChanges) const {
452  ConstLanelets foll{following(lanelet, withLaneChanges)};
453  LaneletRelations result;
454  for (auto const& it : foll) {
455  result.emplace_back(LaneletRelation{it, *routingRelation(lanelet, it)});
456  }
457  return result;
458 } // namespace routing
459 
460 ConstLanelets RoutingGraph::previous(const ConstLanelet& lanelet, bool withLaneChanges) const {
461  auto subgraph = withLaneChanges ? graph_->withLaneChanges(0) : graph_->withoutLaneChanges(0);
462  return getLaneletEdgesFromGraph(*graph_, subgraph, lanelet, false);
463 }
464 
465 LaneletRelations RoutingGraph::previousRelations(const ConstLanelet& lanelet, bool withLaneChanges) const {
466  ConstLanelets prev{previous(lanelet, withLaneChanges)};
467  LaneletRelations result;
468  result.reserve(prev.size());
469  for (auto const& it : prev) {
470  Optional<RelationType> relation{routingRelation(it, lanelet)};
471  if (!!relation) {
472  result.emplace_back(LaneletRelation{it, *relation});
473  } else {
474  assert(false && "Two Lanelets in a route are not connected. This shouldn't happen."); // NOLINT
475  }
476  }
477  return result;
478 }
479 
480 ConstLanelets RoutingGraph::besides(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
481  auto move = [](auto it) { return std::make_move_iterator(it); };
482  ConstLanelets left{lefts(lanelet, routingCostId)};
483  ConstLanelets right{rights(lanelet, routingCostId)};
484  ConstLanelets result;
485  result.reserve(left.size() + right.size() + 1);
486  result.insert(std::end(result), move(left.rbegin()), move(left.rend()));
487  result.push_back(lanelet);
488  result.insert(std::end(result), move(std::begin(right)), move(std::end(right)));
489  return result;
490 }
491 
493  return ifLaneletInGraph(*graph_, lanelet,
494  [&](auto& vertex) { return neighboringLaneletImpl(vertex, graph_->left(routingCostId)); });
495 }
496 
497 Optional<ConstLanelet> RoutingGraph::adjacentLeft(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
498  return ifLaneletInGraph(*graph_, lanelet, [&](auto& vertex) {
499  return neighboringLaneletImpl(vertex, graph_->adjacentLeft(routingCostId));
500  });
501 }
502 
504  return ifLaneletInGraph(*graph_, lanelet,
505  [&](auto& vertex) { return neighboringLaneletImpl(vertex, graph_->right(routingCostId)); });
506 }
507 
508 Optional<ConstLanelet> RoutingGraph::adjacentRight(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
509  return ifLaneletInGraph(*graph_, lanelet, [&](auto& vertex) {
510  return neighboringLaneletImpl(vertex, graph_->adjacentRight(routingCostId));
511  });
512 }
513 
514 ConstLanelets RoutingGraph::lefts(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
515  return getUntilEnd(lanelet, [&](const ConstLanelet& llt) { return left(llt, routingCostId); });
516 }
517 
518 ConstLanelets RoutingGraph::adjacentLefts(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
519  return getUntilEnd(lanelet, [&](const ConstLanelet& llt) { return adjacentLeft(llt, routingCostId); });
520 }
521 
522 LaneletRelations RoutingGraph::leftRelations(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
523  bool leftReached{false};
524  ConstLanelet current = lanelet;
525  LaneletRelations result;
526  while (!leftReached) {
527  const ConstLanelets leftOf{lefts(current, routingCostId)};
528  for (auto const& it : leftOf) {
529  result.emplace_back(LaneletRelation{it, RelationType::Left});
530  current = it;
531  }
532  const ConstLanelets adjacentLeftOf{adjacentLefts(current, routingCostId)};
533  for (auto const& it : adjacentLeftOf) {
534  result.emplace_back(LaneletRelation{it, RelationType::AdjacentLeft});
535  current = it;
536  }
537  leftReached = (leftOf.empty() && adjacentLeftOf.empty());
538  }
539  return result;
540 }
541 
542 ConstLanelets RoutingGraph::rights(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
543  return getUntilEnd(lanelet, [&](const ConstLanelet& llt) { return right(llt, routingCostId); });
544 }
545 
546 ConstLanelets RoutingGraph::adjacentRights(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
547  return getUntilEnd(lanelet, [&](const ConstLanelet& llt) { return adjacentRight(llt, routingCostId); });
548 }
549 
550 LaneletRelations RoutingGraph::rightRelations(const ConstLanelet& lanelet, RoutingCostId routingCostId) const {
551  bool rightReached{false};
552  ConstLanelet current = lanelet;
553  auto result = reservedVector<LaneletRelations>(3);
554  while (!rightReached) {
555  const ConstLanelets rightOf{rights(current, routingCostId)};
556  for (auto const& it : rightOf) {
557  result.emplace_back(LaneletRelation{it, RelationType::Right});
558  current = it;
559  }
560  const ConstLanelets adjacentRightOf{adjacentRights(current, routingCostId)};
561  for (auto const& it : adjacentRightOf) {
562  result.emplace_back(LaneletRelation{it, RelationType::AdjacentRight});
563  current = it;
564  }
565  rightReached = (rightOf.empty() && adjacentRightOf.empty());
566  }
567  return result;
568 }
569 
570 ConstLaneletOrAreas RoutingGraph::conflicting(const ConstLaneletOrArea& laneletOrArea) const {
571  return getAllEdgesFromGraph(*graph_, graph_->conflicting(), laneletOrArea, true);
572 }
573 
574 ConstLanelets RoutingGraph::reachableSet(const ConstLanelet& lanelet, double maxRoutingCost,
575  RoutingCostId routingCostId, bool allowLaneChanges) const {
576  auto start = graph_->getVertex(lanelet);
577  if (!start) {
578  return {};
579  }
580  auto graph = allowLaneChanges ? graph_->withLaneChanges(routingCostId) : graph_->withoutLaneChanges(routingCostId);
581  return reachableSetImpl<false, ConstLanelet>(*start, graph, StopIfCostMoreThan<true>{maxRoutingCost});
582 }
583 
584 ConstLaneletOrAreas RoutingGraph::reachableSetIncludingAreas(const ConstLaneletOrArea& llOrAr, double maxRoutingCost,
585  RoutingCostId routingCostId) const {
586  auto start = graph_->getVertex(llOrAr);
587  if (!start) {
588  return {};
589  }
590  auto graph = graph_->withAreasAndLaneChanges(routingCostId);
591  return reachableSetImpl<false, ConstLaneletOrArea>(*start, graph, StopIfCostMoreThan<true>{maxRoutingCost});
592 }
593 
594 ConstLanelets RoutingGraph::reachableSetTowards(const ConstLanelet& lanelet, double maxRoutingCost,
595  RoutingCostId routingCostId, bool allowLaneChanges) const {
596  auto start = graph_->getVertex(lanelet);
597  if (!start) {
598  return {};
599  }
600  auto graph = allowLaneChanges ? graph_->withLaneChanges(routingCostId) : graph_->withoutLaneChanges(routingCostId);
601  return reachableSetImpl<true, ConstLanelet>(*start, graph, StopIfCostMoreThan<true>{maxRoutingCost});
602 }
603 
604 LaneletPaths RoutingGraph::possiblePaths(const ConstLanelet& startPoint, const PossiblePathsParams& params) const {
605  auto start = graph_->getVertex(startPoint);
606  if (!start) {
607  return {};
608  }
609  auto graph = params.includeLaneChanges ? graph_->withLaneChanges(params.routingCostId)
610  : graph_->withoutLaneChanges(params.routingCostId);
611  return possiblePathsImpl<false, ConstLanelet, LaneletPath>(*start, graph, params);
612 }
613 
614 LaneletPaths RoutingGraph::possiblePaths(const ConstLanelet& startPoint, double minRoutingCost,
615  RoutingCostId routingCostId, bool allowLaneChanges) const {
616  return possiblePaths(startPoint, PossiblePathsParams{minRoutingCost, {}, routingCostId, allowLaneChanges, false});
617 }
618 
619 LaneletPaths RoutingGraph::possiblePaths(const ConstLanelet& startPoint, uint32_t minLanelets, bool allowLaneChanges,
620  RoutingCostId routingCostId) const {
621  return possiblePaths(startPoint, PossiblePathsParams{{}, minLanelets, routingCostId, allowLaneChanges, false});
622 }
623 
624 LaneletPaths RoutingGraph::possiblePathsTowards(const ConstLanelet& targetLanelet,
625  const PossiblePathsParams& params) const {
626  auto start = graph_->getVertex(targetLanelet);
627  if (!start) {
628  return {};
629  }
630  auto graph = params.includeLaneChanges ? graph_->withLaneChanges(params.routingCostId)
631  : graph_->withoutLaneChanges(params.routingCostId);
632  return possiblePathsImpl<true, ConstLanelet, LaneletPath>(*start, graph, params);
633 }
634 
635 LaneletPaths RoutingGraph::possiblePathsTowards(const ConstLanelet& targetLanelet, double minRoutingCost,
636  RoutingCostId routingCostId, bool allowLaneChanges) const {
637  return possiblePathsTowards(targetLanelet,
638  PossiblePathsParams{minRoutingCost, {}, routingCostId, allowLaneChanges, false});
639 }
640 
641 LaneletPaths RoutingGraph::possiblePathsTowards(const ConstLanelet& targetLanelet, uint32_t minLanelets,
642  bool allowLaneChanges, RoutingCostId routingCostId) const {
643  return possiblePathsTowards(targetLanelet,
644  PossiblePathsParams{{}, minLanelets, routingCostId, allowLaneChanges, false});
645 }
646 
647 LaneletOrAreaPaths RoutingGraph::possiblePathsIncludingAreas(const ConstLaneletOrArea& startPoint,
648  const PossiblePathsParams& params) const {
649  auto start = graph_->getVertex(startPoint);
650  if (!start) {
651  return {};
652  }
653  auto graph = params.includeLaneChanges ? graph_->withAreasAndLaneChanges(params.routingCostId)
654  : graph_->withAreasWithoutLaneChanges(params.routingCostId);
655  return possiblePathsImpl<false, ConstLaneletOrArea, LaneletOrAreaPath>(*start, graph, params);
656 }
657 
658 LaneletOrAreaPaths RoutingGraph::possiblePathsIncludingAreas(const ConstLaneletOrArea& startPoint,
659  double minRoutingCost, RoutingCostId routingCostId,
660  bool allowLaneChanges) const {
661  return possiblePathsIncludingAreas(startPoint,
662  PossiblePathsParams{minRoutingCost, {}, routingCostId, allowLaneChanges, false});
663 }
664 
665 LaneletOrAreaPaths RoutingGraph::possiblePathsIncludingAreas(const ConstLaneletOrArea& startPoint, uint32_t minElements,
666  bool allowLaneChanges, RoutingCostId routingCostId) const {
667  return possiblePathsIncludingAreas(startPoint,
668  PossiblePathsParams{{}, minElements, routingCostId, allowLaneChanges, false});
669 }
670 
671 void RoutingGraph::forEachSuccessor(const ConstLanelet& lanelet, const LaneletVisitFunction& f, bool allowLaneChanges,
672  RoutingCostId routingCostId) const {
673  auto start = graph_->getVertex(lanelet);
674  if (!start) {
675  return;
676  }
677  auto graph = allowLaneChanges ? graph_->withLaneChanges(routingCostId) : graph_->withoutLaneChanges(routingCostId);
678  DijkstraStyleSearch<FilteredRoutingGraph> search(graph);
679  search.query(*start, [&](const VertexVisitInformation& i) -> bool {
680  return f(LaneletVisitInformation{graph_->get()[i.vertex].lanelet(), graph_->get()[i.predecessor].lanelet(), i.cost,
681  i.length, i.numLaneChanges});
682  });
683 }
684 
685 void RoutingGraph::forEachSuccessorIncludingAreas(const ConstLaneletOrArea& lanelet,
686  const LaneletOrAreaVisitFunction& f, bool allowLaneChanges,
687  RoutingCostId routingCostId) const {
688  auto start = graph_->getVertex(lanelet);
689  if (!start) {
690  return;
691  }
692  auto graph = allowLaneChanges ? graph_->withAreasAndLaneChanges(routingCostId)
693  : graph_->withAreasWithoutLaneChanges(routingCostId);
694  DijkstraStyleSearch<FilteredRoutingGraph> search(graph);
695  search.query(*start, [&](const VertexVisitInformation& i) -> bool {
696  return f(LaneletOrAreaVisitInformation{graph_->get()[i.vertex].laneletOrArea,
697  graph_->get()[i.predecessor].laneletOrArea, i.cost, i.length,
698  i.numLaneChanges});
699  });
700 }
701 
702 void RoutingGraph::forEachPredecessor(const ConstLanelet& lanelet, const LaneletVisitFunction& f, bool allowLaneChanges,
703  RoutingCostId routingCostId) const {
704  auto start = graph_->getVertex(lanelet);
705  if (!start) {
706  return;
707  }
708  auto forwGraph =
709  allowLaneChanges ? graph_->withLaneChanges(routingCostId) : graph_->withoutLaneChanges(routingCostId);
710  auto graph = boost::make_reverse_graph(forwGraph); // forwGraph needs to stay on the stack
711  internal::DijkstraStyleSearch<decltype(graph)> search(graph);
712  search.query(*start, [&](const VertexVisitInformation& i) -> bool {
713  return f(LaneletVisitInformation{graph_->get()[i.vertex].lanelet(), graph_->get()[i.predecessor].lanelet(), i.cost,
714  i.length, i.numLaneChanges});
715  });
716 }
717 
718 void RoutingGraph::forEachPredecessorIncludingAreas(const ConstLaneletOrArea& lanelet,
719  const LaneletOrAreaVisitFunction& f, bool allowLaneChanges,
720  RoutingCostId routingCostId) const {
721  auto start = graph_->getVertex(lanelet);
722  if (!start) {
723  return;
724  }
725  auto forwGraph = allowLaneChanges ? graph_->withAreasAndLaneChanges(routingCostId)
726  : graph_->withAreasWithoutLaneChanges(routingCostId);
727  auto graph = boost::make_reverse_graph(forwGraph); // forwGraph needs to stay on the stack
728  internal::DijkstraStyleSearch<decltype(graph)> search(graph);
729  search.query(*start, [&](const VertexVisitInformation& i) -> bool {
730  return f(LaneletOrAreaVisitInformation{graph_->get()[i.vertex].laneletOrArea,
731  graph_->get()[i.predecessor].laneletOrArea, i.cost, i.length,
732  i.numLaneChanges});
733  });
734 }
735 
736 void RoutingGraph::exportGraphML(const std::string& filename, const RelationType& edgeTypesToExclude,
737  RoutingCostId routingCostId) const {
738  if (filename.empty()) {
739  throw InvalidInputError("No filename passed");
740  }
741  if (routingCostId >= graph_->numRoutingCosts()) {
742  throw InvalidInputError("Routing Cost ID is higher than the number of routing modules.");
743  }
744  RelationType relations = allRelations() & ~edgeTypesToExclude;
745  internal::exportGraphMLImpl<GraphType>(filename, graph_->get(), relations, routingCostId);
746 }
747 
748 void RoutingGraph::exportGraphViz(const std::string& filename, const RelationType& edgeTypesToExclude,
749  RoutingCostId routingCostId) const {
750  if (filename.empty()) {
751  throw InvalidInputError("No filename passed");
752  }
753  if (routingCostId >= graph_->numRoutingCosts()) {
754  throw InvalidInputError("Routing Cost ID is higher than the number of routing modules.");
755  }
756  RelationType relations = allRelations() & ~edgeTypesToExclude;
757  internal::exportGraphVizImpl<GraphType>(filename, graph_->get(), relations, routingCostId);
758 }
759 
761 RelationType allowedRelationsfromConfiguration(bool includeAdjacent, bool includeConflicting) {
762  RelationType allowedRelations{RelationType::Successor | RelationType::Left | RelationType::Right |
763  RelationType::Area};
764  if (includeAdjacent) {
765  allowedRelations |= RelationType::AdjacentLeft;
766  allowedRelations |= RelationType::AdjacentRight;
767  }
768  if (includeConflicting) {
769  allowedRelations |= RelationType::Conflicting;
770  }
771  return allowedRelations;
772 }
773 
774 LineString3d createLineString(const Point2d& from, const Point2d& to, RelationType relation, double routingCost) {
775  LineString2d lineString(utils::getId());
776  lineString.push_back(from);
777  lineString.push_back(to);
778  LineString3d lineString3d(lineString);
779  lineString3d.setAttribute("relation", relationToString(relation));
780  lineString3d.setAttribute("routing_cost", routingCost);
781  return lineString3d;
782 }
783 
785  public:
786  using LaneletOrAreaPair = std::pair<ConstLaneletOrArea, ConstLaneletOrArea>;
787  explicit DebugMapBuilder(const FilteredRoutingGraph& graph) : graph_{graph} {}
789  LaneletMapPtr output = std::make_shared<LaneletMap>();
790  for (const auto& vertex : loa) {
791  visitVertex(vertex);
792  }
793  auto lineStrings = utils::transform(lineStringMap_, [](auto& mapLs) { return mapLs.second; });
794  auto map = utils::createMap(lineStrings);
795  for (auto& p : pointMap_) {
796  map->add(utils::to3D(p.second));
797  }
798  return map;
799  }
800 
801  private:
802  void visitVertex(const internal::LaneletOrAreaToVertex::value_type& vertex) {
803  addPoint(vertex.first);
804  auto edges = boost::out_edges(vertex.second, graph_);
805  for (auto edge = edges.first; edge != edges.second; ++edge) {
806  const auto& target = graph_[boost::target(*edge, graph_)].laneletOrArea;
807  addPoint(target);
808  const auto& edgeInfo = graph_[*edge];
809  addEdge(vertex.first, target, edgeInfo);
810  }
811  }
812 
813  static LaneletOrAreaPair getPair(const ConstLaneletOrArea& first, const ConstLaneletOrArea& second) {
814  return first.id() < second.id() ? LaneletOrAreaPair(first, second) : LaneletOrAreaPair(second, first);
815  }
816 
817  void addPoint(const ConstLaneletOrArea& point) {
818  auto inMap = pointMap_.find(point);
819  if (inMap == pointMap_.end()) {
820  pointMap_.emplace(point, createPoint<Point2d>(point));
821  }
822  }
823 
825  auto pair = getPair(from, to);
826  auto inMap = lineStringMap_.find(pair);
827  if (inMap != lineStringMap_.end()) {
828  inMap->second.setAttribute("relation_reverse", relationToString(edge.relation));
829  inMap->second.setAttribute("routing_cost_reverse", std::to_string(edge.routingCost));
830 
831  } else {
832  auto pFrom = pointMap_.at(from);
833  auto pTo = pointMap_.at(to);
834  LineString3d lineString3d{createLineString(pFrom, pTo, edge.relation, edge.routingCost)};
835  lineStringMap_.emplace(pair, lineString3d);
836  }
837  }
838 
840  std::unordered_map<LaneletOrAreaPair, LineString3d> lineStringMap_; // Stores all relations
841  std::unordered_map<ConstLaneletOrArea, Point2d> pointMap_; // Stores all 'edges'
842 };
843 
844 LaneletMapPtr RoutingGraph::getDebugLaneletMap(RoutingCostId routingCostId, bool includeAdjacent,
845  bool includeConflicting) const {
846  if (routingCostId >= graph_->numRoutingCosts()) {
847  throw InvalidInputError("Routing Cost ID is higher than the number of routing modules.");
848  }
850  graph_->get(), routingCostId, allowedRelationsfromConfiguration(includeAdjacent, includeConflicting));
851  FilteredRoutingGraph filteredGraph(graph_->get(), edgeFilter);
852  return DebugMapBuilder(filteredGraph).run(graph_->vertexLookup());
853 }
854 
855 RoutingGraph::Errors RoutingGraph::checkValidity(bool throwOnError) const {
856  Errors errors;
857  for (const auto& laWithVertex : graph_->vertexLookup()) {
858  const auto& la = laWithVertex.first;
859  auto ll = laWithVertex.first.lanelet();
860  const auto& vertex = laWithVertex.second;
861  auto id = la.id();
862  // Check left relation
864  try {
865  left = neighboringLaneletImpl(vertex, graph_->left(), true);
866 
867  } catch (RoutingGraphError& e) {
868  errors.emplace_back(std::string("Left: ") + e.what());
869  }
870  Optional<ConstLanelet> adjacentLeft;
871  try {
872  adjacentLeft = neighboringLaneletImpl(vertex, graph_->adjacentLeft(), true);
873  } catch (RoutingGraphError& e) {
874  errors.emplace_back(std::string("Adjacent left: ") + e.what());
875  }
876  if (left && adjacentLeft) {
877  errors.emplace_back("Lanelet " + std::to_string(id) + " has both 'left' (id: " + std::to_string(left->id()) +
878  ") and 'adjancent_left' (id: " + std::to_string(adjacentLeft->id()) + ") lanelet");
879  }
880  if (left) {
881  LaneletRelations rel{rightRelations(*left)};
882  if (rel.empty()) {
883  errors.emplace_back("There is a 'left' relation from " + std::to_string(id) + " to " +
884  std::to_string(left->id()) + " but no relation back");
885  } else if (rel.front().lanelet != ll) {
886  errors.emplace_back("There is a 'left' relation from " + std::to_string(id) + " to " +
887  std::to_string(left->id()) + ", but " + std::to_string(id) +
888  " isn't the closest lanelet the other way round");
889  }
890  }
891  if (adjacentLeft) {
892  LaneletRelations rel{rightRelations(*adjacentLeft)};
893  if (rel.empty()) {
894  errors.emplace_back("There is a 'adjacentLeft' relation from " + std::to_string(id) + " to " +
895  std::to_string(adjacentLeft->id()) + " but no relation back");
896  } else if (rel.front().lanelet != ll) {
897  errors.emplace_back("There is a 'adjacentLeft' relation from " + std::to_string(id) + " to " +
898  std::to_string(adjacentLeft->id()) + ", but " + std::to_string(id) +
899  " isn't the closest lanelet the other way round");
900  }
901  }
902  // Check right
904  try {
905  right = neighboringLaneletImpl(vertex, graph_->right(), true);
906  } catch (RoutingGraphError& e) {
907  errors.emplace_back(std::string("Right: ") + e.what());
908  }
909  Optional<ConstLanelet> adjacentRight;
910  try {
911  adjacentRight = neighboringLaneletImpl(vertex, graph_->adjacentRight(), true);
912  } catch (RoutingGraphError& e) {
913  errors.emplace_back(std::string("Adjacent right: ") + e.what());
914  }
915  if (right && adjacentRight) {
916  errors.emplace_back("Lanelet " + std::to_string(id) + " has both 'right' (id: " + std::to_string(right->id()) +
917  ") and 'adjancent_right' (id: " + std::to_string(adjacentRight->id()) + ") lanelet");
918  }
919  if (right) {
920  LaneletRelations rel{leftRelations(*right)};
921  if (rel.empty()) {
922  errors.emplace_back("There is a 'right' relation from " + std::to_string(id) + " to " +
923  std::to_string(right->id()) + " but no relation back");
924  } else if (rel.front().lanelet != ll) {
925  errors.emplace_back("There is a 'right' relation from " + std::to_string(id) + " to " +
926  std::to_string(right->id()) + ", but " + std::to_string(id) +
927  " isn't the closest lanelet the other way round");
928  }
929  }
930  if (adjacentRight) {
931  LaneletRelations rel{leftRelations(*adjacentRight)};
932  if (rel.empty()) {
933  errors.emplace_back("There is a 'adjacentRight' relation from " + std::to_string(id) + " to " +
934  std::to_string(adjacentRight->id()) + " but no relation back");
935  } else if (rel.front().lanelet != ll) {
936  errors.emplace_back("There is a 'adjacentRight' relation from " + std::to_string(id) + " to " +
937  std::to_string(adjacentRight->id()) + ", but " + std::to_string(id) +
938  " isn't the closest lanelet the other way round");
939  }
940  }
941  }
942  if (throwOnError && !errors.empty()) {
943  std::stringstream ss;
944  ss << "Errors found in routing graph:";
945  for (const auto& err : errors) {
946  ss << "\n\t- " << err;
947  }
948  throw RoutingGraphError(ss.str());
949  }
950  return errors;
951 }
952 
953 RoutingGraph::RoutingGraph(std::unique_ptr<RoutingGraphGraph>&& graph, LaneletSubmapConstPtr&& passableMap)
954  : graph_{std::move(graph)}, passableLaneletSubmap_{std::move(passableMap)} {}
955 
956 } // namespace routing
957 } // namespace lanelet
c2
Cost2 c2
Definition: RoutingGraph.cpp:235
ConstLaneletOrAreas
std::vector< ConstLaneletOrArea > ConstLaneletOrAreas
lanelet::routing::internal::DijkstraStyleSearch::query
void query(VertexType start, Func &&func)
Definition: ShortestPath.h:117
Exceptions.h
RoutingGraph.h
lanelet::routing::internal::RouteBuilder::getRouteFromShortestPath
Optional< Route > getRouteFromShortestPath(const LaneletPath &path, bool withLaneChanges=true, RoutingCostId costId=0)
Definition: RouteBuilder.cpp:438
RouteBuilder.h
LaneletMap.h
lanelet::LaneletMapPtr
std::shared_ptr< LaneletMap > LaneletMapPtr
lanelet::routing::DebugMapBuilder::getPair
static LaneletOrAreaPair getPair(const ConstLaneletOrArea &first, const ConstLaneletOrArea &second)
Definition: RoutingGraph.cpp:813
lanelet
lanelet::utils::createMap
LaneletMapUPtr createMap(const Areas &fromAreas)
lanelet::utils::concatenate
auto concatenate(ContainerT &&c)
lanelet::routing::RoutingGraph::ParticipantHeight
static constexpr const char ParticipantHeight[]
Defined configuration attributes.
Definition: RoutingGraph.h:74
lanelet::routing::DebugMapBuilder::pointMap_
std::unordered_map< ConstLaneletOrArea, Point2d > pointMap_
Definition: RoutingGraph.cpp:841
lanelet::traffic_rules::TrafficRules
lanelet::routing::RoutingCostPtrs
std::vector< RoutingCostPtr > RoutingCostPtrs
Definition: Forward.h:43
lanelet::routing::relationToString
std::string relationToString(RelationType type)
Definition: Forward.h:83
lanelet::routing::internal::RouteBuilder
Builder class to create a route from a routing graph and the shortest path.
Definition: RouteBuilder.h:12
next
Optional< ConstLaneletOrArea > next
Definition: LaneletPath.cpp:83
p
BasicPoint p
lanelet::ConstLaneletOrArea
lanelet::routing::internal::EdgeInfo::routingCost
double routingCost
Calculcated routing cost. Infinity if not routable.
Definition: Graph.h:37
lanelet::utils::getId
Id getId()
lanelet::Point2d
lanelet::routing::internal::EdgeCostFilter
An internal edge filter to get a filtered view on the graph.
Definition: Graph.h:49
lanelet::routing::DebugMapBuilder::visitVertex
void visitVertex(const internal::LaneletOrAreaToVertex::value_type &vertex)
Definition: RoutingGraph.cpp:802
lanelet::routing::RelationType
RelationType
Definition: Forward.h:56
RoutingGraphBuilder.h
boost
LineStringImpl< ConstLineString2d >::push_back
void push_back(const PointType &point)
lanelet::routing::PossiblePathsParams::includeLaneChanges
bool includeLaneChanges
if true, returned paths will include lane changes
Definition: RoutingGraph.h:54
lanelet::routing::LaneletOrAreaVisitFunction
std::function< bool(const LaneletOrAreaVisitInformation &)> LaneletOrAreaVisitFunction
Definition: Types.h:31
lanelet::routing::DebugMapBuilder::run
LaneletMapPtr run(const internal::LaneletOrAreaToVertex &loa)
Definition: RoutingGraph.cpp:788
n
size_t n
Definition: RoutingGraph.cpp:245
ShortestPath.h
right
BasicPolygon3d right
Definition: LaneletPath.cpp:99
lanelet::routing::DebugMapBuilder::LaneletOrAreaPair
std::pair< ConstLaneletOrArea, ConstLaneletOrArea > LaneletOrAreaPair
Definition: RoutingGraph.cpp:786
lanelet::routing::LaneletVisitInformation
This object carries the required information for the graph neighbourhood search.
Definition: Types.h:22
Attribute.h
lanelet::routing::LaneletPaths
std::vector< LaneletPath > LaneletPaths
Definition: Forward.h:47
lanelet::LineString2d
lanelet::routing::internal::RoutingGraphBuilder::build
RoutingGraphUPtr build(const LaneletMapLayers &laneletMapLayers)
Definition: RoutingGraphBuilder.cpp:94
lanelet::utils::transform
auto transform(Container &&c, Func f)
lanelet::LaneletMap
Optional
boost::optional< T > Optional
lanelet::routing::DebugMapBuilder::lineStringMap_
std::unordered_map< LaneletOrAreaPair, LineString3d > lineStringMap_
Definition: RoutingGraph.cpp:840
numLaneChanges
size_t numLaneChanges
Definition: RoutingGraph.cpp:58
Route.h
lanelet::routing::internal::FilteredRoutingGraph
FilteredGraphT< GraphType > FilteredRoutingGraph
Definition: Graph.h:59
lanelet::ConstLaneletOrArea::id
Id id() const
lanelet::routing::PossiblePathsParams
Controls the behaviour of the different possible path algorithms in RoutingGraph.
Definition: RoutingGraph.h:50
lanelet::routing::DebugMapBuilder::addPoint
void addPoint(const ConstLaneletOrArea &point)
Definition: RoutingGraph.cpp:817
lanelet::routing::allowedRelationsfromConfiguration
RelationType allowedRelationsfromConfiguration(bool includeAdjacent, bool includeConflicting)
Helper function to slim down getDebugLaneletMap.
Definition: RoutingGraph.cpp:761
lanelet::routing::RoutingGraph::Errors
std::vector< std::string > Errors
For the checkValidity function.
Definition: RoutingGraph.h:71
vertexId
uint32_t vertexId
Definition: RoutingGraph.cpp:56
lanelet::routing::createLineString
LineString3d createLineString(const Point2d &from, const Point2d &to, RelationType relation, double routingCost)
Definition: RoutingGraph.cpp:774
lanelet::routing::RoutingGraphUPtr
std::unique_ptr< RoutingGraph > RoutingGraphUPtr
Definition: Forward.h:26
lanelet::routing::DebugMapBuilder::graph_
FilteredRoutingGraph graph_
Definition: RoutingGraph.cpp:839
lanelet::routing::internal::get
SparseColorMap::value_type get(const SparseColorMap &map, LaneletVertexId key)
Definition: GraphUtils.h:304
lanelet::routing::LaneletRelations
std::vector< LaneletRelation > LaneletRelations
Definition: Forward.h:34
lanelet::routing::LaneletRelation
Represents the relation of a lanelet to another lanelet.
Definition: Types.h:34
lanelet::routing::internal::LaneletOrAreaToVertex
std::unordered_map< ConstLaneletOrArea, std::uint32_t > LaneletOrAreaToVertex
Definition: Graph.h:102
lanelet::routing::RoutingCostId
uint16_t RoutingCostId
Definition: Forward.h:44
lanelet::routing::LaneletOrAreaPaths
std::vector< LaneletOrAreaPath > LaneletOrAreaPaths
Definition: Forward.h:49
GraphUtils.h
laneletsOrAreas
ConstLaneletOrAreas laneletsOrAreas
Definition: RoutingGraph.cpp:59
lanelet::routing::internal::DijkstraSearchMap
std::map< VertexT, VertexState > DijkstraSearchMap
Definition: ShortestPath.h:33
TrafficRules
totalDistance
double totalDistance
Definition: RoutingGraph.cpp:57
lanelet::routing::internal::LaneletVertexId
GraphTraits::vertex_descriptor LaneletVertexId
Definition: GraphUtils.h:12
left
BasicPolygon3d left
Definition: LaneletPath.cpp:98
c1
Cost1 c1
Definition: RoutingGraph.cpp:234
TrafficRules.h
Graph.h
RoutingGraphVisualization.h
c
double c
Definition: RoutingGraph.cpp:260
lanelet::RoutingGraphError
Thrown when an there's an error in the routing graph. It will feature further information.
Definition: Exceptions.h:19
lanelet::routing::internal::DijkstraStyleSearch
Definition: ShortestPath.h:59
lanelet::routing::LaneletVisitFunction
std::function< bool(const LaneletVisitInformation &)> LaneletVisitFunction
Definition: Types.h:30
lanelet::routing::DebugMapBuilder
Definition: RoutingGraph.cpp:784
leftOf
bool leftOf(const ConstLanelet &right, const ConstArea &left)
lanelet::LaneletSubmap
lanelet::routing::RoutingGraph
Main class of the routing module that holds routing information and can be queried....
Definition: RoutingGraph.h:69
lanelet::routing::DebugMapBuilder::addEdge
void addEdge(const ConstLaneletOrArea &from, const ConstLaneletOrArea &to, internal::EdgeInfo edge)
Definition: RoutingGraph.cpp:824
lanelet::routing::internal::EdgeInfo::relation
RelationType relation
Relation between the two lanelets. E.g. SUCCESSOR or CONFLICTING.
Definition: Graph.h:39
lanelet::LaneletSubmapConstPtr
std::shared_ptr< const LaneletSubmap > LaneletSubmapConstPtr
lanelet::ConstLanelet
lanelet::routing::RoutingGraph::Configuration
std::map< std::string, Attribute > Configuration
Definition: RoutingGraph.h:72
Primitive< ConstLineString3d >::setAttribute
void setAttribute(AttributeName name, const Attribute &attribute)
Forward.h
lanelet::routing::internal::RoutingGraphBuilder
Definition: RoutingGraphBuilder.h:15
lanelet::routing::DebugMapBuilder::DebugMapBuilder
DebugMapBuilder(const FilteredRoutingGraph &graph)
Definition: RoutingGraph.cpp:787
lanelet::routing::allRelations
constexpr RelationType allRelations()
Definition: Forward.h:69
lanelet::LineString3d
ll
LaneletAdjacency ll
Definition: LaneletPath.cpp:88
rightOf
bool rightOf(const ConstLanelet &left, const ConstArea &area)
graph_
const OriginalGraph * graph_
Definition: RouteBuilder.cpp:366
lanelet::routing::LaneletOrAreaVisitInformation
This object carries the required information for the graph neighbourhood search.
Definition: Types.h:13
ConstLanelets
std::vector< ConstLanelet > ConstLanelets
Exceptions.h
lanelet::routing::PossiblePathsParams::routingCostId
RoutingCostId routingCostId
the routing cost module to be used for the costs
Definition: RoutingGraph.h:53
lanelet::routing::internal::GraphType
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, VertexInfo, EdgeInfo > GraphType
General graph type definitions.
Definition: Graph.h:43
lanelet::InvalidInputError
lanelet::routing::internal::EdgeInfo
Internal information of an edge in the graph.
Definition: Graph.h:36


lanelet2_routing
Author(s): Matthias Mayr
autogenerated on Sun Oct 27 2024 02:27:49