Ask Your Question
0

tf2 tutorial writing broadcaster -- compile error

asked 2015-06-17 15:58:52 -0600

nitekrawler gravatar image

updated 2015-06-17 18:07:39 -0600

Hi,

I'm following the tutorial at http://wiki.ros.org/tf2/Tutorials/Wri...

I copy-and-pasted the code, made changes to CMakeLists.txt, but I see this error when I catkin_make:

CMakeFiles/turtle_tf2_broadcaster.dir/src/turtle_tf2_broadcaster.cpp.o: In function `poseCallback(boost::shared_ptr<turtlesim::Pose_<std::allocator<void> > const> const&)':
turtle_tf2_broadcaster.cpp:(.text+0x40): undefined reference to `tf2_ros::TransformBroadcaster::TransformBroadcaster()'
turtle_tf2_broadcaster.cpp:(.text+0x1d3): undefined reference to `tf2_ros::TransformBroadcaster::sendTransform(geometry_msgs::TransformStamped_<std::allocator<void> > const&)'
collect2: ld returned 1 exit status

I'm fairly sure I've followed each step correctly (and the Python version works for me). I checked /opt/ros/hydro/include/tf2_ros/transform_broadcaster.h and sendTransform() seems to be defined:

  /** \brief Send a TransformStamped message
   * The stamped data structure includes frame_id, and time, and parent_id already.  */
  void sendTransform(const geometry_msgs::TransformStamped & transform);

  /** \brief Send a vector of TransformStamped messages
   * The stamped data structure includes frame_id, and time, and parent_id already.  */
  void sendTransform(const std::vector<geometry_msgs::TransformStamped> & transforms);

Is there something else with the C++ version that I'm overlooking?

I'm using Hydro with 12.04.5.

Thanks!


EDIT with CMakeLists.txt and compile output:

CMakeList.txt:

make_minimum_required(VERSION 2.8.3)
project(learning_tf2)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  tf2
  turtlesim
)

## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES learning_tf2
#  CATKIN_DEPENDS roscpp rospy tf2 turtlesim
#  DEPENDS system_lib
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

install(PROGRAMS
  nodes/turtle_tf2_broadcaster.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(FILES
  start_demo.launch
  # myfile2
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

add_executable(turtle_tf2_broadcaster src/turtle_tf2_broadcaster.cpp)
target_link_libraries(turtle_tf2_broadcaster ${catkin_LIBRARIES})

catkin_make output:

$ catkin_make VERBOSE=1
Base path: /home/local/nitekrawler/catkin_ws
Source space: /home/local/nitekrawler/catkin_ws/src
Build space: /home/local/nitekrawler/catkin_ws/build
Devel space: /home/local/nitekrawler/catkin_ws/devel
Install space: /home/local/nitekrawler/catkin_ws/install
####
#### Running command: "cmake /home/local/nitekrawler/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/local/nitekrawler/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/local/nitekrawler/catkin_ws/install" in "/home/local/nitekrawler/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/local/nitekrawler/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/local/nitekrawler/adn/AdnSensors/rigs/handheld-backyard-rig/devel;/home/local/nitekrawler/catkin_ws/devel;/opt/ros/hydro
-- This workspace overlays: /home/local/nitekrawler/adn/AdnSensors/rigs/handheld-backyard-rig/devel;/home/local/nitekrawler/catkin_ws/devel;/opt/ros/hydro
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Python version: 2.7
-- Using Debian Python package layout
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/local/nitekrawler/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- catkin 0.5.90
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 3 packages in topological order:
-- ~~  - imu_test
-- ~~  - learning_tf
-- ~~  - learning_tf2
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'imu_test'
-- ==> add_subdirectory(imu_test)
-- +++ processing catkin package: 'learning_tf'
-- ==> add_subdirectory(learning_tf)
-- Using these message generators: gencpp;genlisp;genpy
-- +++ processing catkin package: 'learning_tf2'
-- ==> add_subdirectory(learning_tf2)
-- Using these message generators: gencpp;genlisp;genpy
-- Configuring done
-- Generating done
-- Build files have been written to: /home/local/nitekrawler/catkin_ws/build
####
#### Running command: "make VERBOSE=1 -j4 -l4" in "/home/local/nitekrawler/catkin_ws/build"
####
/usr/bin/cmake -H/home/local/nitekrawler/catkin_ws/src -B/home/local/nitekrawler/catkin_ws/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake ...
(more)
edit retag flag offensive close merge delete

Comments

2

Please post your CMakeLists.txt contents, as well as your full console output of the compile. (VERBOSE=1 will give you more info as well.)

It looks like you're missing some link flags.

tfoote gravatar imagetfoote ( 2015-06-17 17:36:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-18 17:06:11 -0600

tfoote gravatar image

From the missing symbol it looks like you need add tf2_ros to your find_package(catkin... list

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-17 15:58:52 -0600

Seen: 952 times

Last updated: Jun 18 '15