How to use tf2_ros::MessageFilter with geometry_msgs::PoseArray ?
I followed the tutorial for tf2_ros::MessageFilter
to transform stamped data from one frame to the other. The node compiled with no difficulty. However, I want to do the same for the PoseArray
datatype, for which I am getting the following compilation error:
/usr/bin/ld: CMakeFiles/tf_listener_test.dir/src/tf_listener_test.cpp.o: in function `geometry_msgs::PoseArray_<std::allocator<void> >& tf2_ros::BufferInterface::transform<geometry_msgs::PoseArray_<std::allocator<void> > >(geometry_msgs::PoseArray_<std::allocator<void> > const&, geometry_msgs::PoseArray_<std::allocator<void> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, ros::Duration) const':
tf_listener_test.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs10PoseArray_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs10PoseArray_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE]+0x5c): undefined reference to `ros::Time const& tf2::getTimestamp<geometry_msgs::PoseArray_<std::allocator<void> > >(geometry_msgs::PoseArray_<std::allocator<void> > const&)'
/usr/bin/ld: tf_listener_test.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs10PoseArray_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs10PoseArray_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE]+0x6e): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const& tf2::getFrameId<geometry_msgs::PoseArray_<std::allocator<void> > >(geometry_msgs::PoseArray_<std::allocator<void> > const&)'
/usr/bin/ld: tf_listener_test.cpp:(.text._ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs10PoseArray_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE[_ZNK7tf2_ros15BufferInterface9transformIN13geometry_msgs10PoseArray_ISaIvEEEEERT_RKS6_S7_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEN3ros8DurationE]+0xb8): undefined reference to `void tf2::doTransform<geometry_msgs::PoseArray_<std::allocator<void> > >(geometry_msgs::PoseArray_<std::allocator<void> > const&, geometry_msgs::PoseArray_<std::allocator<void> >&, geometry_msgs::TransformStamped_<std::allocator<void> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [my_ws/something/testing/pcl_operations_test/CMakeFiles/tf_listener_test.dir/build.make:286: /home/my_pc/my_ws/devel/lib/testing/tf_listener_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:6789: my_ws/something/testing/pcl_operations_test/CMakeFiles/tf_listener_test.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
Invoking "make -j20 -l20" failed
Below is the code which I have edited:
class PoseDrawer
{
public:
PoseDrawer() :
tf2_(buffer_), target_frame_("world"),
tf2_filter_(point_sub_, buffer_, target_frame_, 10, 0)
{
point_sub_.subscribe(n_, "pose_output", 10);
tf2_filter_.registerCallback( boost::bind(&PoseDrawer::msgCallback, this, _1) );
}
void msgCallback(const geometry_msgs::PoseArrayConstPtr& point_ptr)
{
geometry_msgs::PoseArray array_out;
array_out.header.stamp = ros::Time::now();
array_out.header.frame_id = "world";
try
{
buffer_.transform(*point_ptr, array_out, target_frame_);
/*ROS_INFO("array of turtle 3 in frame of turtle 1 Position(x:%f y:%f z:%f)\n",
point_out.point.x,
point_out.point.y,
point_out.point.z);*/
}
catch (tf2::TransformException &ex)
{
ROS_WARN("Failure %s\n", ex.what()); //Print exception which was caught
}
}
};
Can you please help me using this datatype?
Is there any more error in your terminal? The errors you are getting are coming from the linker. I suspect you forgot to include
find_package( ... )
or something similar in yourCMakeLists.txt
file. Please share yourCMakeLists.txt
in the question above, and do not forget to format it properly while posting here.