Skip to content

Commit 905f170

Browse files
committed
simplify get_missing_lane_change_lanelets function
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent 1e1011e commit 905f170

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

planning/behavior_velocity_out_of_lane_module/src/lanelets_selection.cpp

+14-10
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,21 @@ lanelet::ConstLanelets get_missing_lane_change_lanelets(
4242
lanelet::ConstLanelets adjacents;
4343
lanelet::ConstLanelets consecutives;
4444
for (const auto & ll : path_lanelets) {
45-
for (const auto & consecutive : consecutive_lanelets(route_handler, ll))
46-
if (!contains_lanelet(consecutives, consecutive.id())) consecutives.push_back(consecutive);
47-
for (const auto & adjacent : routing_graph.besides(ll))
48-
if (!contains_lanelet(adjacents, adjacent.id())) adjacents.push_back(adjacent);
49-
}
50-
for (const auto & ll : adjacents) {
51-
if (
52-
!contains_lanelet(missing_lane_change_lanelets, ll.id()) &&
53-
!contains_lanelet(path_lanelets, ll.id()) && contains_lanelet(consecutives, ll.id()))
54-
missing_lane_change_lanelets.push_back(ll);
45+
const auto consecutives_of_ll = consecutive_lanelets(route_handler, ll);
46+
std::copy_if(
47+
consecutives_of_ll.begin(), consecutives_of_ll.end(), std::back_inserter(consecutives),
48+
[&](const auto & l) { return !contains_lanelet(consecutives, l.id()); });
49+
const auto adjacents_of_ll = routing_graph.besides(ll);
50+
std::copy_if(
51+
adjacents_of_ll.begin(), adjacents_of_ll.end(), std::back_inserter(adjacents),
52+
[&](const auto & l) { return !contains_lanelet(adjacents, l.id()); });
5553
}
54+
std::copy_if(
55+
adjacents.begin(), adjacents.end(), std::back_inserter(missing_lane_change_lanelets),
56+
[&](const auto & l) {
57+
return !contains_lanelet(missing_lane_change_lanelets, l.id()) &&
58+
!contains_lanelet(path_lanelets, l.id()) && contains_lanelet(consecutives, l.id());
59+
});
5660
return missing_lane_change_lanelets;
5761
}
5862

0 commit comments

Comments
 (0)