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

Undefined symbol error when using tf2_ros::BufferInterface::transform

asked 2020-03-27 19:19:11 -0500

alexe gravatar image

updated 2020-03-27 19:31:13 -0500

I'm trying to use the tf2_ros::BufferInterface::transform method on a PointCloud2 message like so (tf_buffer_ is a tf2_ros::Buffer object):

void someMethod(const sensor_msgs::PointCloud2ConstPtr& input_cloud)
{
  const auto transformed_cloud = tf_buffer_.transform<sensor_msgs::PointCloud2>(*input_cloud,
      some_frame_id, ros::Duration(0.1));

  ... do some stuff ...
}

The code compiles fine, but fails with a symbol lookup error during run time:

undefined symbol: ros::Time const& tf2::getTimestamp<sensor_msgs::PointCloud2_<std::allocator<void> > >(sensor_msgs::PointCloud2_<std::allocator<void> > const&)

I have no idea what is going on. I tried to include all sorts of packages (tf2, tf2_ros, tf2_msgs, tf2_sensor_msgs, geometry_msgs, sensor_msgs) in both my CMakeLists and my package.xml, but that doesn't help.

It's worthwhile mentioning that I'm using the same tf2_ros::Buffer object before this point in the program to transform a geometry_msgs::PointStamped message, which has the same frame_id as the point cloud, into the same target frame, and there it works just fine. Just for this PointCloud2 message it seems to fail.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2020-03-27 20:23:51 -0500

tfoote gravatar image

To get template instantiations you also need to make sure to #include the right headers.

For transforming PointCloud2 datatypes you need #include "tf2_sensor_msgs/tf2_sensor_msgs.h" in your source code to resolve the symbols.

That's in addition to having tf2_sensor_msgs appropriately in your CMakeLists.txt and package.xml.

edit flag offensive delete link more

Comments

That solved it, thank you so much! Follow-up question (since I'm a bit of a noob): Why does this only fail at run time and not already at compile time? Or put differently, I guess I don't yet understand why I need to include tf2_sensor_msgs/tf2_sensor_msgs.h at all, since I'm not explicitly using any of its types in my code.

alexe gravatar image alexe  ( 2020-03-28 06:44:34 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-03-27 19:19:11 -0500

Seen: 886 times

Last updated: Mar 27 '20