passthrough filter error
hi, I want to do obstacle avoidance using two filter but I get the following error:
/home/esetron/catkin_ws/src/sabir/src/sabir_node.cpp: In function ‘void cloud_cb(const PCLPointCloud2ConstPtr&)’:
/home/esetron/catkin_ws/src/sabir/src/sabir_node.cpp:25:53: error: no matching function for call to ‘pcl::PassThrough<pcl::PCLPointCloud2>::setInputCloud(pcl::PCLPointCloud2&)’
/home/esetron/catkin_ws/src/sabir/src/sabir_node.cpp:25:53: note: candidate is:
/usr/include/pcl-1.7/pcl/pcl_base.h:204:7: note: void pcl::PCLBase<pcl::PCLPointCloud2>::setInputCloud(const PCLPointCloud2ConstPtr&)
/usr/include/pcl-1.7/pcl/pcl_base.h:204:7: note: no known conversion for argument 1 from ‘pcl::PCLPointCloud2’ to ‘const PCLPointCloud2ConstPtr& {aka const boost::shared_ptr<const pcl::PCLPointCloud2>&}’
make[2]: *** [sabir/CMakeFiles/sabir_node.dir/src/sabir_node.cpp.o] Error 1
make[1]: *** [sabir/CMakeFiles/sabir_node.dir/all] Error 2
make: *** [all] Error 2
Actually, when I added to code line "pass_through_filter.setInputCloud(cloud_filtered);
", I am getting the current error. why I am getting this error?
thanks
my code:
#include <ros/ros.h>
#include <iostream>
// PCL specific includes
#include <pcl_conversions/pcl_conversions.h>
#include <sensor_msgs/PointCloud2.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
#include <pcl/filters/voxel_grid.h>
ros::Publisher pub;
void cloud_cb(const pcl::PCLPointCloud2ConstPtr& input)
{
pcl::PCLPointCloud2 cloud_filtered;
pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
sor.setInputCloud(input);
sor.setLeafSize(0.01, 0.01, 0.01);
sor.filter(cloud_filtered);
// Create the appropriate pass-through filter
pcl::PassThrough<pcl::PCLPointCloud2> pass_through_filter;
pass_through_filter.setInputCloud(cloud_filtered);
// Publish the data
pub.publish(cloud_filtered);
}
int main (int argc, char** argv){
// Initialize ROS
ros::init (argc, argv, "sabir");
ros::NodeHandle nh;
// Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);
// Create a ROS publisher for the output point cloud
pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
// Spin
ros::spin ();
}