Undefined symbol in custom costmap layer during runtime caused by tf2 Buffer transform
I am writing a custom costmap layer to read data from a radar sensor and turn it into a costmap, and I'm facing some issues running it. I get the following error when it runs:
symbol lookup error: /home/mkhoory/sdc/catkin_ws/devel/lib//libRadarDataLayer.so: undefined symbol: _ZN3tf212getTimestampIN13geometry_msgs15PolygonStamped_ISaIvEEEEERKN3ros4TimeERKT_
What the related code is trying to do is create a PolygonStamped from the radar data and convert it to world coordinates via tf2.
tfBuffer.transform(polyRadar, polyWorld, globalFrame);
I'm not sure what I'm doing wrong here. The code compiles fine, and it's only when the plugin reaches the above line that it tells me that it's an undefined reference. I tried including tf2_geometry_msgs.h but that didn't do anything. What am I missing?
EDIT: Here's my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.3)
project(my_project_processing)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
geometry_msgs
message_generation
tf
tf2
tf2_geometry_msgs
costmap_2d
dynamic_reconfigure
my_project_sensors
)
find_package(Boost REQUIRED COMPONENTS system thread)
add_message_files(
FILES
CommandMessage.msg
)
generate_messages(
DEPENDENCIES
std_msgs
geometry_msgs
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES
CATKIN_DEPENDS roscpp rospy std_msgs tf message_runtime geometry_msgs message_generation
DEPENDS Boost
)
# let's use C++11
SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
include_directories(
include
${tf2_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
)
# Costmap2D Layer plugin
add_library(RadarDataLayer lib/RadarDataLayer.cpp)
target_link_libraries(RadarDataLayer ${Boost_LIBRARIES} ${catkin_LIBRARIES})
This is a (deferred) linker error, not a compilation issue.
Please post your
CMakeLists.txt
-- make sure to remove all the boilerplate comments from it first (lines starting with#
).I think I may have found the problem. tf2_geometry_msgs only supports native transformations certain types of messages from geometry_msgs, and PolygonStamped isn't one of them, according to this link http://wiki.ros.org/tf2_geometry_msgs . I'm not sure yet so I'm going to try another type first.
I would expect to see a compiler error ("no candidates" or "no matching function call for ..") in that case, not a linker error. A 'missing symbol error' basically means that the compiler embedded the use of an external symbol in your library, but you didn't link against all needed dependencies.
Hi, I added my CMakeLists.