Ask Your Question
0

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

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

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
0

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

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

Comments

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: http://wiki.ros.org/tf2/Tutorials/Mig.... But tried to do it in ros2

vamsi gravatar image vamsi  ( 2021-05-28 01:51:57 -0600 )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 -0600 )edit
1

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 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

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

Seen: 236 times

Last updated: May 28