@@ -703,18 +703,6 @@ bool AvoidanceModule::isSafePath(
703
703
return true ; // if safety check is disabled, it always return safe.
704
704
}
705
705
706
- const bool limit_to_max_velocity = false ;
707
- const auto ego_predicted_path_params =
708
- std::make_shared<utils::path_safety_checker::EgoPredictedPathParams>(
709
- parameters_->ego_predicted_path_params );
710
- const size_t ego_seg_idx = planner_data_->findEgoSegmentIndex (shifted_path.path .points );
711
- const auto ego_predicted_path_for_front_object = utils::path_safety_checker::createPredictedPath (
712
- ego_predicted_path_params, shifted_path.path .points , getEgoPose (), getEgoSpeed (), ego_seg_idx,
713
- true , limit_to_max_velocity);
714
- const auto ego_predicted_path_for_rear_object = utils::path_safety_checker::createPredictedPath (
715
- ego_predicted_path_params, shifted_path.path .points , getEgoPose (), getEgoSpeed (), ego_seg_idx,
716
- false , limit_to_max_velocity);
717
-
718
706
const auto ego_idx = planner_data_->findEgoIndex (shifted_path.path .points );
719
707
const auto is_right_shift = [&]() -> std::optional<bool > {
720
708
for (size_t i = ego_idx; i < shifted_path.shift_length .size (); i++) {
@@ -741,6 +729,22 @@ bool AvoidanceModule::isSafePath(
741
729
const auto safety_check_target_objects = utils::avoidance::getSafetyCheckTargetObjects (
742
730
avoid_data_, planner_data_, parameters_, is_right_shift.value (), debug);
743
731
732
+ if (safety_check_target_objects.empty ()) {
733
+ return true ;
734
+ }
735
+
736
+ const bool limit_to_max_velocity = false ;
737
+ const auto ego_predicted_path_params =
738
+ std::make_shared<utils::path_safety_checker::EgoPredictedPathParams>(
739
+ parameters_->ego_predicted_path_params );
740
+ const size_t ego_seg_idx = planner_data_->findEgoSegmentIndex (shifted_path.path .points );
741
+ const auto ego_predicted_path_for_front_object = utils::path_safety_checker::createPredictedPath (
742
+ ego_predicted_path_params, shifted_path.path .points , getEgoPose (), getEgoSpeed (), ego_seg_idx,
743
+ true , limit_to_max_velocity);
744
+ const auto ego_predicted_path_for_rear_object = utils::path_safety_checker::createPredictedPath (
745
+ ego_predicted_path_params, shifted_path.path .points , getEgoPose (), getEgoSpeed (), ego_seg_idx,
746
+ false , limit_to_max_velocity);
747
+
744
748
for (const auto & object : safety_check_target_objects) {
745
749
auto current_debug_data = utils::path_safety_checker::createObjectDebug (object);
746
750
@@ -793,15 +797,16 @@ PathWithLaneId AvoidanceModule::extendBackwardLength(const PathWithLaneId & orig
793
797
794
798
const auto longest_dist_to_shift_point = [&]() {
795
799
double max_dist = 0.0 ;
796
- for ( const auto & pnt : path_shifter_.getShiftLines ()) {
797
- max_dist = std::max (
798
- max_dist, calcSignedArcLength (previous_path. points , pnt. start . position , getEgoPosition ())) ;
800
+ auto lines = path_shifter_.getShiftLines ();
801
+ if (lines. empty ()) {
802
+ return max_dist;
799
803
}
800
- for (const auto & sp : generator_.getRawRegisteredShiftLine ()) {
801
- max_dist = std::max (
802
- max_dist, calcSignedArcLength (previous_path.points , sp.start .position , getEgoPosition ()));
803
- }
804
- return max_dist;
804
+ std::sort (lines.begin (), lines.end (), [](const auto & a, const auto & b) {
805
+ return a.start_idx < b.start_idx ;
806
+ });
807
+ return std::max (
808
+ max_dist,
809
+ calcSignedArcLength (previous_path.points , lines.front ().start .position , getEgoPosition ()));
805
810
}();
806
811
807
812
const auto extra_margin = 10.0 ; // Since distance does not consider arclength, but just line.
@@ -1029,11 +1034,14 @@ void AvoidanceModule::updatePathShifter(const AvoidLineArray & shift_lines)
1029
1034
const auto sl = helper_->getMainShiftLine (shift_lines);
1030
1035
const auto sl_front = shift_lines.front ();
1031
1036
const auto sl_back = shift_lines.back ();
1037
+ const auto relative_longitudinal = sl_back.end_longitudinal - sl_front.start_longitudinal ;
1032
1038
1033
1039
if (helper_->getRelativeShiftToPath (sl) > 0.0 ) {
1034
- left_shift_array_.push_back ({uuid_map_.at (" left" ), sl_front.start , sl_back.end });
1040
+ left_shift_array_.push_back (
1041
+ {uuid_map_.at (" left" ), sl_front.start , sl_back.end , relative_longitudinal});
1035
1042
} else if (helper_->getRelativeShiftToPath (sl) < 0.0 ) {
1036
- right_shift_array_.push_back ({uuid_map_.at (" right" ), sl_front.start , sl_back.end });
1043
+ right_shift_array_.push_back (
1044
+ {uuid_map_.at (" right" ), sl_front.start , sl_back.end , relative_longitudinal});
1037
1045
}
1038
1046
1039
1047
uuid_map_.at (" left" ) = generateUUID ();
@@ -1150,15 +1158,19 @@ bool AvoidanceModule::isValidShiftLine(
1150
1158
const size_t start_idx = shift_lines.front ().start_idx ;
1151
1159
const size_t end_idx = shift_lines.back ().end_idx ;
1152
1160
1161
+ const auto path = shifter_for_validate.getReferencePath ();
1162
+ const auto left_bound = lanelet::utils::to2D (avoid_data_.left_bound );
1163
+ const auto right_bound = lanelet::utils::to2D (avoid_data_.right_bound );
1153
1164
for (size_t i = start_idx; i <= end_idx; ++i) {
1154
- const auto p = getPoint (shifter_for_validate. getReferencePath () .points .at (i));
1165
+ const auto p = getPoint (path .points .at (i));
1155
1166
lanelet::BasicPoint2d basic_point{p.x , p.y };
1156
1167
1157
1168
const auto shift_length = proposed_shift_path.shift_length .at (i);
1158
- const auto bound = shift_length > 0.0 ? avoid_data_.left_bound : avoid_data_.right_bound ;
1159
1169
const auto THRESHOLD = minimum_distance + std::abs (shift_length);
1160
1170
1161
- if (boost::geometry::distance (basic_point, lanelet::utils::to2D (bound)) < THRESHOLD) {
1171
+ if (
1172
+ boost::geometry::distance (basic_point, (shift_length > 0.0 ? left_bound : right_bound)) <
1173
+ THRESHOLD) {
1162
1174
RCLCPP_DEBUG_THROTTLE (
1163
1175
getLogger (), *clock_, 1000 ,
1164
1176
" following latest new shift line may cause deviation from drivable area." );
0 commit comments