@@ -56,6 +56,19 @@ OutOfLaneModule::OutOfLaneModule(
56
56
velocity_factor_.init (PlanningBehavior::UNKNOWN);
57
57
}
58
58
59
+ size_t calculate_index_ahead (
60
+ const std::vector<PathPointWithLaneId> & points, const size_t start, const double dist_ahead)
61
+ {
62
+ auto last_idx = start;
63
+ auto length = 0.0 ;
64
+ while (length < dist_ahead && last_idx + 1 < points.size ()) {
65
+ length +=
66
+ tier4_autoware_utils::calcDistance2d (points[last_idx].point , points[last_idx + 1 ].point );
67
+ ++last_idx;
68
+ }
69
+ return last_idx;
70
+ }
71
+
59
72
bool OutOfLaneModule::modifyPathVelocity (PathWithLaneId * path, StopReason * stop_reason)
60
73
{
61
74
debug_data_.reset_data ();
@@ -68,15 +81,9 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
68
81
ego_data.path .points = path->points ;
69
82
ego_data.first_path_idx =
70
83
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 );
84
+ ego_data.path .points .resize (calculate_index_ahead (
85
+ path->points , ego_data.first_path_idx ,
86
+ std::max (params_.slow_dist_threshold , params_.stop_dist_threshold )));
80
87
motion_utils::removeOverlapPoints (ego_data.path .points );
81
88
ego_data.velocity = planner_data_->current_velocity ->twist .linear .x ;
82
89
ego_data.max_decel = -planner_data_->max_stop_acceleration_threshold ;
@@ -86,8 +93,7 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
86
93
const auto calculate_path_footprints_us = stopwatch.toc (" calculate_path_footprints" );
87
94
// Calculate lanelets to ignore and consider
88
95
stopwatch.tic (" calculate_lanelets" );
89
- const auto path_lanelets =
90
- calculate_path_lanelets (ego_data, *planner_data_->route_handler_ , current_ego_footprint);
96
+ const auto path_lanelets = calculate_path_lanelets (ego_data, *planner_data_->route_handler_ );
91
97
const auto ignored_lanelets =
92
98
calculate_ignored_lanelets (ego_data, path_lanelets, *planner_data_->route_handler_ , params_);
93
99
const auto other_lanelets = calculate_other_lanelets (
@@ -191,7 +197,7 @@ bool OutOfLaneModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
191
197
debug_data_.ranges = inputs.ranges ;
192
198
193
199
const auto total_time_us = stopwatch.toc ();
194
- RCLCPP_DEBUG (
200
+ RCLCPP_WARN (
195
201
logger_,
196
202
" Total time = %2.2fus\n "
197
203
" \t calculate_lanelets = %2.0fus\n "
0 commit comments