Skip to content

Commit d192149

Browse files
committed
limit the path size and record time to calculate lanelets
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent 8acbf18 commit d192149

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

planning/behavior_velocity_out_of_lane_module/src/scene_out_of_lane.cpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include <lanelet2_core/geometry/LaneletMap.h>
3838

39+
#include <algorithm>
3940
#include <memory>
4041
#include <string>
4142
#include <utility>
@@ -66,7 +67,16 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
6667
ego_data.pose = planner_data_->current_odometry->pose;
6768
ego_data.path.points = path->points;
6869
ego_data.first_path_idx =
69-
motion_utils::findNearestSegmentIndex(ego_data.path.points, ego_data.pose.position);
70+
motion_utils::findNearestSegmentIndex(path->points, ego_data.pose.position);
71+
auto last_idx = ego_data.first_path_idx;
72+
auto length = 0.0;
73+
while (length < std::max(params_.slow_dist_threshold, params_.stop_dist_threshold) &&
74+
last_idx + 1 < path->points.size()) {
75+
length += tier4_autoware_utils::calcDistance2d(
76+
path->points[last_idx].point, path->points[last_idx + 1].point);
77+
++last_idx;
78+
}
79+
ego_data.path.points.resize(last_idx + 1);
7080
motion_utils::removeOverlapPoints(ego_data.path.points);
7181
ego_data.velocity = planner_data_->current_velocity->twist.linear.x;
7282
ego_data.max_decel = -planner_data_->max_stop_acceleration_threshold;
@@ -75,12 +85,14 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
7585
const auto path_footprints = calculate_path_footprints(ego_data, params_);
7686
const auto calculate_path_footprints_us = stopwatch.toc("calculate_path_footprints");
7787
// Calculate lanelets to ignore and consider
88+
stopwatch.tic("calculate_lanelets");
7889
const auto path_lanelets =
7990
calculate_path_lanelets(ego_data, *planner_data_->route_handler_, current_ego_footprint);
8091
const auto ignored_lanelets =
8192
calculate_ignored_lanelets(ego_data, path_lanelets, *planner_data_->route_handler_, params_);
8293
const auto other_lanelets = calculate_other_lanelets(
8394
ego_data, path_lanelets, ignored_lanelets, *planner_data_->route_handler_, params_);
95+
const auto calculate_lanelets_us = stopwatch.toc("calculate_lanelets");
8496

8597
debug_data_.footprints = path_footprints;
8698
debug_data_.path_lanelets = path_lanelets;
@@ -182,13 +194,15 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
182194
RCLCPP_DEBUG(
183195
logger_,
184196
"Total time = %2.2fus\n"
197+
"\tcalculate_lanelets = %2.0fus\n"
185198
"\tcalculate_path_footprints = %2.0fus\n"
186199
"\tcalculate_overlapping_ranges = %2.0fus\n"
187200
"\tcalculate_decisions = %2.0fus\n"
188201
"\tcalc_slowdown_points = %2.0fus\n"
189202
"\tinsert_slowdown_points = %2.0fus\n",
190-
total_time_us, calculate_path_footprints_us, calculate_overlapping_ranges_us,
191-
calculate_decisions_us, calc_slowdown_points_us, insert_slowdown_points_us);
203+
total_time_us, calculate_lanelets_us, calculate_path_footprints_us,
204+
calculate_overlapping_ranges_us, calculate_decisions_us, calc_slowdown_points_us,
205+
insert_slowdown_points_us);
192206
return true;
193207
}
194208

0 commit comments

Comments
 (0)