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

Undefined reference to tf2::fromMsg

asked 2017-10-22 12:28:19 -0600

lalten gravatar image

updated 2017-10-22 12:30:10 -0600

In this code:

visualization_msgs::Marker marker_msg;
geometry_msgs::TransformStamped geo_tf_stamped;
tf2::Stamped<tf2::Transform> tf2_stamped;
geo_tf_stamped = tf_buffer.lookupTransform("map", "camera_image", bboxes_msg->header.stamp, ros::Duration(1.0));
tf2::convert(geo_tf_stamped.transform, tf2_stamped);
tf2::toMsg(tf2_stamped, marker_msg.pose);

My linker can't find a tf2::fromMsg implementation:

In function `void tf2::impl::Converter<true, false>::convert<geometry_msgs::Transform_<std::allocator<void> >, tf2::Stamped<tf2::Transform> >(geometry_msgs::Transform_<std::allocator<void> > const&, tf2::Stamped<tf2::Transform>&)':
[...]
undefined reference to `void tf2::fromMsg<geometry_msgs::Transform_<std::allocator<void> >, tf2::Stamped<tf2::Transform> >(geometry_msgs::Transform_<std::allocator<void> > const&, tf2::Stamped<tf2::Transform>&)'

In my CMakeLists.txt I already have these packages:

find_package(catkin REQUIRED COMPONENTS
  roscpp
  vision_inference
  vision_inference_msgs
  visualization_msgs
  geometry_msgs
  tf2_geometry_msgs
  tf2_ros
  tf2
  tf
)

Which package do i need to add to get the tf2::fromMsg linked? Or am I doing something else wrong?

edit retag flag offensive close merge delete

Comments

I'm using ROS Kinetic and if I run ls /opt/ros/kinetic/lib/libtf* I have the following files: libtf2_ros.so, libtf2.so, libtf_conversions.so, libtf.so.

What is your output if you run the same command considering the path of your ROS Version?

Ruben Alves gravatar image Ruben Alves  ( 2017-10-23 05:38:46 -0600 )edit

same: /opt/ros/lunar/lib/libtf2_ros.so, /opt/ros/lunar/lib/libtf_conversions.so, /opt/ros/lunar/lib/libtf2.so, /opt/ros/lunar/lib/libtf.so.

lalten gravatar image lalten  ( 2017-10-23 05:44:55 -0600 )edit

I have the same problem with indigo. I included <tf2_geometry_msgs/tf2_geometry_msgs.h>, added tf2_geometry_msgs to package.xml and CMakeLists.txt, and compile with catkin-tools. Could this be related to using C++11 standard?

galou gravatar image galou  ( 2018-04-23 10:13:27 -0600 )edit

Hello, same problem, my shell complaint : /home/user/workspace/devel/lib/libmoveit_ros_benchmarks.so.0.9.11: undefined reference tovoid tf2::fromMsg<geometry_msgs::quaternion_<std::allocator<void> >, tf2::Quaternion>(geometry_msgs::Quaternion_<std::allocator<void> > const&, tf2::Quaternion&)' `

fer gravatar image fer  ( 2018-11-08 10:58:51 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-04-23 12:33:04 -0600

tfoote gravatar image

tf2::fromMsg is a templated function so it is not expected to be in the libraries and found by the linker, you need to make sure to have the correct include is available.

However your problem appears that you are trying to convert a Transform into a TransformStamped which isn't going to work because they are not holding the same data. You won't find conversions like that. You need to not remove the .transform from your call like: tf2::convert(geo_tf_stamped, tf2_stamped); to have matching datatypes.

edit flag offensive delete link more

Comments

I still had the error of undefined void tf2::doTransform(Pose &, Pose &, TransformStamped&). The file documented at api does not correspond to my package ros-indigo-tf2-geometry-msgs v0.5.17.

galou gravatar image galou  ( 2018-04-24 01:03:18 -0600 )edit

Yes, there's an unreleased patch adding support for Pose that's expected in the next release: https://github.com/ros/geometry2/pull...

tfoote gravatar image tfoote  ( 2018-04-24 01:17:00 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-10-22 12:28:19 -0600

Seen: 7,104 times

Last updated: Apr 23 '18