@@ -819,8 +819,8 @@ bool isNoNeedAvoidanceBehavior(
819
819
return false ;
820
820
}
821
821
822
- const auto shift_length =
823
- calcShiftLength ( isOnRight (object), object.overhang_dist , object.avoid_margin .value ());
822
+ const auto shift_length = calcShiftLength (
823
+ isOnRight (object), object.overhang_points . front (). first , object.avoid_margin .value ());
824
824
if (!isShiftNecessary (isOnRight (object), shift_length)) {
825
825
object.reason = " NotNeedAvoidance" ;
826
826
return true ;
@@ -881,40 +881,41 @@ double getRoadShoulderDistance(
881
881
return 0.0 ;
882
882
}
883
883
884
- const auto centerline_pose =
885
- lanelet::utils::getClosestCenterPose ( object.overhang_lanelet , object_pose. position );
886
- const auto & p1_object = object. overhang_pose . position ;
887
- const auto p_tmp =
888
- geometry_msgs::build<Pose>(). position (p1_object). orientation (centerline_pose. orientation );
889
- const auto p2_object =
890
- calcOffsetPose (p_tmp, 0.0 , (isOnRight (object) ? 100.0 : -100.0 ), 0.0 ).position ;
884
+ std::vector<std::pair< Point , Point >> intersects;
885
+ for ( const auto & p1 : object.overhang_points ) {
886
+ const auto centerline_pose =
887
+ lanelet::utils::getClosestCenterPose (object. overhang_lanelet , object_pose. position );
888
+ const auto p_tmp =
889
+ geometry_msgs::build<Pose>(). position (p1. second ). orientation (centerline_pose. orientation );
890
+ const auto p2 = calcOffsetPose (p_tmp, 0.0 , (isOnRight (object) ? 100.0 : -100.0 ), 0.0 ).position ;
891
891
892
- // TODO(Satoshi OTA): check if the basic point is on right or left of bound.
893
- const auto bound = isOnRight (object) ? data.left_bound : data.right_bound ;
892
+ // TODO(Satoshi OTA): check if the basic point is on right or left of bound.
893
+ const auto bound = isOnRight (object) ? data.left_bound : data.right_bound ;
894
894
895
- std::vector<Point > intersects;
896
- for (size_t i = 1 ; i < bound.size (); i++) {
897
- const auto opt_intersect =
898
- tier4_autoware_utils::intersect (p1_object, p2_object, bound.at (i - 1 ), bound.at (i));
895
+ for (size_t i = 1 ; i < bound.size (); i++) {
896
+ const auto opt_intersect =
897
+ tier4_autoware_utils::intersect (p1.second , p2, bound.at (i - 1 ), bound.at (i));
899
898
900
- if (!opt_intersect) {
901
- continue ;
902
- }
899
+ if (!opt_intersect) {
900
+ continue ;
901
+ }
903
902
904
- intersects.push_back (opt_intersect.value ());
903
+ intersects.emplace_back (p1.second , opt_intersect.value ());
904
+ }
905
905
}
906
906
907
+ std::sort (intersects.begin (), intersects.end (), [](const auto & a, const auto & b) {
908
+ return calcDistance2d (a.first , a.second ) < calcDistance2d (b.first , b.second );
909
+ });
910
+
907
911
if (intersects.empty ()) {
908
912
return 0.0 ;
909
913
}
910
914
911
- std::sort (intersects.begin (), intersects.end (), [&p1_object](const auto & a, const auto & b) {
912
- return calcDistance2d (p1_object, a) < calcDistance2d (p1_object, b);
913
- });
914
-
915
- object.nearest_bound_point = intersects.front ();
915
+ object.narrowest_place = intersects.front ();
916
916
917
- return calcDistance2d (p1_object, object.nearest_bound_point .value ());
917
+ return calcDistance2d (
918
+ object.narrowest_place .value ().first , object.narrowest_place .value ().second );
918
919
}
919
920
} // namespace filtering_utils
920
921
@@ -1070,34 +1071,22 @@ void fillLongitudinalAndLengthByClosestEnvelopeFootprint(
1070
1071
return ;
1071
1072
}
1072
1073
1073
- double calcEnvelopeOverhangDistance (
1074
- const ObjectData & object_data, const PathWithLaneId & path, Point & overhang_pose )
1074
+ std::vector<std::pair< double , Point >> calcEnvelopeOverhangDistance (
1075
+ const ObjectData & object_data, const PathWithLaneId & path)
1075
1076
{
1076
- double largest_overhang = isOnRight (object_data) ? - 100.0 : 100.0 ; // large number
1077
+ std::vector<std::pair< double , Point >> overhang_points{};
1077
1078
1078
1079
for (const auto & p : object_data.envelope_poly .outer ()) {
1079
1080
const auto point = tier4_autoware_utils::createPoint (p.x (), p.y (), 0.0 );
1080
1081
// TODO(someone): search around first position where the ego should avoid the object.
1081
1082
const auto idx = findNearestIndex (path.points , point);
1082
1083
const auto lateral = calcLateralDeviation (getPose (path.points .at (idx)), point);
1083
-
1084
- const auto & overhang_pose_on_right = [&overhang_pose, &largest_overhang, &point, &lateral]() {
1085
- if (lateral > largest_overhang) {
1086
- overhang_pose = point;
1087
- }
1088
- return std::max (largest_overhang, lateral);
1089
- };
1090
-
1091
- const auto & overhang_pose_on_left = [&overhang_pose, &largest_overhang, &point, &lateral]() {
1092
- if (lateral < largest_overhang) {
1093
- overhang_pose = point;
1094
- }
1095
- return std::min (largest_overhang, lateral);
1096
- };
1097
-
1098
- largest_overhang = isOnRight (object_data) ? overhang_pose_on_right () : overhang_pose_on_left ();
1084
+ overhang_points.emplace_back (lateral, point);
1099
1085
}
1100
- return largest_overhang;
1086
+ std::sort (overhang_points.begin (), overhang_points.end (), [&](const auto & a, const auto & b) {
1087
+ return isOnRight (object_data) ? b.first < a.first : a.first < b.first ;
1088
+ });
1089
+ return overhang_points;
1101
1090
}
1102
1091
1103
1092
void setEndData (
@@ -1442,10 +1431,10 @@ void fillAvoidanceNecessity(
1442
1431
0.5 * vehicle_width + object_parameter.safety_buffer_lateral * object_data.distance_factor ;
1443
1432
1444
1433
const auto check_necessity = [&](const auto hysteresis_factor) {
1445
- return (isOnRight (object_data) &&
1446
- std::abs (object_data. overhang_dist ) < safety_margin * hysteresis_factor) ||
1434
+ return (isOnRight (object_data) && std::abs (object_data. overhang_points . front (). first ) <
1435
+ safety_margin * hysteresis_factor) ||
1447
1436
(!isOnRight (object_data) &&
1448
- object_data.overhang_dist < safety_margin * hysteresis_factor);
1437
+ object_data.overhang_points . front (). first < safety_margin * hysteresis_factor);
1449
1438
};
1450
1439
1451
1440
const auto id = object_data.object .object_id ;
@@ -1665,8 +1654,7 @@ void filterTargetObjects(
1665
1654
}
1666
1655
1667
1656
// Find the footprint point closest to the path, set to object_data.overhang_distance.
1668
- o.overhang_dist =
1669
- calcEnvelopeOverhangDistance (o, data.reference_path , o.overhang_pose .position );
1657
+ o.overhang_points = utils::avoidance::calcEnvelopeOverhangDistance (o, data.reference_path );
1670
1658
o.to_road_shoulder_distance = filtering_utils::getRoadShoulderDistance (o, data, planner_data);
1671
1659
o.avoid_margin = filtering_utils::getAvoidMargin (o, planner_data, parameters);
1672
1660
0 commit comments