pcl conditionalRemoval [closed]

asked 2020-07-06 15:32:36 -0500

Aviad gravatar image

Hello everyone,

I am trying to filter points cloud by the PCL's method conditionalRemoval. (an example)

This is my simple code but for any reason, it doesn't compile.

#include <ros/ros.h>
// PCL specific includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/filters/passthrough.h>
#include <pcl/filters/crop_box.h>
#include <pcl/filters/conditional_removal.h>

ros::Publisher pub;

float minX = -0.3, minY = 1 , minZ = -0.8;
float maxX = 5, maxY = 4, maxZ = 0.1;

void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud_msg)
{
    // Container for original & filtered data
    pcl::PCLPointCloud2* cloud = new pcl::PCLPointCloud2;
    pcl::PCLPointCloud2ConstPtr cloudPtr(cloud);
    pcl::PCLPointCloud2 cloud_filtered;
    // Convert to PCL data type
    pcl_conversions::toPCL(*cloud_msg, *cloud);

    pcl::ConditionOr<pcl::PCLPointCloud2>::Ptr range_cond (new pcl::ConditionOr<pcl::PCLPointCloud2> ());
//    range_cond->addComparison (pcl::FieldComparison<pcl::PCLPointCloud2>::ConstPtr (new pcl::FieldComparison<pcl::PCLPointCloud2> ("z", pcl::ComparisonOps::GT, 0.0)));
//    range_cond->addComparison (pcl::FieldComparison<pcl::PCLPointCloud2>::ConstPtr (new pcl::FieldComparison<pcl::PCLPointCloud2> ("z", pcl::ComparisonOps::LT, 0.5)));
//    pcl::ConditionalRemoval<pcl::PCLPointCloud2> conderm (range_cond);
//    condrem.setInputCloud(cloudPtr);
//    condrem.filter (cloud_filtered);



    // Convert to ROS data type
    sensor_msgs::PointCloud2 output;
    pcl_conversions::fromPCL(cloud_filtered, output);

    // Publish the data
    pub.publish (output);
}

int main (int argc, char** argv)
{
    // Initialize ROS
    ros::init (argc, argv, "my_pcl_tutorial");
    ros::NodeHandle nh;

    // Create a ROS subscriber for the input point cloud
    ros::Subscriber sub = nh.subscribe<sensor_msgs::PointCloud2> ("/fused_points", 1, cloud_cb);

    // Create a ROS publisher for the output point cloud
    pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);

    // Spin
    ros::spin ();
}

The error is:

undefined reference to `pcl::ConditionOr<pcl::PCLPointCloud2>::evaluate(pcl::PCLPointCloud2 const&) const'
collect2: error: ld returned 1 exit status

When I changed it to another type like pcl::PointXYZ it was compiled but I have a problem with the line

condrem.setInputCloud(cloudPtr);

The IDE showed that it doesn't recognize this variable or anything else.

Can someone help me with that issue? My goal is to remove points that are inside a range (or keep the points that are outside this range), I saw that it is the only approach to do that.

Thanks, Aviad

edit retag flag offensive reopen merge delete

Closed for the following reason PCL Question: The PCL community prefers to answer questions at http://www.pcl-users.org/ by stevemacenski
close date 2020-07-06 16:14:47.921465