@@ -368,7 +368,35 @@ bool StartPlannerModule::isCurrentPoseOnMiddleOfTheRoad() const
368
368
369
369
bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough () const
370
370
{
371
+ // prepare poses for preventing check
372
+ // - current_pose
373
+ // - estimated_stop_pose (The position assumed when stopped with the minimum stop distance,
374
+ // although it is NOT actually stopped)
371
375
const auto & current_pose = planner_data_->self_odometry ->pose .pose ;
376
+ std::vector<Pose> preventing_check_pose{current_pose};
377
+ const auto min_stop_distance =
378
+ autoware::behavior_path_planner::utils::parking_departure::calcFeasibleDecelDistance (
379
+ planner_data_, parameters_->maximum_deceleration_for_stop , parameters_->maximum_jerk_for_stop ,
380
+ 0.0 );
381
+ debug_data_.estimated_stop_pose .reset (); // debug
382
+ if (min_stop_distance.has_value ()) {
383
+ const auto current_path = getCurrentPath ();
384
+ const auto estimated_stop_pose = calcLongitudinalOffsetPose (
385
+ current_path.points , current_pose.position , min_stop_distance.value ());
386
+ if (estimated_stop_pose.has_value ()) {
387
+ preventing_check_pose.push_back (estimated_stop_pose.value ());
388
+ debug_data_.estimated_stop_pose = estimated_stop_pose.value (); // debug
389
+ }
390
+ }
391
+
392
+ // check if any of the preventing check poses are preventing rear vehicle from passing through
393
+ return std::any_of (
394
+ preventing_check_pose.begin (), preventing_check_pose.end (),
395
+ [&](const auto & pose) { return isPreventingRearVehicleFromPassingThrough (pose); });
396
+ }
397
+
398
+ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough (const Pose & ego_pose) const
399
+ {
372
400
const auto & dynamic_object = planner_data_->dynamic_object ;
373
401
const auto & route_handler = planner_data_->route_handler ;
374
402
const Pose start_pose = planner_data_->route_handler ->getOriginalStartPose ();
@@ -414,8 +442,8 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
414
442
geometry_msgs::msg::Pose & ego_overhang_point_as_pose,
415
443
const bool ego_is_merging_from_the_left) -> std::optional<std::pair<double , double >> {
416
444
const auto local_vehicle_footprint = vehicle_info_.createFootprint ();
417
- const auto vehicle_footprint = transformVector (
418
- local_vehicle_footprint, autoware::universe_utils::pose2transform (current_pose ));
445
+ const auto vehicle_footprint =
446
+ transformVector ( local_vehicle_footprint, autoware::universe_utils::pose2transform (ego_pose ));
419
447
double smallest_lateral_gap_between_ego_and_border = std::numeric_limits<double >::max ();
420
448
double corresponding_lateral_gap_with_other_lane_bound = std::numeric_limits<double >::max ();
421
449
@@ -481,7 +509,7 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
481
509
// Check backwards just in case the Vehicle behind ego is in a different lanelet
482
510
constexpr double backwards_length = 200.0 ;
483
511
const auto prev_lanes = autoware::behavior_path_planner::utils::getBackwardLanelets (
484
- *route_handler, target_lanes, current_pose , backwards_length);
512
+ *route_handler, target_lanes, ego_pose , backwards_length);
485
513
// return all the relevant lanelets
486
514
lanelet::ConstLanelets relevant_lanelets{closest_lanelet_const};
487
515
relevant_lanelets.insert (relevant_lanelets.end (), prev_lanes.begin (), prev_lanes.end ());
@@ -491,7 +519,7 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
491
519
492
520
// filtering objects with velocity, position and class
493
521
const auto filtered_objects = utils::path_safety_checker::filterObjects (
494
- dynamic_object, route_handler, relevant_lanelets.value (), current_pose .position ,
522
+ dynamic_object, route_handler, relevant_lanelets.value (), ego_pose .position ,
495
523
objects_filtering_params_);
496
524
if (filtered_objects.objects .empty ()) return false ;
497
525
@@ -508,7 +536,7 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
508
536
target_objects_on_lane.on_current_lane .begin (), target_objects_on_lane.on_current_lane .end (),
509
537
[&](const auto & o) {
510
538
const auto arc_length = autoware::motion_utils::calcSignedArcLength (
511
- centerline_path.points , current_pose .position , o.initial_pose .pose .position );
539
+ centerline_path.points , ego_pose .position , o.initial_pose .pose .position );
512
540
if (arc_length > 0.0 ) return ;
513
541
if (std::abs (arc_length) >= std::abs (arc_length_to_closet_object)) return ;
514
542
arc_length_to_closet_object = arc_length;
@@ -1723,6 +1751,16 @@ void StartPlannerModule::setDebugData()
1723
1751
info_marker_);
1724
1752
add (showPolygon (debug_data_.collision_check , " ego_and_target_polygon_relation" ), info_marker_);
1725
1753
1754
+ // visualize estimated_stop_pose for isPreventingRearVehicleFromPassingThrough()
1755
+ if (debug_data_.estimated_stop_pose .has_value ()) {
1756
+ auto footprint_marker = createDefaultMarker (
1757
+ " map" , rclcpp::Clock{RCL_ROS_TIME}.now (), " estimated_stop_pose" , 0 , Marker::LINE_STRIP,
1758
+ createMarkerScale (0.2 , 0.2 , 0.2 ), purple_color);
1759
+ footprint_marker.lifetime = rclcpp::Duration::from_seconds (1.5 );
1760
+ addFootprintMarker (footprint_marker, debug_data_.estimated_stop_pose .value (), vehicle_info_);
1761
+ debug_marker_.markers .push_back (footprint_marker);
1762
+ }
1763
+
1726
1764
// set objects of interest
1727
1765
for (const auto & [uuid, data] : debug_data_.collision_check ) {
1728
1766
const auto color = data.is_safe ? ColorName::GREEN : ColorName::RED;
0 commit comments