Reputation: 727
I am asking here since answers.ros.org is hanging when posting...
we are currently compiling a PCL-1.6 software using catkin build system on 64-bit Ubuntu Linux 12.10 Quantal Quetzal. We are using ROS Groovy installed in the default path (Groovy and Hydro installed on the same system, Groovy workspace sourced while working now on groovy).
We have been referring to wiki tutorias of ros (cannot link with my karma here) to draft a CMakeLists.txt setup for the project. Since the tutorial only states 2 lines about CMakeLists.txt and recommends using the default template we are asking for guidance here.
The project is using a PCL software that supposedly should run in a ROS node sending data to the network. We have the original implementation in PCL-1.7 but with minimal modifications it runs on PCL-1.6, too, and now we are integrating it into ROS.
We have added ROS required headers in the code, and ros::init, and ros::NodeHandle, but what else is absolutely required for the ROS node to run PCL-1.6?
To make things not easier the least, OpenCV and BOOST are being used, too! (They are absolutely amazing libraries, when they work)
Currently, a problem is: a warning about conflicting libraries
/usr/bin/ld: warning: libpcl_sample_consensus.so.1.6, needed by>
opt/ros/groovy/lib/libpcl_filters.so, may conflict with > libpcl_sample_consensus.so.1.7
/usr/bin/ld: warning: libpcl_io.so.1.6, needed by /opt/ros/groovy/lib/libpcl_visualization.so, may conflict with libpcl_io.so.1.7
/usr/bin/ld: warning: libpcl_common.so.1.7, needed by /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpcl_sample_consensus.so, may conflict with libpcl_common.so.1.6
even though no paths with pcl-1.7 are provided to catkin. I did create the package with pcl-1.7 dependency, but long since has removed dependency of pcl-1.7 from CMakeLists.txt, package.xml, and did catkin_make clean (does this not remove the dependency from all cmake files?).
My question is how should I change my CMakeLists.txt setup to solve this linking error? Ultimately, the problem leads to segmentation faults in the program => PCL RANSAC segmentation filters crash.
Here's the current CMakeLists.txt (in short) that successfully compiles and runs the project that we have written:
cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)
project(famous_emutanen_bv)
set(famous_emutanen_bv_srcs src/disparity.cpp)
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
# pcl
pcl_ros
roscpp
rospy
sensor_msgs
std_msgs
)
find_package(PCL 1.6 REQUIRED)
find_package(OpenCV 2.2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread)
catkin_package(
INCLUDE_DIRS include
# LIBRARIES famous_emutanen_bv
# CATKIN_DEPENDS geometry_msgs pcl-1.7 pcl_ros roscpp rospy sensor_msgs std_msgs
# DEPENDS system_lib
)
include_directories(include
${catkin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
include_directories(/usr/include/vtk-5.8)
link_directories(${PCL_LIBRARY_DIRS} ${OpenCV_LIBRARY_DIRS}) #
add_definitions(${PCL_DEFINITIONS} ${OpenCV_DEFINITIONS}) #
add_executable(famous_emutanen_bv ${famous_emutanen_bv_srcs})
target_link_libraries(famous_emutanen_bv ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES} libvtkCommon.so libvtkFiltering.so libvtkRendering.so) #
Should be added, this CMakeLists.txt compiles and runs against stand-alone PCL installation (1.6 or 1.7) nicely. and here is the package.xml:
<?xml version="1.0"?>
<package>
<name>famous_emutanen_bv</name>
<version>0.0.0</version>
<description>The famous_emutanen_bv package</description>
<maintainer email="emutanen@xx">emutanen</maintainer>
<license>GPLv3</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>pcl_ros</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>pcl_ros</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>std_msgs</run_depend>
<export>
<!-- <metapackage/> -->
</export>
</package>
I have tried to trace down the segfault with GDB and we can interestingly see that sample_consensus library changes in the middle of things from 1.6 to 1.7
(gdb) backtrace
#0 0x00007ffff396caed in pcl::SampleConsensusModelCylinder<pcl::PointXYZ, pcl::Normal>::computeModelCoefficients(std::vector<int, std::allocator<int> > const&, Eigen::Matrix<float, -1, 1, 0, -1, 1>&) ()
from /usr/lib/libpcl_sample_consensus.so.1.7
#1 0x00007ffff4cb6166 in pcl::RandomSampleConsensus<pcl::PointXYZ>::computeModel(int) () from /opt/ros/groovy/lib/libpcl_segmentation.so.1.6
#2 0x00007ffff4cafd1c in pcl::SACSegmentation<pcl::PointXYZ>::segment(pcl::PointIndices_<std::allocator<void> >&, pcl::ModelCoefficients_<std::allocator<void> >&) () from /opt/ros/groovy/lib/libpcl_segmentation.so.1.6
#3 0x000000000049ac23 in famous::segmentCylinder(boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >&, boost::shared_ptr<pcl::ModelCoefficients_<std::allocator<void> > >) ()
#4 0x00000000004a1164 in famous::updatePointCloud() ()
#5 0x00000000004a6fa7 in main ()
What should we do with CMakeLists.txt in order to solve the problem? Hopefully someone can guide us in the right direction, while at it, happy holidays everyone!
Upvotes: 1
Views: 3066
Reputation: 1043
Not sure if this will help ... I'm using OpenCV, Boost and PCL in a catkin package. What worked for me was
in package.xml
<?xml version="1.0"?>
...
<buildtool_depend>catkin</buildtool_depend>
...
<build_depend>pcl_ros</build_depend>
<build_depend>pcl</build_depend>
<run_depend>pcl</run_depend>
<run_depend>pcl_ros</run_depend>
...
</package>
in CMakeLists.txt
find_package(catkin REQUIRED
...
pcl
pcl_ros
...
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES famous_emutanen_bv
CATKIN_DEPENDS geometry_msgs pcl pcl_ros roscpp rospy sensor_msgs std_msgs
)
Now you need to include pcl headers with #include <pcl-1.6/pcl/...>
And then you dont need
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
nor linking ${PCL_LIBRARIES}. It will be contained in ${catkin_LIBRARIES}.
Hope this works. Cheers
Upvotes: 1