Skip to content

Commit

Permalink
feat(autonomous_emergency_braking): add sanity chackes (autowarefound…
Browse files Browse the repository at this point in the history
…ation#8998)

add sanity chackes

Signed-off-by: Daniel Sanchez <[email protected]>
  • Loading branch information
danielsanchezaran committed Oct 1, 2024
1 parent 2774c8d commit 5eacb6f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions control/autoware_autonomous_emergency_braking/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,9 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
const auto ego_polys = generatePathFootprint(path, expand_width_);
std::vector<ObjectData> objects;
// Crop out Pointcloud using an extra wide ego path
if (use_pointcloud_data_ && !points_belonging_to_cluster_hulls->empty()) {
if (
use_pointcloud_data_ && points_belonging_to_cluster_hulls &&
!points_belonging_to_cluster_hulls->empty()) {
const auto current_time = obstacle_ros_pointcloud_ptr_->header.stamp;
getClosestObjectsOnPath(
path, ego_polys, current_time, points_belonging_to_cluster_hulls, objects);
Expand Down Expand Up @@ -667,6 +669,9 @@ void AEB::generatePathFootprint(
const Path & path, const double extra_width_margin, std::vector<Polygon2d> & polygons)
{
autoware::universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
if (path.empty()) {
return;
}
for (size_t i = 0; i < path.size() - 1; ++i) {
polygons.push_back(
createPolygon(path.at(i), path.at(i + 1), vehicle_info_, extra_width_margin));
Expand All @@ -676,8 +681,11 @@ void AEB::generatePathFootprint(
std::vector<Polygon2d> AEB::generatePathFootprint(
const Path & path, const double extra_width_margin)
{
std::vector<Polygon2d> polygons;
autoware::universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
if (path.empty()) {
return {};
}
std::vector<Polygon2d> polygons;
for (size_t i = 0; i < path.size() - 1; ++i) {
polygons.push_back(
createPolygon(path.at(i), path.at(i + 1), vehicle_info_, extra_width_margin));
Expand All @@ -690,7 +698,7 @@ void AEB::createObjectDataUsingPredictedObjects(
std::vector<ObjectData> & object_data_vector)
{
autoware::universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
if (predicted_objects_ptr_->objects.empty()) return;
if (predicted_objects_ptr_->objects.empty() || ego_polys.empty()) return;

const double current_ego_speed = current_velocity_ptr_->longitudinal_velocity;
const auto & objects = predicted_objects_ptr_->objects;
Expand Down Expand Up @@ -863,6 +871,9 @@ void AEB::cropPointCloudWithEgoFootprintPath(
const std::vector<Polygon2d> & ego_polys, PointCloud::Ptr filtered_objects)
{
autoware::universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
if (ego_polys.empty()) {
return;
}
PointCloud::Ptr full_points_ptr(new PointCloud);
pcl::fromROSMsg(*obstacle_ros_pointcloud_ptr_, *full_points_ptr);
// Create a Point cloud with the points of the ego footprint
Expand Down

0 comments on commit 5eacb6f

Please sign in to comment.