ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Undefined reference to pcl_ros::transformPointCloud

asked 2014-11-27 08:45:47 -0600

mennamatteo gravatar image

I am migrating to catkin and I am trying to compile a node already compiled under rosbuild. I have this message error: undefined reference to pcl_ros::transformPointCloud(std::string const&, sensor_msgs::PointCloud2_<std::allocator<void> > const&, sensor_msgs::PointCloud2_<std::allocator<void> >&, tf::TransformListener const&)

I followed the migration guide. This is the CMakeList:

cmake_minimum_required(VERSION 2.8.3)
project(path_planner)   

find_package(catkin REQUIRED 
    COMPONENTS 
    dynamic_reconfigure
    pcl_conversions
        roscpp
    tf
    rospy
    geometry_msgs 
    interactive_markers

)
find_package(PCL 1.7 REQUIRED)

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES ${PROJECT_NAME} 
  CATKIN_DEPENDS 
    geometry_msgs 
    pcl_conversions 
    roscpp 
    rospy 
    tf 
    std_msgs
    pcl_ros
    interactive_markers
  DEPENDS PCL 
)

include_directories(include ${catkin_INCLUDE_DIRS}  ${PCL_INCLUDE_DIRS})

 add_library(normalestimation src/NormalEstimationPcl.cpp)
 add_library(dynamicjoinpcl src/DynamicJoinPcl.cpp)
 add_library(clusterpcl src/ClusterPcl.cpp)
 add_library(conversionpcl src/ConversionPcl.cpp)
 add_library(travanalpcl src/TravAnal.cpp)
 add_library(pathplanning src/PathPlanning.cpp)
 add_library(marker src/MarkerController.cpp)

add_executable(mapping src/mapping.cpp)
add_executable(traversability src/traversability.cpp)
add_executable(pathPlanner src/pathPlanner.cpp)

