tf2_ros::Buffer.transform() causes "undefined reference" errors
I am trying to use tf2_ros::Buffer.transform()
and when trying to compile I am getting "undefined reference" errors from the linker. I don't link I'm missing any libraries, because tf2_ros::Buffer.lookupTransform()
compiles just fine and I added all possible tf2 libraries. Am I doing something wrong or does it seem to be a bug?
Below is the code of my test node and error messages. And my entire test package is at https://github.com/tommises/ros-tf2-i...
For what it's worth, tf::TransformListener.transformPoint()
works fine as well. Is there any risk in mixing tf and tf2?
- ROS version: kinetic
- OS: Ubuntu 16.04
#include <ros/ros.h>
#include <geometry_msgs/PointStamped.h>
#include <tf2_ros/transform_listener.h>
tf2_ros::Buffer tfBuffer;
void ellipsevsCallback(const geometry_msgs::PointStamped::ConstPtr& point_raw){
geometry_msgs::TransformStamped transformStamped;
transformStamped = tfBuffer.lookupTransform("global", "local", ros::Time(0));
geometry_msgs::PointStamped point_tf;
/* This is the line which fails to compile. */
tfBuffer.transform(*point_raw, point_tf, "local");
}
int main(int argc, char** argv){
ros::init(argc, argv, "tf2_test_tf2_point");
tf2_ros::TransformListener tfListener(tfBuffer);
ros::NodeHandle node;
ros::Subscriber topic_sub = node.subscribe("test/point", 1, &ellipsevsCallback);
ros::spin();
return 0;
};
linker errors
[100%] Linking CXX executable tf2_test_tf2_point
CMakeFiles/tf2_test_tf2_point.dir/src/tf2_test_tf2_point.cpp.o: In function `geometry_msgs::PointStamped_<std::allocator<void> >& tf2_ros::BufferInterface::transform<geometry_msgs::PointStamped_<std::allocator<void> > >(geometry_msgs::PointStamped_<std::allocator<void> > const&, geometry_msgs::PointStamped_<std::allocator<void> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::Duration) const':
tf2_test_tf2_point.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs13PointStamped_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs13PointStamped_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE]+0x69): undefined reference to `ros::Time const& tf2::getTimestamp<geometry_msgs::PointStamped_<std::allocator<void> > >(geometry_msgs::PointStamped_<std::allocator<void> > const&)'
tf2_test_tf2_point.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs13PointStamped_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs13PointStamped_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE]+0x7b): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const& tf2::getFrameId<geometry_msgs::PointStamped_<std::allocator<void> > >(geometry_msgs::PointStamped_<std::allocator<void> > const&)'
tf2_test_tf2_point.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs13PointStamped_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs13PointStamped_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE]+0xc8): undefined reference to `void tf2::doTransform<geometry_msgs::PointStamped_<std::allocator<void> > >(geometry_msgs::PointStamped_<std::allocator<void> > const&, geometry_msgs::PointStamped_<std::allocator<void> >&, geometry_msgs::TransformStamped_<std::allocator<void> > const&)'
collect2: error: ld returned 1 exit status
tf2_test/CMakeFiles/tf2_test_tf2_point.dir/build.make:120: recipe for target 'tf2_test/tf2_test_tf2_point' failed
make[2]: *** [tf2_test/tf2_test_tf2_point] Error 1
CMakeFiles/Makefile2:1340: recipe for target 'tf2_test/CMakeFiles/tf2_test_tf2_point.dir/all' failed
make[1]: *** [tf2_test/CMakeFiles/tf2_test_tf2_point.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
and my CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(tf2_test)
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
rospy
tf2
tf2_bullet
tf2_eigen
tf2_geometry_msgs
tf2_kdl
tf2_msgs
tf2_py
tf2_ros
tf2_sensor_msgs
tf2_tools
tf
)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(tf2_test_tf2_point src/tf2_test_tf2_point.cpp)
add_executable(tf2_test_tf1_point src/tf2_test_tf1_point.cpp)
target_link_libraries(tf2_test_tf2_point
${catkin_LIBRARIES}
)
target_link_libraries(tf2_test_tf1_point
${catkin_LIBRARIES}
)