test_routing_graph_container.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
3 
7 #include "test_routing_map.h"
8 
9 using namespace lanelet;
10 using namespace lanelet::routing;
11 using namespace lanelet::routing::tests;
12 
14  public:
16  std::vector<RoutingGraphConstPtr> graphs{testData.vehicleGraph, testData.pedestrianGraph};
17  container = std::make_unique<RoutingGraphContainer>(graphs);
18  }
19 
21 };
22 
24  public:
25  void getAndCheckRoute(const RoutingGraphConstPtr& graph, Id from, Id to, routing::RoutingCostId routingCostId = 0) {
26  ASSERT_NE(graph->passableSubmap()->laneletLayer.find(from), graph->passableSubmap()->laneletLayer.end());
27  ConstLanelet fromLanelet{*graph->passableSubmap()->laneletLayer.find(from)};
28  ASSERT_NE(graph->passableSubmap()->laneletLayer.find(to), graph->passableSubmap()->laneletLayer.end());
29  ConstLanelet toLanelet{*graph->passableSubmap()->laneletLayer.find(to)};
30  Optional<Route> tempRoute = graph->getRoute(fromLanelet, toLanelet, routingCostId);
31  ASSERT_TRUE(!!tempRoute);
32  route = std::make_unique<Route>(std::move(*tempRoute));
33  }
34 
35  std::unique_ptr<Route> route;
36 };
37 
38 TEST_F(RoutingGraphContainerTest, ConflictingInGraph) { // NOLINT
39  ConstLanelet pedestrianLanelet{*laneletMap->laneletLayer.find(2031)};
40  ConstLanelets conflictingVehicle{container->conflictingInGraph(pedestrianLanelet, 0)};
41  ASSERT_EQ(conflictingVehicle.size(), 1ul);
42  EXPECT_EQ(conflictingVehicle[0], *laneletMap->laneletLayer.find(2020));
43 
44  ConstLanelets conflictingPedestrian{container->conflictingInGraph(pedestrianLanelet, 1)};
45  EXPECT_EQ(conflictingPedestrian.size(), 0ul);
46 }
47 
48 TEST_F(RoutingGraphContainerTest, ConflictingInGraphs) { // NOLINT
49  ConstLanelet pedestrianLanelet{*laneletMap->laneletLayer.find(2031)};
50  RoutingGraphContainer::ConflictingInGraphs result{container->conflictingInGraphs(pedestrianLanelet)};
51  ASSERT_EQ(result.size(), 2ul);
52 
53  ConstLanelets conflictingVehicle{result[0].second};
54  ASSERT_EQ(conflictingVehicle.size(), 1ul);
55  EXPECT_EQ(conflictingVehicle[0], *laneletMap->laneletLayer.find(2020));
56 
57  ConstLanelets conflictingPedestrian{result[1].second};
58  EXPECT_EQ(conflictingPedestrian.size(), 0ul);
59 }
60 
61 TEST_F(RouteRoutingGraphContainerTest, ConflictingOfRouteInGraph) { // NOLINT
62  getAndCheckRoute(container->routingGraphs()[0], 2017, 2024);
63  ConstLanelets conflictingVehicle{container->conflictingOfRouteInGraph(route.get(), 0)};
64  EXPECT_EQ(conflictingVehicle.size(), 2ul);
65 
66  ConstLanelets conflictingPedestrian{container->conflictingOfRouteInGraph(route.get(), 1)};
67  EXPECT_EQ(conflictingPedestrian.size(), 1ul);
68 }
69 
70 TEST_F(RouteRoutingGraphContainerTest, ConflictingOfRouteInGraphs) { // NOLINT
71  getAndCheckRoute(container->routingGraphs()[0], 2017, 2024);
72  RoutingGraphContainer::ConflictingInGraphs result{container->conflictingOfRouteInGraphs(route.get(), 0)};
73  ASSERT_EQ(result.size(), 2ul);
74 
75  ConstLanelets conflictingVehicle{result[0].second};
76  EXPECT_EQ(conflictingVehicle.size(), 2ul);
77 
78  ConstLanelets conflictingPedestrian{result[1].second};
79  EXPECT_EQ(conflictingPedestrian.size(), 1ul);
80 }
81 
82 TEST_F(RoutingGraphContainerTest, ConflictingInGraph3dFits) { // NOLINT
83  ConstLanelet bridgeLanelet{*laneletMap->laneletLayer.find(2032)};
84  ConstLanelets conflictingVehicle{container->conflictingInGraph(bridgeLanelet, 0, 2.)};
85  EXPECT_EQ(conflictingVehicle.size(), 0ul);
86 
87  conflictingVehicle = container->conflictingInGraph(lanelets.find(2005)->second, 0, 2.);
88  ASSERT_EQ(conflictingVehicle.size(), 1ul);
89  EXPECT_TRUE(conflictingVehicle.front() == lanelets.find(2006)->second);
90 
91  conflictingVehicle = container->conflictingInGraph(lanelets.find(2006)->second, 0, 2.);
92  ASSERT_EQ(conflictingVehicle.size(), 1ul);
93  EXPECT_TRUE(conflictingVehicle.front() == lanelets.find(2005)->second);
94 
95  ConstLanelets conflictingPedestrian{container->conflictingInGraph(bridgeLanelet, 1, 2.)};
96  EXPECT_EQ(conflictingPedestrian.size(), 0ul);
97 }
98 
99 TEST_F(RoutingGraphContainerTest, ConflictingInGraph3dDoesntFit) { // NOLINT
100  ConstLanelet bridgeLanelet{*laneletMap->laneletLayer.find(2032)};
101  ConstLanelets conflictingVehicle{container->conflictingInGraph(bridgeLanelet, 0, 4.)};
102  EXPECT_EQ(conflictingVehicle.size(), 2ul);
103 
104  conflictingVehicle = container->conflictingInGraph(lanelets.find(2005)->second, 0, 4.);
105  EXPECT_EQ(conflictingVehicle.size(), 2ul);
106 
107  conflictingVehicle = container->conflictingInGraph(lanelets.find(2006)->second, 0, 4.);
108  EXPECT_EQ(conflictingVehicle.size(), 2ul);
109 
110  ConstLanelets conflictingPedestrian{container->conflictingInGraph(bridgeLanelet, 1, 4.)};
111  EXPECT_EQ(conflictingPedestrian.size(), 0ul);
112 }
TEST_F
TEST_F(RoutingGraphContainerTest, ConflictingInGraph)
Definition: test_routing_graph_container.cpp:38
RoutingGraph.h
lanelet::routing::tests::RoutingGraphTest
Definition: test_routing_map.h:484
LaneletMap.h
lanelet
RouteRoutingGraphContainerTest::getAndCheckRoute
void getAndCheckRoute(const RoutingGraphConstPtr &graph, Id from, Id to, routing::RoutingCostId routingCostId=0)
Definition: test_routing_graph_container.cpp:25
RoutingGraphContainer.h
Id
int64_t Id
lanelet::routing::RoutingGraphContainer::ConflictingInGraphs
std::vector< ConflictingInGraph > ConflictingInGraphs
Definition: RoutingGraphContainer.h:23
lanelet::routing::tests
Definition: test_routing_map.h:17
lanelet::routing
Definition: Forward.h:11
RoutingGraphContainerTest::RoutingGraphContainerTest
RoutingGraphContainerTest()
Definition: test_routing_graph_container.cpp:15
RouteRoutingGraphContainerTest::route
std::unique_ptr< Route > route
Definition: test_routing_graph_container.cpp:35
Optional
boost::optional< T > Optional
RoutingGraphContainerTest
Definition: test_routing_graph_container.cpp:13
lanelet::routing::RoutingCostId
uint16_t RoutingCostId
Definition: Forward.h:44
RouteRoutingGraphContainerTest
Definition: test_routing_graph_container.cpp:23
RoutingGraphContainerTest::container
RoutingGraphContainerUPtr container
Definition: test_routing_graph_container.cpp:20
lanelet::ConstLanelet
lanelet::routing::RoutingGraphConstPtr
std::shared_ptr< const RoutingGraph > RoutingGraphConstPtr
Definition: Forward.h:27
Forward.h
test_routing_map.h
lanelet::routing::RoutingGraphContainerUPtr
std::unique_ptr< RoutingGraphContainer > RoutingGraphContainerUPtr
Definition: Forward.h:30
ConstLanelets
std::vector< ConstLanelet > ConstLanelets


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