diff --git a/control/autoware_autonomous_emergency_braking/src/node.cpp b/control/autoware_autonomous_emergency_braking/src/node.cpp index 6267b62c694fe..6c0d144e94091 100644 --- a/control/autoware_autonomous_emergency_braking/src/node.cpp +++ b/control/autoware_autonomous_emergency_braking/src/node.cpp @@ -827,6 +827,12 @@ void AEB::createObjectDataUsingPointCloudClusters( obj.distance_to_object = std::abs(dist_ego_to_object); const Point2d obj_point(p.x, p.y); + // Check if the object is in the predicted path for AEB or not + if (!std::any_of(ego_polys.begin(), ego_polys.end(), [&obj_point](const auto & ego_poly) { + return bg::within(obj_point, ego_poly); + })) { + obj.is_target = false; + } // Add all objects located in the expanded area to the object list for tracking for (const auto & ego_poly : expanded_ego_polys) { if (bg::within(obj_point, ego_poly)) { @@ -834,13 +840,6 @@ void AEB::createObjectDataUsingPointCloudClusters( break; } } - - // Check if the object is in the predicted path for AEB or not - if (!std::any_of(ego_polys.begin(), ego_polys.end(), [&obj_point](const auto & ego_poly) { - return bg::within(obj_point, ego_poly); - })) { - obj.is_target = false; - } } }