Skip to content

Commit

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

Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com>
  • Loading branch information
danielsanchezaran authored Oct 1, 2024
1 parent 89d0a51 commit a301539
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 @@ -461,7 +461,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, current_time, points_belonging_to_cluster_hulls, objects);
}
Expand Down Expand Up @@ -712,6 +714,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 @@ -721,8 +726,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 @@ -735,7 +743,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 @@ -926,6 +934,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 a301539

Please sign in to comment.