Problem with tf tutorial
I followed the tutorial http://wiki.ros.org/tf/Tutorials/Writing%20a%20tf%20broadcaster%20%28C%2B%2B%29
I encountered this error while doing catkin_make
CMakeFiles/turtle_tf_broadcaster.dir/src/turtle_tf_broadcaster.cpp.o: In function `poseCallback(boost::shared_ptr<turtlesim::Pose_<std::allocator<void> > const> const&)':
turtle_tf_broadcaster.cpp:(.text+0x57): undefined reference to `tf::TransformBroadcaster::TransformBroadcaster()'
turtle_tf_broadcaster.cpp:(.text+0x211): undefined reference to `tf::TransformBroadcaster::sendTransform(tf::StampedTransform const&)'
collect2: error: ld returned 1 exit status
learning_tf/CMakeFiles/turtle_tf_broadcaster.dir/build.make:113: recipe for target '/home/calvin/catkin_ws/devel/lib/learning_tf/turtle_tf_broadcaster' failed
make[2]: *** [/home/calvin/catkin_ws/devel/lib/learning_tf/turtle_tf_broadcaster] Error 1
CMakeFiles/Makefile2:1482: recipe for target 'learning_tf/CMakeFiles/turtle_tf_broadcaster.dir/all' failed
make[1]: *** [learning_tf/CMakeFiles/turtle_tf_broadcaster.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
I don't think I have problem with the CMakeLists but to just make sure
I put
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
tf
turtlesim
)
and
add_executable(turtle_tf_broadcaster src/turtle_tf_broadcaster.cpp)
target_link_libraries(turtle_tf_broadcaster ${catkin_LIBRARIES})
and my package.xml looks has this inside
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>tf</build_depend>
<build_depend>turtlesim</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>tf</build_export_depend>
<build_export_depend>turtlesim</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>tf</exec_depend>
<exec_depend>turtlesim</exec_depend>
Please tell me what is the error with this?
Complete CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(learning_tf)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
tf
turtlesim
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES learning_tf
# CATKIN_DEPENDS roscpp rospy tf turtlesim
# DEPENDS system_lib
)
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
add_executable(turtle_tf_broadcaster src/turtle_tf_broadcaster.cpp)
target_link_libraries(turtle_tf_broadcaster ${catkin_LIBRARIES})
Asked by calvintanct on 2019-03-25 11:30:47 UTC
Answers
Now that you have the full Cmakelists, I'd put $1 that your issue is here
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES learning_tf
# CATKIN_DEPENDS roscpp rospy tf turtlesim
# DEPENDS system_lib
)
You should read that snippet above here and try to understand what this is doing. To get you going, you need to uncomment the CATKIN_DEPENDS and probably the INCLUDE_DIRS lines.
Asked by stevemacenski on 2019-03-26 14:21:06 UTC
Comments
Since he is using catkin to build his project, CATKIN_DEPENDS should be uncommented, and all additional ros packages should be listed there as well
Asked by Dyson sphere on 2019-03-26 19:58:19 UTC
I believe that is what i said above.
Asked by stevemacenski on 2019-03-26 20:05:22 UTC
Hello, thank you for the answer, I will update again if it is working or not. I used the same ros package with same package.xml and CMakeLists.txt in different installation Ubuntu 16 and Ros Kinetic, and it is working. However it cannot work in my setup Ubuntu 18 Ros Melodic. It seems a bit weird to me
Asked by calvintanct on 2019-03-26 22:07:42 UTC
Is your error solved @calvintanct .Even after uncomment as mentioned in answer ,I am facing the same error.
Asked by charvi on 2019-06-27 02:05:19 UTC
Comments
Please include your full CMakelists file. Its definitely a problem with your CMakeLists. I would suspect you didnt add the packages to the catkin_package() macro
Asked by stevemacenski on 2019-03-25 14:43:13 UTC
hello, I have included my CMakeLists inside my posts here. There is a lot of comments generated from auto catkin_create_pkg learning_tf tf roscpp rospy turtlesim
Asked by calvintanct on 2019-03-26 06:48:42 UTC
@calvintanct I've removed the majority of the comments from your CMakeLists.txt file as they're not necessary
Asked by jayess on 2019-03-26 14:45:59 UTC