20#include <lanelet2_routing/RoutingGraph.h>
21#include <lanelet2_routing/internal/Graph.h>
44 autoware_lanelet2_msgs::msg::RoutingGraph
routingGraphToMsg(
const std::string& participant) {
47 autoware_lanelet2_msgs::msg::RoutingGraph msg;
50 msg.num_unique_routing_cost_ids = this->graph_->numRoutingCosts();
51 msg.participant_type = participant;
56 auto underlying_graph = this->graph_->get();
59 boost::graph_traits<lanelet::routing::internal::GraphType>::vertex_iterator vi, vi_end;
61 for(boost::tie(vi, vi_end) = boost::vertices(underlying_graph); vi != vi_end; ++vi) {
63 autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges vertex_and_edges;
65 lanelet::routing::internal::GraphType::vertex_descriptor source = *vi;
68 boost::graph_traits<lanelet::routing::internal::GraphType>::out_edge_iterator ei, ei_end;
69 for(boost::tie(ei, ei_end) = boost::out_edges(source, underlying_graph); ei != ei_end; ++ei) {
71 lanelet::routing::internal::GraphType::edge_descriptor edge = *ei;
72 lanelet::routing::internal::GraphType::vertex_descriptor target = boost::target(edge, underlying_graph);
76 vertex_and_edges.lanelet_or_area_ids.push_back(underlying_graph[target].laneletOrArea.id());
78 vertex_and_edges.edge_routing_costs.push_back(underlying_graph[edge].routingCost);
79 vertex_and_edges.edge_routing_cost_source_ids.push_back(underlying_graph[edge].costId);
82 switch(underlying_graph[edge].relation) {
83 case lanelet::routing::RelationType::Successor:
84 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_SUCCESSOR;
break;
86 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_LEFT;
break;
88 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_RIGHT;
break;
89 case lanelet::routing::RelationType::AdjacentLeft:
90 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_ADJACENT_LEFT;
break;
91 case lanelet::routing::RelationType::AdjacentRight:
92 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_ADJACENT_RIGHT;
break;
93 case lanelet::routing::RelationType::Conflicting:
94 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_CONFLICTING;
break;
95 case lanelet::routing::RelationType::Area:
96 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_AREA;
break;
98 relation = autoware_lanelet2_msgs::msg::RoutingGraphVertexAndEdges::RELATION_NONE;
break;
101 vertex_and_edges.edge_relations.push_back(relation);
105 vertex_and_edges.lanelet_or_area = underlying_graph[source].laneletOrArea.id();
108 if (underlying_graph[source].laneletOrArea.isLanelet()) {
109 msg.lanelet_vertices.push_back(vertex_and_edges);
112 msg.area_vertices.push_back(vertex_and_edges);
This class serves as a method of exposing the internal protected members of the lanelet2 RoutingGraph...
autoware_lanelet2_msgs::msg::RoutingGraph routingGraphToMsg(const std::string &participant)
Returns a ROS message version of this RoutingGraph. This is done by accessing protected data members ...