Skip to content

Commit

Permalink
Merge pull request #23 from pf-telos/fix/nan-to-pointcloud
Browse files Browse the repository at this point in the history
Also exclude samples with Inf or NaN distance
  • Loading branch information
JnsHndr authored Jan 10, 2025
2 parents 2279a2a + e260a15 commit a42cf78
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/pf_driver/src/ros/point_cloud_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,19 @@ void PointcloudPublisher::project_laser(sensor_msgs::msg::PointCloud2& c, sensor
{
// num of points in cloud is sometimes less than that in laser scan because of
// https://github.com/ros-perception/laser_geometry/blob/indigo-devel/src/laser_geometry.cpp#L110
if (msg->ranges[i] < msg->range_min || msg->ranges[i] >= msg->range_max)
if (msg->ranges[i] < msg->range_max && msg->ranges[i] >= msg->range_min)
{
continue;
}
double angle_h = msg->angle_min + msg->angle_increment * (double)i;
double angle_h = msg->angle_min + msg->angle_increment * (double)i;

angle_v = correction_params_[layer_inclination][0] * angle_h * angle_h +
correction_params_[layer_inclination][1] * angle_h + correction_params_[layer_inclination][2];
angle_v = correction_params_[layer_inclination][0] * angle_h * angle_h +
correction_params_[layer_inclination][1] * angle_h + correction_params_[layer_inclination][2];

p_cloud->points[cl_idx].x = cos(angle_h) * cos(angle_v) * msg->ranges[i];
p_cloud->points[cl_idx].y = sin(angle_h) * cos(angle_v) * msg->ranges[i];
p_cloud->points[cl_idx].z = sin(angle_v) * msg->ranges[i];
p_cloud->points[cl_idx].x = cos(angle_h) * cos(angle_v) * msg->ranges[i];
p_cloud->points[cl_idx].y = sin(angle_h) * cos(angle_v) * msg->ranges[i];
p_cloud->points[cl_idx].z = sin(angle_v) * msg->ranges[i];

cl_idx++;
cl_idx++;
}
}

pcl::toROSMsg(*p_cloud.get(), c);
Expand Down

0 comments on commit a42cf78

Please sign in to comment.