[compile error] "PCL conversions dont compile"
I trying to use a pcl with statistical filter and ROS.
I am using this code with this cmakeList.
When I try compile appear this error:
collect2: error: ld returned 1 exit status
make[2]: *** [pcl_manipulation/CMakeFiles/pcl_sample_visualizer.dir/build.make:409: /home/lidiaxp/workspace/devel/lib/pcl_manipulation/pcl_sample_visualizer] Error 1
make[1]: *** [CMakeFiles/Makefile2:6445: pcl_manipulation/CMakeFiles/pcl_sample_visualizer.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
make[2]: *** [pcl_manipulation/CMakeFiles/pcl_sample_filter.dir/build.make:409: /home/lidiaxp/workspace/devel/lib/pcl_manipulation/pcl_sample_filter] Error 1
make[1]: *** [CMakeFiles/Makefile2:6499: pcl_manipulation/CMakeFiles/pcl_sample_filter.dir/all] Error 2
make: *** [Makefile:160: all] Error 2
I believe that this error is because the pcl conversions package because when I try run a package without it works.
I install this package and ros-noetic-pcl-conversions. I am using Ubuntu 20.04 with ROS noetic and Python 3.8.
Ps. When I tested this code in another computer it works. So, I guess that the problem is some library that I have installed, as ros-noetic-pcl-conversions, or this (PCL Library), and I know don't how uninstall.
Update: including the code
#include<ros/ros.h>
#include<pcl/point_cloud.h>
#include<pcl_conversions/pcl_conversions.h>
#include<sensor_msgs/PointCloud2.h>
#include<pcl/filters/statistical_outlier_removal.h>
class cloud_filter{
public:
cloud_filter();
void cloud_sub_pub(const sensor_msgs::PointCloud2& input);
protected:
ros::NodeHandle nh;
ros::Subscriber pcl_sub;
ros::Publisher pcl_pub;
};
cloud_filter::cloud_filter()
{
pcl_sub = nh.subscribe("/orb_slam2_rgbd/map_points",10,&cloud_filter::cloud_sub_pub,this);
pcl_pub = nh.advertise<sensor_msgs::PointCloud2>("/orbslam/filtered/map_points",1);
}
void cloud_filter::cloud_sub_pub(const sensor_msgs::PointCloud2 & input)
{
pcl::PointCloud<pcl::PointXYZ> cloud, filtered_cloud;
sensor_msgs::PointCloud2 result;
pcl::fromROSMsg(input,cloud);
pcl::StatisticalOutlierRemoval<pcl::PointXYZ> statFilter;
statFilter.setInputCloud(cloud.makeShared());
statFilter.setMeanK(50);
statFilter.setStddevMulThresh(0.2);
statFilter.filter(filtered_cloud);
pcl::toROSMsg(filtered_cloud,result);
result.header.frame_id="map";
pcl_pub.publish(result);
}
int main(int argc,char ** argv)
{
ros::init(argc,argv,"statistical_outlier_removal_filter");
cloud_filter filter;
ros::spin();
return 0;
}
and CmakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(pcl_manipulation)
find_package(PCL REQUIRED)
find_package(catkin REQUIRED COMPONENTS
pcl_conversions
pcl_msgs
pcl_ros
sensor_msgs
)
find_package(Boost REQUIRED COMPONENTS system)
catkin_package(
LIBRARIES pcl_manipulation
CATKIN_DEPENDS pcl_conversions pcl_msgs pcl_ros sensor_msgs
DEPENDS system_lib
)
include_directories(include ${PCL_INCLUDE_DIRS})
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
link_directories(${PCL_LIBRARY_DIRS})
add_executable(pcl_sample src/pcl_sample.cpp)
target_link_libraries(pcl_sample ${catkin_LIBRARIES} ${PCL_LIBRARIES})
add_executable(pcl_sample_reader src/pcl_sample_reader.cpp)
target_link_libraries(pcl_sample_reader ${catkin_LIBRARIES} ${PCL_LIBRARIES})
add_executable(pcl_sample_writer src/pcl_sample_writer.cpp)
target_link_libraries(pcl_sample_writer ${catkin_LIBRARIES} ${PCL_LIBRARIES})
add_executable(pcl_sample_visualizer src/pcl_sample_visualizer.cpp)
target_link_libraries(pcl_sample_visualizer ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
add_executable(pcl_sample_filter src/pcl_sample_filter.cpp)
target_link_libraries(pcl_sample_filter ${catkin_LIBRARIES};${PCL_LIBRARIES} ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})
Asked by lidiaxp on 2021-04-27 13:47:08 UTC
Comments