Skip to content

Commit d05d86e

Browse files
authored
Merge pull request #10 from jkk-research/handle-nan-points
Zero NaN points in eucl. grid
2 parents efacc23 + 27429e1 commit d05d86e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/euclidean_grid.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <pcl/filters/voxel_grid.h>
2121
#include <pcl/search/kdtree.h>
2222
#include <pcl/segmentation/extract_clusters.h>
23+
#include <pcl/common/point_tests.h>
2324
// ROS package
2425
#include "lidar_cluster/marker.hpp"
2526
// Benchmarking
@@ -280,6 +281,15 @@ class EuclideanGrid : public rclcpp::Node
280281
RCLCPP_INFO_STREAM(this->get_logger(), "PointCloud in: " << original_size << " reduced size before cluster: " << cloud->width * cloud->height);
281282
}
282283

284+
// if any point in the pointcloud is not a proper number, modify that value to zero
285+
for (auto &point : cloud_xyz->points) {
286+
if (!pcl::isFinite(point)) {
287+
point.x = 0.0;
288+
point.y = 0.0;
289+
point.z = 0.0;
290+
}
291+
}
292+
283293
// Create voxel grid and project to 2D
284294
pcl::PointCloud<pcl::PointXYZ>::Ptr voxel_map_ptr(new pcl::PointCloud<pcl::PointXYZ>);
285295
pcl::VoxelGrid<pcl::PointXYZ> voxel_grid;

0 commit comments

Comments
 (0)