target_link_libraries(mapping dynamicjoinpcl  conversionpcl normalestimation  ${catkin_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(traversability clusterpcl  conversionpcl travanalpcl  ${catkin_LIBRARIES} ${PCL_LIBRARIES})
target_link_libraries(pathPlanner marker  pathplanning   ${catkin_LIBRARIES} ${PCL_LIBRARIES})

install(FILES
    launch/test.launch
    launch/test.yaml   
   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
 )

And this is the package.xml

<buildtool_depend>catkin</buildtool_depend>

<build_depend>message_runtime</build_depend>   <build_depend>roscpp</build_depend>  
<build_depend>rospy</build_depend>  
<build_depend>dynamic_reconfigure</build_depend>
<build_depend>tf</build_depend>  
<build_depend>std_msgs</build_depend> 
<build_depend>geometry_msgs</build_depend>
<build_depend>visualization_msgs</build_depend>
<build_depend>pcl_ros</build_depend>  
<build_depend>pcl_conversions</build_depend>   <build_depend>interactive_markers</build_depend>
<build_depend>nav_msgs</build_depend> 
<build_depend>laser_geometry</build_depend>
<build_depend>dynamic_reconfigure</build_depend>
<build_depend>libpcl-all-dev</build_depend>  

<run_depend>message_runtime</run_depend>
<run_depend>roscpp</run_depend>  
<run_depend>rospy</run_depend>  
<run_depend>dynamic_reconfigure</run_depend>
<run_depend>tf</run_depend>  
<run_depend>std_msgs</run_depend>  
<run_depend>geometry_msgs</run_depend>
<run_depend>visualization_msgs</run_depend>
<run_depend>libpcl-all</run_depend>  
<run_depend>pcl_conversions</run_depend>
<run_depend>interactive_markers</run_depend>
<run_depend>nav_msgs</run_depend>  
<run_depend>laser_geometry</run_depend>
<run_depend>dynamic_reconfigure</run_depend>
<run_depend>pcl_ros</run_depend>

<test_depend>python-mock</test_depend>

</package>

What I forget????

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2014-12-05 05:20:12 -0600

luator gravatar image

updated 2014-12-05 14:09:07 -0600

I also had a linking problem with pcl_ros::transformPointCloud() and solved it by changing the point type from PointXY to PointXYZ (pcl_ros::transformPointCloud() can only cope with 3d-points).

Edit: Try #include <pcl_ros/impl/transfoms.hpp>. This solved the linker error and gave me more helpful compiler errors instead (complaining about the missing 'z'). Though your problem seems to be different, it might give you a more helpful error, too.

edit flag offensive delete link more

Comments

In my case it can be both PointXYZ and PointXYZRGBNormal

mennamatteo gravatar image mennamatteo  ( 2014-12-05 10:04:43 -0600 )edit

@mennamatteo: They should both be ok, my problem was the missing Z. Maybe try #include <pcl_ros/impl/transfoms.hpp>, see edit.

luator gravatar image luator  ( 2014-12-05 14:09:22 -0600 )edit

#include <pcl_ros/impl/transforms.hpp> helped me too (I have a custom point type). I think the function needs to be re-compiles for custom point types and is pre-compiled for the standard ones ..?

stfn gravatar image stfn  ( 2016-06-01 07:56:31 -0600 )edit
1

answered 2020-11-27 17:16:38 -0600

schwarmcyc gravatar image
sudo apt install ros-melodic-pcl-ros
sudo apt install ros-melodic-pcl-conversions

works. ubuntu 18.04.3 . ROS melodic . This is my CMakeLists.txt for you reference Wrap up opencv(v3.2) gtSAM PCL(1.8)

cmake_minimum_required(VERSION 2.8.3)
project(icp)

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -pthread")


find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  geometry_msgs
  message_generation
  nav_msgs
  pcl_conversions
  pcl_ros
  roscpp
  rospy
  sensor_msgs
  std_msgs
  tf
)

find_package(OpenMP REQUIRED)
find_package(PCL REQUIRED QUIET)
find_package(OpenCV REQUIRED QUIET)
find_package(GTSAM REQUIRED QUIET)

add_message_files(
  DIRECTORY msg
  FILES
  cloud_info.msg
)


generate_messages(
  DEPENDENCIES
  geometry_msgs
  std_msgs
  nav_msgs
  sensor_msgs
)

catkin_package(
  INCLUDE_DIRS include
  DEPENDS PCL GTSAM

  CATKIN_DEPENDS 
  std_msgs
  nav_msgs
  geometry_msgs
  pcl_conversions
  sensor_msgs
  message_runtime 
  message_generation
)

# include directories
include_directories(
    include
    ${catkin_INCLUDE_DIRS}
    ${PCL_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
    ${GTSAM_INCLUDE_DIR}
)

# link directories
link_directories(
    include
    ${PCL_LIBRARY_DIRS}
  ${OpenCV_LIBRARY_DIRS}
  ${GTSAM_LIBRARY_DIRS}
)

add_executable(${PROJECT_NAME}_icp_localization src/icp_localization.cpp)
target_link_libraries(${PROJECT_NAME}_icp_localization ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} gtsam)
edit flag offensive delete link more

Comments

And if you wonder why

undefined reference to `void pcl_ros::transformPointCloud<pcl::PointXYZ>(pcl::PointCloud<pcl::PointXYZ> const&, pcl::PointCloud<pcl::PointXYZ>&, tf::Transform const&)'

means cannot find .so linking PCL to ROS that function share objects.

schwarmcyc gravatar image schwarmcyc  ( 2020-11-27 17:19:32 -0600 )edit
0

answered 2014-11-29 10:02:45 -0600

I had the same problem. You need to add the right namespace "pcl_ros" to the find_package section...


find_package(catkin REQUIRED COMPONENTS COMPONENTS dynamic_reconfigure pcl_conversions roscpp tf rospy geometry_msgs interactive_markers pcl_ros )

edit flag offensive delete link more

Comments

I already tried, but it does not work. it return the same error, plus undefined reference to pcl::VoxelGrid<pcl::PointXYZRGBNormal>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBNormal>&) that before there wasn't... unbelievable

mennamatteo gravatar image mennamatteo  ( 2014-12-02 06:41:52 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2014-11-27 08:45:47 -0600

Seen: 3,732 times

Last updated: Nov 27 '20