@@ -68,11 +68,11 @@ BlindSpotModule::BlindSpotModule(
68
68
const rclcpp::Clock::SharedPtr clock)
69
69
: SceneModuleInterface(module_id, logger, clock),
70
70
lane_id_ (lane_id),
71
+ planner_param_{planner_param},
71
72
turn_direction_ (TurnDirection::INVALID),
72
73
is_over_pass_judge_line_(false )
73
74
{
74
75
velocity_factor_.init (PlanningBehavior::REAR_CHECK);
75
- planner_param_ = planner_param;
76
76
77
77
const auto & assigned_lanelet =
78
78
planner_data->route_handler_ ->getLaneletMapPtr ()->laneletLayer .get (lane_id);
@@ -91,7 +91,7 @@ bool BlindSpotModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
91
91
92
92
const auto input_path = *path;
93
93
94
- StateMachine::State current_state = state_machine_.getState ();
94
+ const auto current_state = state_machine_.getState ();
95
95
RCLCPP_DEBUG (
96
96
logger_, " lane_id = %ld, state = %s" , lane_id_, StateMachine::toString (current_state).c_str ());
97
97
@@ -110,12 +110,8 @@ bool BlindSpotModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
110
110
}
111
111
const auto & interpolated_path_info = interpolated_path_info_opt.value ();
112
112
113
- if (!first_conflicting_lanelet_) {
114
- first_conflicting_lanelet_ = getFirstConflictingLanelet (interpolated_path_info);
115
- }
116
- if (!first_conflicting_lanelet_) {
117
- RCLCPP_DEBUG (logger_, " [BlindSpotModule::run] failed to find first conflicting lanelet" );
118
- return false ;
113
+ if (!sibling_straight_lanelet_) {
114
+ sibling_straight_lanelet_ = getSiblingStraightLanelet ();
119
115
}
120
116
121
117
const auto stoplines_idx_opt = generateStopLine (interpolated_path_info, path);
@@ -263,70 +259,37 @@ std::optional<InterpolatedPathInfo> BlindSpotModule::generateInterpolatedPathInf
263
259
return interpolated_path_info;
264
260
}
265
261
266
- std::optional<lanelet::ConstLanelet> BlindSpotModule::getFirstConflictingLanelet (
267
- const InterpolatedPathInfo & interpolated_path_info) const
262
+ std::optional<lanelet::ConstLanelet> BlindSpotModule::getSiblingStraightLanelet () const
268
263
{
269
- if (!interpolated_path_info.lane_id_interval ) {
270
- return std::nullopt;
271
- }
272
-
273
264
const auto lanelet_map_ptr = planner_data_->route_handler_ ->getLaneletMapPtr ();
274
265
const auto routing_graph_ptr = planner_data_->route_handler_ ->getRoutingGraphPtr ();
275
266
276
267
const auto assigned_lane = lanelet_map_ptr->laneletLayer .get (lane_id_);
277
- const auto conflicting_lanes =
278
- lanelet::utils::getConflictingLanelets (routing_graph_ptr, assigned_lane);
279
- lanelet::ConstLanelets conflicting_ex_sibling_lanes{};
280
- lanelet::ConstLanelets sibling_lanes{};
281
268
for (const auto & prev : routing_graph_ptr->previous (assigned_lane)) {
282
269
for (const auto & following : routing_graph_ptr->following (prev)) {
283
- if (!lanelet::utils::contains (sibling_lanes, following)) {
284
- sibling_lanes.push_back (following);
285
- }
286
- }
287
- }
288
- for (const auto & conflicting : conflicting_lanes) {
289
- if (!lanelet::utils::contains (sibling_lanes, conflicting)) {
290
- conflicting_ex_sibling_lanes.push_back (conflicting);
291
- }
292
- }
293
-
294
- const auto [lane_start, lane_end] = interpolated_path_info.lane_id_interval .value ();
295
- const size_t vehicle_length_idx = static_cast <size_t >(
296
- planner_data_->vehicle_info_ .max_longitudinal_offset_m / interpolated_path_info.ds );
297
- const size_t start =
298
- static_cast <size_t >(std::max<int >(0 , static_cast <int >(lane_start) - vehicle_length_idx));
299
- const auto local_footprint = planner_data_->vehicle_info_ .createFootprint (0.0 , 0.0 );
300
- for (size_t i = start; i <= lane_end; ++i) {
301
- const auto & pose = interpolated_path_info.path .points .at (i).point .pose ;
302
- const auto path_footprint = tier4_autoware_utils::transformVector (
303
- local_footprint, tier4_autoware_utils::pose2transform (pose));
304
- for (const auto & conflicting : conflicting_ex_sibling_lanes) {
305
- const auto area2d = conflicting.polygon2d ().basicPolygon ();
306
- const bool is_in_polygon = bg::intersects (area2d, path_footprint);
307
- if (is_in_polygon) {
308
- return std::make_optional<lanelet::ConstLanelet>(conflicting);
270
+ if (std::string (following.attributeOr (" turn_direction" , " else" )) == " straight" ) {
271
+ return following;
309
272
}
310
273
}
311
274
}
312
275
return std::nullopt;
313
276
}
314
277
315
- static std::optional<size_t > getFirstPointInsidePolygonByFootprint (
316
- const lanelet::CompoundPolygon2d & polygon , const InterpolatedPathInfo & interpolated_path_info,
278
+ static std::optional<size_t > getFirstPointIntersectsLineByFootprint (
279
+ const lanelet::ConstLineString2d & line , const InterpolatedPathInfo & interpolated_path_info,
317
280
const tier4_autoware_utils::LinearRing2d & footprint, const double vehicle_length)
318
281
{
319
282
const auto & path_ip = interpolated_path_info.path ;
320
283
const auto [lane_start, lane_end] = interpolated_path_info.lane_id_interval .value ();
321
284
const size_t vehicle_length_idx = static_cast <size_t >(vehicle_length / interpolated_path_info.ds );
322
285
const size_t start =
323
286
static_cast <size_t >(std::max<int >(0 , static_cast <int >(lane_start) - vehicle_length_idx));
324
- const auto area_2d = polygon. basicPolygon ();
287
+ const auto line2d = line. basicLineString ();
325
288
for (auto i = start; i <= lane_end; ++i) {
326
289
const auto & base_pose = path_ip.points .at (i).point .pose ;
327
290
const auto path_footprint = tier4_autoware_utils::transformVector (
328
291
footprint, tier4_autoware_utils::pose2transform (base_pose));
329
- if (bg::intersects (path_footprint, area_2d )) {
292
+ if (bg::intersects (path_footprint, line2d )) {
330
293
return std::make_optional<size_t >(i);
331
294
}
332
295
}
@@ -389,21 +352,47 @@ std::optional<std::pair<size_t, size_t>> BlindSpotModule::generateStopLine(
389
352
const int margin_idx_dist =
390
353
std::ceil (planner_param_.stop_line_margin / interpolated_path_info.ds );
391
354
392
- const auto first_conflict_idx_ip_opt = getFirstPointInsidePolygonByFootprint (
393
- first_conflicting_lanelet_.value ().polygon2d (), interpolated_path_info,
394
- planner_data_->vehicle_info_ .createFootprint (0.0 , 0.0 ),
395
- planner_data_->vehicle_info_ .max_longitudinal_offset_m );
396
- if (!first_conflict_idx_ip_opt) {
397
- return std::nullopt;
398
- }
399
- const int first_conflict_idx_ip = static_cast <int >(first_conflict_idx_ip_opt.value ());
355
+ const auto & path_ip = interpolated_path_info.path ;
400
356
401
- const size_t stop_idx_default_ip =
402
- static_cast <size_t >(std::max (first_conflict_idx_ip - margin_idx_dist, 0 ));
403
- const size_t stop_idx_critical_ip = static_cast <size_t >(first_conflict_idx_ip);
357
+ size_t stop_idx_default_ip = 0 ;
358
+ size_t stop_idx_critical_ip = 0 ;
359
+ if (sibling_straight_lanelet_) {
360
+ const auto sibling_straight_lanelet = sibling_straight_lanelet_.value ();
361
+ const auto turn_boundary_line = turn_direction_ == TurnDirection::LEFT
362
+ ? sibling_straight_lanelet.leftBound ()
363
+ : sibling_straight_lanelet.rightBound ();
364
+ const auto first_conflict_idx_ip_opt = getFirstPointIntersectsLineByFootprint (
365
+ lanelet::utils::to2D (turn_boundary_line), interpolated_path_info,
366
+ planner_data_->vehicle_info_ .createFootprint (0.0 , 0.0 ),
367
+ planner_data_->vehicle_info_ .max_longitudinal_offset_m );
368
+ if (!first_conflict_idx_ip_opt) {
369
+ return std::nullopt;
370
+ }
371
+ const int first_conflict_idx_ip = static_cast <int >(first_conflict_idx_ip_opt.value ());
372
+
373
+ stop_idx_default_ip = static_cast <size_t >(std::max (first_conflict_idx_ip - margin_idx_dist, 0 ));
374
+ stop_idx_critical_ip = static_cast <size_t >(first_conflict_idx_ip);
375
+ } else {
376
+ // the entry point of the assigned lane
377
+ const auto & assigned_lanelet =
378
+ planner_data_->route_handler_ ->getLaneletMapPtr ()->laneletLayer .get (lane_id_);
379
+ const auto left_pt = assigned_lanelet.leftBound ().front ().basicPoint ();
380
+ const auto right_pt = assigned_lanelet.rightBound ().front ().basicPoint ();
381
+ const auto mid_pt = (left_pt + right_pt) / 2.0 ;
382
+ const geometry_msgs::msg::Point mid_point =
383
+ geometry_msgs::build<geometry_msgs::msg::Point >().x (mid_pt.x ()).y (mid_pt.y ()).z (mid_pt.z ());
384
+ stop_idx_default_ip = stop_idx_critical_ip =
385
+ motion_utils::findNearestSegmentIndex (path_ip.points , mid_point);
386
+ /*
387
+ // NOTE: it is not ambiguous when the curve starts on the left/right lanelet, so this module
388
+ inserts stopline at the beginning of the lanelet for baselink
389
+ stop_idx_default_ip = stop_idx_critical_ip = static_cast<size_t>(std::max<int>(0,
390
+ static_cast<int>(motion_utils::findNearestSegmentIndex(path_ip.points, mid_point)) -
391
+ baselink2front_dist));
392
+ */
393
+ }
404
394
405
395
/* insert stop_point to use interpolated path*/
406
- const auto & path_ip = interpolated_path_info.path ;
407
396
const auto stopline_idx_default_opt = insertPointIndex (
408
397
path_ip.points .at (stop_idx_default_ip).point .pose , path,
409
398
planner_data_->ego_nearest_dist_threshold , planner_data_->ego_nearest_yaw_threshold );
0 commit comments