How to implement PassThrough for pcl_ros

311 views Asked by At

I used code here for 3D mapping using 2D lidar. I want to try to implement the passthrough filter for removing outliers in the obtain points. I tried to replace the cloud with scan3dMsg in pass.setInputCloud (cloud);and result for the program to error. Does someone what should I replace cloudwith?

pcl::PassThrough<pcl::PointXYZ> pass;
pass.setInputCloud (cloud);
pass.setFilterFieldName ("z");
pass.setFilterLimits (0.0, 1.0);
//pass.setFilterLimitsNegative (true);
pass.filter (*cloud_filtered);
1

There are 1 answers

0
BTables On

Take a look at the pcl documentation. setInputCloud is looking for something with type pcl::PointCloud<pcl::PointXYZ>::Ptr and scan3dMsg is a ros message type. If you want to use this you'll need to first convert the ROS message to a pcl type, which you've asked about in another question; so I won't re-paste my answer here.

All of that being said, you shouldn't be using PointCloud messages at all these days as it's deprecated. There are packages that support PointCloud2, non-EOL distros, and do exactly what you're trying to do in less steps: laser_geometry