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

‘buffer’ is not a type tf2_ros::TransformListener tfl_(buffer);

asked 2021-05-28 00:16:03 -0500

vamsi gravatar image

I am trying to convert tf transform listener in ros1 to tf2 transform listener in ros2. I declared "tf2_ros::Buffer buffer; and tf2_ros::TransformListener tfl_(buffer);" in the public as per the migration guide from tf to tf2. However, I am getting the following error while building.

error: ‘buffer’ is not a type tf2_ros::TransformListener tfl_(buffer);

Thank You!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-05-28 01:09:57 -0500

Given that you are following this. Make sure you have the correct headers and in the CMakeLists.txt you have included tf2_ros and tf2.

This example is for transform conversions but uses the same listener concept.

edit flag offensive delete link more


Yes, I have added tf2_ros and tf2 both in the CMakeLists.txt and package.xml but it still doesn't work. Further, I was following this: But tried to do it in ros2

vamsi gravatar image vamsi  ( 2021-05-28 01:51:57 -0500 )edit

Can you confirm that this node runs in your system. Also can you provide your code?

At best you you also try the structure in the above mentioned link?

Some further information about your System (Linux/Windows, ROS2 Version) would also be good to know.

turtleMaster20 gravatar image turtleMaster20  ( 2021-05-31 03:47:38 -0500 )edit

I managed to get my code running using the following changes:

1) adding in public, std::shared_ptr<tf2_ros::buffer> tf_; std::shared_ptr<tf2_ros::transformlistener> tfl_; 2) In the constructor, rclcpp::Clock::SharedPtr clock; clock=std::make_shared< rclcpp::Clock >(RCL_SYSTEM_TIME); tf_.reset(new tf2_ros::Buffer(clock)); tfl_.reset(new tf2_ros::TransformListener(*tf_)); 3) And followed the syntax from the migration guide to use tf_->lookupTransform()

I am using ubuntu 20.04 Thank You

vamsi gravatar image vamsi  ( 2021-05-31 04:59:52 -0500 )edit

Question Tools



Asked: 2021-05-28 00:16:03 -0500

Seen: 1,453 times

Last updated: May 28 '21