From 8865dcd8ce138a98ffa42dd71cf83d58def90e4b Mon Sep 17 00:00:00 2001 From: Tim Clephas Date: Thu, 28 Jan 2021 14:47:20 +0100 Subject: [PATCH 1/2] Fix zero-division error on empty clouds Signed-off-by: Tim Clephas --- .../nodes/ray_ground_filter/ray_ground_filter.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp b/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp index f1d33ace..d1844e1e 100644 --- a/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp +++ b/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp @@ -103,7 +103,15 @@ void RayGroundFilter::filterROSMsg(const sensor_msgs::PointCloud2ConstPtr in_ori const std::vector& in_selector, const sensor_msgs::PointCloud2::Ptr out_filtered_msg) { - size_t point_size = in_origin_cloud->row_step/in_origin_cloud->width; // in Byte + size_t point_size = 0; + if (in_origin_cloud->width == 0) + { + ROS_WARN_THROTTLE(5, "Cloud width of zero, nothing to process"); + } + else + { + size_t point_size = in_origin_cloud->row_step/in_origin_cloud->width; // in Byte + } // TODO(yoan picchi) I fear this may do a lot of cache miss because it is sorted in the radius // and no longer sorted in the original pointer. One thing to try is that, given From 796a7994074c0a439af1d6dc78292cb6c91a078b Mon Sep 17 00:00:00 2001 From: Tim Clephas Date: Tue, 30 Mar 2021 13:21:53 +0200 Subject: [PATCH 2/2] Don't declare type again Signed-off-by: Tim Clephas --- .../nodes/ray_ground_filter/ray_ground_filter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp b/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp index d1844e1e..61722c2f 100644 --- a/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp +++ b/points_preprocessor/nodes/ray_ground_filter/ray_ground_filter.cpp @@ -110,7 +110,7 @@ void RayGroundFilter::filterROSMsg(const sensor_msgs::PointCloud2ConstPtr in_ori } else { - size_t point_size = in_origin_cloud->row_step/in_origin_cloud->width; // in Byte + point_size = in_origin_cloud->row_step/in_origin_cloud->width; // in Byte } // TODO(yoan picchi) I fear this may do a lot of cache miss because it is sorted in the radius