PCL setInputCloud error

Share:
error: no matching function for call to 'pcl::VoxelGrid::setInputCloud(std::shared_ptr >&)' voxel.setInputCloud(-) ## Source code with error ```cpp template pcl::PointCloud Semantic::filterPCD(std::shared_ptr > t_input) { std::shared_ptr > filtered(new pcl::PointCloud()); static pcl::VoxelGrid voxel; voxel.setLeafSize(0.05, 0.05, 0.05); voxel.setInputCloud(t_input); voxel.filter(*filtered); return *filtered; } ``` ## Error Message ```sh error: no matching function for call to 'pcl::VoxelGrid::setInputCloud(std::shared_ptr >&)' voxel.setInputCloud(t_input); ^~~~~ In file included from /usr/include/pcl-1.8/pcl/common/io.h:45:0, from /usr/include/pcl-1.8/pcl/io/file_io.h:42, from /usr/include/pcl-1.8/pcl/io/pcd_io.h:44, from /opt/ros/melodic/include/pcl_conversions/pcl_conversions.h:70, from /opt/ros/melodic/include/pcl_ros/point_cloud.h:9, from /root/catkin_ws/src/SLAM/include/Common.h:35, from /root/catkin_ws/src/SLAM/include/Semantic.h:7, from /root/catkin_ws/src/SLAM/src/Semantic.cpp:1: /usr/include/pcl-1.8/pcl/pcl_base.h:95:7: note: candidate: void pcl::PCLBase::setInputCloud(const PointCloudConstPtr&) [with PointT = pcl::PointXYZRGBA; pcl::PCLBase::PointCloudConstPtr = boost::shared_ptr >] setInputCloud (const PointCloudConstPtr &cloud); ^~~~~~~~~~~~~ /usr/include/pcl-1.8/pcl/pcl_base.h:95:7: note: no known conversion for argument 1 from 'std::shared_ptr >' to 'const PointCloudConstPtr& {aka const boost::shared_ptr >&}' SLAM/CMakeFiles/rds_slam.dir/build.make:341: recipe for target 'SLAM/CMakeFiles/rds_slam.dir/src/Semantic.cpp.o' failed make[2]: *** [SLAM/CMakeFiles/rds_slam.dir/src/Semantic.cpp.o] Error 1 CMakeFiles/Makefile2:3766: recipe for target 'SLAM/CMakeFiles/rds_slam.dir/all' failed ``` ## Solution The error is caused by "std::shared_ptr". "boost::shared_ptr" is used in PCL rather than std version. Therefore, the correct version is: ```cpp template pcl::PointCloud Semantic::filterPCD(boost::shared_ptr > t_input) { boost::shared_ptr > filtered(new pcl::PointCloud()); static pcl::VoxelGrid voxel; voxel.setLeafSize(0.05, 0.05, 0.05); voxel.setInputCloud(t_input); voxel.filter(*filtered); return *filtered; } ``` cover

No comments