@@ -886,41 +886,58 @@ double getRoadShoulderDistance(
886
886
return 0.0 ;
887
887
}
888
888
889
- std::vector<std::pair< Point , Point >> intersects;
889
+ std::vector<std::tuple< double , Point , Point >> intersects;
890
890
for (const auto & p1 : object.overhang_points ) {
891
891
const auto centerline_pose =
892
892
lanelet::utils::getClosestCenterPose (object.overhang_lanelet , object_pose.position );
893
893
const auto p_tmp =
894
894
geometry_msgs::build<Pose>().position (p1.second ).orientation (centerline_pose.orientation );
895
- const auto p2 = calcOffsetPose (p_tmp, 0.0 , (isOnRight (object) ? 100.0 : -100.0 ), 0.0 ).position ;
896
895
897
896
// TODO(Satoshi OTA): check if the basic point is on right or left of bound.
898
897
const auto bound = isOnRight (object) ? data.left_bound : data.right_bound ;
899
898
900
899
for (size_t i = 1 ; i < bound.size (); i++) {
901
- const auto opt_intersect =
902
- tier4_autoware_utils::intersect (p1.second , p2, bound.at (i - 1 ), bound.at (i));
903
-
904
- if (!opt_intersect) {
905
- continue ;
900
+ {
901
+ const auto p2 =
902
+ calcOffsetPose (p_tmp, 0.0 , (isOnRight (object) ? 100.0 : -100.0 ), 0.0 ).position ;
903
+ const auto opt_intersect =
904
+ tier4_autoware_utils::intersect (p1.second , p2, bound.at (i - 1 ), bound.at (i));
905
+
906
+ if (opt_intersect.has_value ()) {
907
+ intersects.emplace_back (
908
+ calcDistance2d (p1.second , opt_intersect.value ()), p1.second , opt_intersect.value ());
909
+ break ;
910
+ }
906
911
}
907
912
908
- intersects.emplace_back (p1.second , opt_intersect.value ());
913
+ {
914
+ const auto p2 =
915
+ calcOffsetPose (p_tmp, 0.0 , (isOnRight (object) ? -100.0 : 100.0 ), 0.0 ).position ;
916
+ const auto opt_intersect =
917
+ tier4_autoware_utils::intersect (p1.second , p2, bound.at (i - 1 ), bound.at (i));
918
+
919
+ if (opt_intersect.has_value ()) {
920
+ intersects.emplace_back (
921
+ -1.0 * calcDistance2d (p1.second , opt_intersect.value ()), p1.second ,
922
+ opt_intersect.value ());
923
+ break ;
924
+ }
925
+ }
909
926
}
910
927
}
911
928
912
929
std::sort (intersects.begin (), intersects.end (), [](const auto & a, const auto & b) {
913
- return calcDistance2d (a. first , a. second ) < calcDistance2d (b. first , b. second );
930
+ return std::get< 0 >(a ) < std::get< 0 >(b );
914
931
});
915
932
916
933
if (intersects.empty ()) {
917
934
return 0.0 ;
918
935
}
919
936
920
- object.narrowest_place = intersects.front ();
937
+ object.narrowest_place =
938
+ std::make_pair (std::get<1 >(intersects.front ()), std::get<2 >(intersects.front ()));
921
939
922
- return calcDistance2d (
923
- object.narrowest_place .value ().first , object.narrowest_place .value ().second );
940
+ return std::get<0 >(intersects.front ());
924
941
}
925
942
} // namespace filtering_utils
926
943
0 commit comments