在使用tf2::doTransform时候报错:
undefined reference to `void tf2::doTransform<sensor_msgs::PointCloud2_<std::allocator<void> > >(sensor_msgs::PointCloud2_<std::allocator<void> > const&, sensor_msgs::PointCloud2_<std::allocator<void> >&, geometry_msgs::TransformStamped_<std::allocator<void> > const&)'
tf2::doTransform在头文件tf2/convert.h中。
cmakelist中已经包含了tf2.
解决办法:
需要在cmakelist中包含 tf2_sensor_msgs
find_package(catkin REQUIRED COMPONENTS
roscpp
tf2
tf2_ros
tf2_msgs
tf2_sensor_msgs
geometry_msgs
sensor_msgs
)
并在在头文件中增加
#include "tf2_sensor_msgs/tf2_sensor_msgs.h"
再编译问题就解决了
参考:
https://answers.ros.org/question/262179/transform-pointcloud-with-tf2/