I've had some success doing this by using PointCloud Library's built-in functions, namely Statistical Outlier Removal. It really depends where the majority of your points lie. If there's a lot of grass, this won't work as well. If the grass is sparse, this method could definitely improve your performance. Radial Outlier Removal might also work.
EDIT:
In order to get a ROS sensor_msgs/PointCloud2
to a pcl cloud, use the following code:
sensor_msgs::PointCloud2 cloud_in;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromROSMsg(cloud_in, *cloud);
The cloud
variable will now contain a pcl cloud that you can use with the PCL built-in functions.
Originally posted by DimitriProsser with karma: 11163 on 2012-02-23
This answer was ACCEPTED on the original site
Post score: 2
Original comments
Comment by rplankenhorn on 2012-02-23:
This looks like it could work. How do you suggest I implement it? I looked at the PCL page for ROS and the functions to convert from an ROS PointCloud to a PCL PointCloud and back are deprecated. Am I missing something?
Comment by DimitriProsser on 2012-02-23:
Use the fuction pcl::fromROSMsg()
. The docs might be misleading. This function is not deprecated. The fuction point_cloud::fromMsg()
is, but not pcl::fromROSMsg()
.
Comment by rplankenhorn on 2012-02-23:
Thanks again. If the fromMsg is deprecated, how do I convert the pcl::PointCloud back to a PointCloud2?
Comment by DimitriProsser on 2012-02-23:
pcl::toROSMsg() does the opposite of pcl::fromROSMsg()