Skip to content

Commit 63b9769

Browse files
committed
improve calculate_trajectory_lanelets performance
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent 5d79c9a commit 63b9769

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

planning/motion_velocity_planner/autoware_motion_velocity_out_of_lane_module/src/lanelets_selection.cpp

+9-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#include <autoware/universe_utils/geometry/geometry.hpp>
1818

19+
#include <boost/geometry/algorithms/detail/disjoint/interface.hpp>
20+
21+
#include <lanelet2_core/geometry/BoundingBox.h>
1922
#include <lanelet2_core/geometry/LaneletMap.h>
2023
#include <lanelet2_routing/RoutingGraph.h>
2124

@@ -71,10 +74,12 @@ lanelet::ConstLanelets calculate_trajectory_lanelets(
7174
lanelet::BasicLineString2d trajectory_ls;
7275
for (const auto & p : ego_data.trajectory_points)
7376
trajectory_ls.emplace_back(p.pose.position.x, p.pose.position.y);
74-
for (const auto & dist_lanelet :
75-
lanelet::geometry::findWithin2d(lanelet_map_ptr->laneletLayer, trajectory_ls)) {
76-
if (!contains_lanelet(trajectory_lanelets, dist_lanelet.second.id()))
77-
trajectory_lanelets.push_back(dist_lanelet.second);
77+
const auto candidates =
78+
lanelet_map_ptr->laneletLayer.search(lanelet::geometry::boundingBox2d(trajectory_ls));
79+
for (const auto & ll : candidates) {
80+
if (!boost::geometry::disjoint(trajectory_ls, ll.polygon2d().basicPolygon())) {
81+
trajectory_lanelets.push_back(ll);
82+
}
7883
}
7984
const auto missing_lanelets =
8085
get_missing_lane_change_lanelets(trajectory_lanelets, route_handler);

0 commit comments

Comments
 (0)