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