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

How to use tf2_ros::MessageFilter with geometry_msgs::PoseArray ?

asked 2022-09-09 09:59:50 -0500

Anubhav@d gravatar image

updated 2022-09-09 22:39:08 -0500

ravijoshi gravatar image

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?

edit retag flag offensive close merge delete

Comments

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 your CMakeLists.txt file. Please share your CMakeLists.txt in the question above, and do not forget to format it properly while posting here.

ravijoshi gravatar image ravijoshi  ( 2022-09-09 22:43:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-10 10:07:18 -0500

Mike Scheutzow gravatar image

https://docs.ros.org/en/noetic/api/tf...

From the linked page, it doesn't look to me like you can pass a geometry_msgs::PoseArray to buffer_.transform()

I would try walking the poses[] array to convert each Pose one at a time.

edit flag offensive delete link more

Comments

Thankyou, your suggestion worked.

Can you suggest any other method for the transformation of large number of poses in an array, without walking the poses[] one at a time?

Anubhav@d gravatar image Anubhav@d  ( 2022-09-12 09:17:44 -0500 )edit

I'm not aware of any other way to handle an array of poses.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-09-12 10:21:33 -0500 )edit

If you'd like to do that you can create a custom transformer implementation for yourself and or contributed it back to the core library for the newer implementation in ROS 2. We generally don't want to do major feature changes in already released distros such as Noetic. You will need to implement a doTransform method like here: https://github.com/ros2/geometry2/blo...

tfoote gravatar image tfoote  ( 2022-09-12 13:26:35 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-09-09 09:59:50 -0500

Seen: 198 times

Last updated: Sep 10 '22