Skip to content

Commit 20d1f83

Browse files
committed
fix(avoidance): fix bug in minimum overhang distance calculation (autowarefoundation#6372)
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent c323b57 commit 20d1f83

File tree

1 file changed

+29
-12
lines changed
  • planning/behavior_path_avoidance_module/src

1 file changed

+29
-12
lines changed

planning/behavior_path_avoidance_module/src/utils.cpp

+29-12
Original file line numberDiff line numberDiff line change
@@ -886,41 +886,58 @@ double getRoadShoulderDistance(
886886
return 0.0;
887887
}
888888

889-
std::vector<std::pair<Point, Point>> intersects;
889+
std::vector<std::tuple<double, Point, Point>> intersects;
890890
for (const auto & p1 : object.overhang_points) {
891891
const auto centerline_pose =
892892
lanelet::utils::getClosestCenterPose(object.overhang_lanelet, object_pose.position);
893893
const auto p_tmp =
894894
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;
896895

897896
// TODO(Satoshi OTA): check if the basic point is on right or left of bound.
898897
const auto bound = isOnRight(object) ? data.left_bound : data.right_bound;
899898

900899
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+
}
906911
}
907912

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+
}
909926
}
910927
}
911928

912929
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);
914931
});
915932

916933
if (intersects.empty()) {
917934
return 0.0;
918935
}
919936

920-
object.narrowest_place = intersects.front();
937+
object.narrowest_place =
938+
std::make_pair(std::get<1>(intersects.front()), std::get<2>(intersects.front()));
921939

922-
return calcDistance2d(
923-
object.narrowest_place.value().first, object.narrowest_place.value().second);
940+
return std::get<0>(intersects.front());
924941
}
925942
} // namespace filtering_utils
926943

0 commit comments

Comments
 (0)