Skip to content

Commit b5091fc

Browse files
Use single PC ptr
Signed-off-by: Daniel Sanchez <danielsanchezaran@gmail.com>
1 parent 0be9601 commit b5091fc

File tree

2 files changed

+5
-7
lines changed
  • control/autonomous_emergency_braking

2 files changed

+5
-7
lines changed

control/autonomous_emergency_braking/include/autonomous_emergency_braking/node.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ class AEB : public rclcpp::Node
165165
void addCollisionMarker(const ObjectData & data, MarkerArray & debug_markers);
166166

167167
PointCloud2::SharedPtr obstacle_ros_pointcloud_ptr_{nullptr};
168-
PointCloud2::SharedPtr cropped_ros_pointcloud_ptr_{nullptr};
169168

170169
VelocityReport::ConstSharedPtr current_velocity_ptr_{nullptr};
171170
Vector3::SharedPtr angular_velocity_ptr_{nullptr};

control/autonomous_emergency_braking/src/node.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ void AEB::onPointCloud(const PointCloud2::ConstSharedPtr input_msg)
242242
filter.filter(*no_height_filtered_pointcloud_ptr);
243243

244244
obstacle_ros_pointcloud_ptr_ = std::make_shared<PointCloud2>();
245-
cropped_ros_pointcloud_ptr_ = std::make_shared<PointCloud2>();
246245

247246
pcl::toROSMsg(*no_height_filtered_pointcloud_ptr, *obstacle_ros_pointcloud_ptr_);
248247
obstacle_ros_pointcloud_ptr_->header = input_msg->header;
@@ -386,8 +385,8 @@ bool AEB::checkCollision(MarkerArray & debug_markers)
386385
}
387386
}
388387

389-
if (cropped_ros_pointcloud_ptr_) {
390-
pub_obstacle_pointcloud_->publish(*cropped_ros_pointcloud_ptr_);
388+
if (obstacle_ros_pointcloud_ptr_) {
389+
pub_obstacle_pointcloud_->publish(*obstacle_ros_pointcloud_ptr_);
391390
}
392391

393392
return has_collision_ego || has_collision_predicted;
@@ -577,7 +576,7 @@ void AEB::cropPointCloudWithEgoFootprintPath(const std::vector<Polygon2d> & ego_
577576

578577
// Store the results
579578
if (!objects->empty()) {
580-
pcl::toROSMsg(*objects, *cropped_ros_pointcloud_ptr_);
579+
pcl::toROSMsg(*objects, *obstacle_ros_pointcloud_ptr_);
581580
}
582581
}
583582

@@ -586,12 +585,12 @@ void AEB::createObjectDataUsingPointCloudClusters(
586585
std::vector<ObjectData> & objects)
587586
{
588587
// check if the predicted path has valid number of points
589-
if (ego_path.size() < 2 || ego_polys.empty() || cropped_ros_pointcloud_ptr_->data.empty()) {
588+
if (ego_path.size() < 2 || ego_polys.empty() || obstacle_ros_pointcloud_ptr_->data.empty()) {
590589
return;
591590
}
592591

593592
PointCloud::Ptr obstacle_points_ptr(new PointCloud);
594-
pcl::fromROSMsg(*cropped_ros_pointcloud_ptr_, *obstacle_points_ptr);
593+
pcl::fromROSMsg(*obstacle_ros_pointcloud_ptr_, *obstacle_points_ptr);
595594
if (obstacle_points_ptr->empty()) return;
596595

597596
std::vector<pcl::PointIndices> cluster_indices;

0 commit comments

Comments
 (0)