36
36
37
37
#include < lanelet2_core/geometry/LaneletMap.h>
38
38
39
+ #include < algorithm>
39
40
#include < memory>
40
41
#include < string>
41
42
#include < utility>
@@ -66,7 +67,16 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
66
67
ego_data.pose = planner_data_->current_odometry ->pose ;
67
68
ego_data.path .points = path->points ;
68
69
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 );
70
80
motion_utils::removeOverlapPoints (ego_data.path .points );
71
81
ego_data.velocity = planner_data_->current_velocity ->twist .linear .x ;
72
82
ego_data.max_decel = -planner_data_->max_stop_acceleration_threshold ;
@@ -75,12 +85,14 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
75
85
const auto path_footprints = calculate_path_footprints (ego_data, params_);
76
86
const auto calculate_path_footprints_us = stopwatch.toc (" calculate_path_footprints" );
77
87
// Calculate lanelets to ignore and consider
88
+ stopwatch.tic (" calculate_lanelets" );
78
89
const auto path_lanelets =
79
90
calculate_path_lanelets (ego_data, *planner_data_->route_handler_ , current_ego_footprint);
80
91
const auto ignored_lanelets =
81
92
calculate_ignored_lanelets (ego_data, path_lanelets, *planner_data_->route_handler_ , params_);
82
93
const auto other_lanelets = calculate_other_lanelets (
83
94
ego_data, path_lanelets, ignored_lanelets, *planner_data_->route_handler_ , params_);
95
+ const auto calculate_lanelets_us = stopwatch.toc (" calculate_lanelets" );
84
96
85
97
debug_data_.footprints = path_footprints;
86
98
debug_data_.path_lanelets = path_lanelets;
@@ -182,13 +194,15 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
182
194
RCLCPP_DEBUG (
183
195
logger_,
184
196
" Total time = %2.2fus\n "
197
+ " \t calculate_lanelets = %2.0fus\n "
185
198
" \t calculate_path_footprints = %2.0fus\n "
186
199
" \t calculate_overlapping_ranges = %2.0fus\n "
187
200
" \t calculate_decisions = %2.0fus\n "
188
201
" \t calc_slowdown_points = %2.0fus\n "
189
202
" \t insert_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);
192
206
return true ;
193
207
}
194
208
0 commit comments