@@ -585,9 +585,16 @@ void StartPlannerModule::planWithPriority(
585
585
const PriorityOrder order_priority =
586
586
determinePriorityOrder (search_priority, start_pose_candidates.size ());
587
587
588
- for (const auto & [index , planner] : order_priority) {
589
- if (findPullOutPath (start_pose_candidates[index ], planner, refined_start_pose, goal_pose))
590
- return ;
588
+ for (const auto & collision_check_margin : parameters_->collision_check_margins ) {
589
+ for (const auto & [index , planner] : order_priority) {
590
+ if (findPullOutPath (
591
+ start_pose_candidates[index ], planner, refined_start_pose, goal_pose,
592
+ collision_check_margin)) {
593
+ start_planner_data_.selected_start_pose_candidate_index = index ;
594
+ start_planner_data_.margin_for_start_pose_candidate = collision_check_margin;
595
+ return ;
596
+ }
597
+ }
591
598
}
592
599
593
600
updateStatusIfNoSafePathFound ();
@@ -618,7 +625,7 @@ PriorityOrder StartPlannerModule::determinePriorityOrder(
618
625
619
626
bool StartPlannerModule::findPullOutPath (
620
627
const Pose & start_pose_candidate, const std::shared_ptr<PullOutPlannerBase> & planner,
621
- const Pose & refined_start_pose, const Pose & goal_pose)
628
+ const Pose & refined_start_pose, const Pose & goal_pose, const double collision_check_margin )
622
629
{
623
630
const auto & dynamic_objects = planner_data_->dynamic_object ;
624
631
const auto pull_out_lanes = start_planner_utils::getPullOutLanes (
@@ -646,7 +653,7 @@ bool StartPlannerModule::findPullOutPath(
646
653
// check collision
647
654
if (utils::checkCollisionBetweenPathFootprintsAndObjects (
648
655
vehicle_footprint, extractCollisionCheckSection (*pull_out_path), pull_out_lane_stop_objects,
649
- parameters_-> collision_check_margin )) {
656
+ collision_check_margin)) {
650
657
return false ;
651
658
}
652
659
@@ -667,23 +674,21 @@ PathWithLaneId StartPlannerModule::extractCollisionCheckSection(const PullOutPat
667
674
combined_path.points .insert (
668
675
combined_path.points .end (), partial_path.points .begin (), partial_path.points .end ());
669
676
}
670
-
671
677
// calculate collision check end idx
672
- size_t collision_check_end_idx = 0 ;
673
- const auto collision_check_end_pose = motion_utils::calcLongitudinalOffsetPose (
674
- combined_path.points , path.end_pose .position , parameters_->collision_check_distance_from_end );
675
-
676
- if (collision_check_end_pose) {
677
- collision_check_end_idx =
678
- motion_utils::findNearestIndex (combined_path.points , collision_check_end_pose->position );
679
- }
678
+ const size_t collision_check_end_idx = std::invoke ([&]() {
679
+ const auto collision_check_end_pose = motion_utils::calcLongitudinalOffsetPose (
680
+ combined_path.points , path.end_pose .position , parameters_->collision_check_distance_from_end );
680
681
682
+ if (collision_check_end_pose) {
683
+ return motion_utils::findNearestIndex (
684
+ combined_path.points , collision_check_end_pose->position );
685
+ } else {
686
+ return combined_path.points .size () - 1 ;
687
+ }
688
+ });
681
689
// remove the point behind of collision check end pose
682
- if (collision_check_end_idx + 1 < combined_path.points .size ()) {
683
- combined_path.points .erase (
684
- combined_path.points .begin () + collision_check_end_idx + 1 , combined_path.points .end ());
685
- }
686
-
690
+ combined_path.points .erase (
691
+ combined_path.points .begin () + collision_check_end_idx + 1 , combined_path.points .end ());
687
692
return combined_path;
688
693
}
689
694
@@ -950,7 +955,7 @@ std::vector<Pose> StartPlannerModule::searchPullOutStartPoseCandidates(
950
955
951
956
if (utils::checkCollisionBetweenFootprintAndObjects (
952
957
local_vehicle_footprint, *backed_pose, stop_objects_in_pull_out_lanes,
953
- parameters_->collision_check_margin )) {
958
+ parameters_->collision_check_margins . back () )) {
954
959
break ; // poses behind this has a collision, so break.
955
960
}
956
961
0 commit comments