Skip to content

Commit 60f8a99

Browse files
committed
fix(avoidance): fix logic to check if it is parked vehicle
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 52f4147 commit 60f8a99

File tree

1 file changed

+38
-52
lines changed
  • planning/behavior_path_avoidance_module/src

1 file changed

+38
-52
lines changed

planning/behavior_path_avoidance_module/src/utils.cpp

+38-52
Original file line numberDiff line numberDiff line change
@@ -498,33 +498,26 @@ bool isParkedVehicle(
498498

499499
bool is_left_side_parked_vehicle = false;
500500
if (!isOnRight(object)) {
501-
auto [object_shiftable_distance, sub_type] = [&]() {
502-
const auto most_left_road_lanelet =
503-
route_handler->getMostLeftLanelet(object.overhang_lanelet);
504-
const auto most_left_lanelet_candidates =
505-
route_handler->getLaneletMapPtr()->laneletLayer.findUsages(
506-
most_left_road_lanelet.leftBound());
507-
508-
lanelet::ConstLanelet most_left_lanelet = most_left_road_lanelet;
509-
const lanelet::Attribute sub_type =
510-
most_left_lanelet.attribute(lanelet::AttributeName::Subtype);
511-
512-
for (const auto & ll : most_left_lanelet_candidates) {
513-
const lanelet::Attribute sub_type = ll.attribute(lanelet::AttributeName::Subtype);
514-
if (sub_type.value() == "road_shoulder") {
515-
most_left_lanelet = ll;
516-
}
501+
const auto most_left_lanelet =
502+
route_handler->getMostLeftLanelet(object.overhang_lanelet, true, true);
503+
const auto center_to_left_boundary = distance2d(
504+
to2D(most_left_lanelet.leftBound().basicLineString()),
505+
to2D(toLaneletPoint(centerline_pos)).basicPoint());
506+
507+
double object_shiftable_distance =
508+
center_to_left_boundary - 0.5 * object.object.shape.dimensions.y;
509+
510+
const lanelet::Attribute sub_type =
511+
most_left_lanelet.attribute(lanelet::AttributeName::Subtype);
512+
if (sub_type == "road_shoulder") {
513+
// assuming it's parked vehicle if its CoG is within road shoulder lanelet.
514+
if (boost::geometry::within(
515+
to2D(toLaneletPoint(object_pos)).basicPoint(),
516+
most_left_lanelet.polygon2d().basicPolygon())) {
517+
return true;
517518
}
518-
519-
const auto center_to_left_boundary = distance2d(
520-
to2D(most_left_lanelet.leftBound().basicLineString()),
521-
to2D(toLaneletPoint(centerline_pos)).basicPoint());
522-
523-
return std::make_pair(
524-
center_to_left_boundary - 0.5 * object.object.shape.dimensions.y, sub_type);
525-
}();
526-
527-
if (sub_type.value() != "road_shoulder") {
519+
} else {
520+
// assuming there is 0.5m road shoulder even if it's not defined explicitly in HDMap.
528521
object_shiftable_distance += parameters->object_check_min_road_shoulder_width;
529522
}
530523

@@ -538,33 +531,26 @@ bool isParkedVehicle(
538531

539532
bool is_right_side_parked_vehicle = false;
540533
if (isOnRight(object)) {
541-
auto [object_shiftable_distance, sub_type] = [&]() {
542-
const auto most_right_road_lanelet =
543-
route_handler->getMostRightLanelet(object.overhang_lanelet);
544-
const auto most_right_lanelet_candidates =
545-
route_handler->getLaneletMapPtr()->laneletLayer.findUsages(
546-
most_right_road_lanelet.rightBound());
547-
548-
lanelet::ConstLanelet most_right_lanelet = most_right_road_lanelet;
549-
const lanelet::Attribute sub_type =
550-
most_right_lanelet.attribute(lanelet::AttributeName::Subtype);
551-
552-
for (const auto & ll : most_right_lanelet_candidates) {
553-
const lanelet::Attribute sub_type = ll.attribute(lanelet::AttributeName::Subtype);
554-
if (sub_type.value() == "road_shoulder") {
555-
most_right_lanelet = ll;
556-
}
534+
const auto most_right_lanelet =
535+
route_handler->getMostRightLanelet(object.overhang_lanelet, true, true);
536+
const auto center_to_right_boundary = distance2d(
537+
to2D(most_right_lanelet.rightBound().basicLineString()),
538+
to2D(toLaneletPoint(centerline_pos)).basicPoint());
539+
540+
double object_shiftable_distance =
541+
center_to_right_boundary - 0.5 * object.object.shape.dimensions.y;
542+
543+
const lanelet::Attribute sub_type =
544+
most_right_lanelet.attribute(lanelet::AttributeName::Subtype);
545+
if (sub_type == "road_shoulder") {
546+
// assuming it's parked vehicle if its CoG is within road shoulder lanelet.
547+
if (boost::geometry::within(
548+
to2D(toLaneletPoint(object_pos)).basicPoint(),
549+
most_right_lanelet.polygon2d().basicPolygon())) {
550+
return true;
557551
}
558-
559-
const auto center_to_right_boundary = distance2d(
560-
to2D(most_right_lanelet.rightBound().basicLineString()),
561-
to2D(toLaneletPoint(centerline_pos)).basicPoint());
562-
563-
return std::make_pair(
564-
center_to_right_boundary - 0.5 * object.object.shape.dimensions.y, sub_type);
565-
}();
566-
567-
if (sub_type.value() != "road_shoulder") {
552+
} else {
553+
// assuming there is 0.5m road shoulder even if it's not defined explicitly in HDMap.
568554
object_shiftable_distance += parameters->object_check_min_road_shoulder_width;
569555
}
570556

0 commit comments

Comments
 (0)