ROS ERROR:‘tf2_buffer_’ was not declared in this scope

asked 2020-08-21 02:17:06 -0500

Dullyter gravatar image

I copy the code of Autolabor2.5 in my workspace, and when I start to build, I get an error that says "error: ‘tf2_buffer_’ was not declared in this scope"

The error is in /home/hwh/catkin_ws/src/navigation/amcl/src/amcl_node.cpp, and here is the code where error happens

 // Use a child class to get access to tf2::Buffer class inside of tf_
struct TransformListenerWrapper : public tf::TransformListener
{
  inline tf2_ros::Buffer &getBuffer() {return tf2_buffer_;}
};

The whole code is too long, so I do not put the file for now.

edit retag flag offensive close merge delete

Comments

You tagged melodic and yet the code you show is from the branch kinetic (source), which ros distribution do you have ? Instead of getting the source code in your workspace why don't you get the package amcl with sudo apt install ros-DISTRO-amcl ?

Delb gravatar image Delb  ( 2020-08-21 03:21:00 -0500 )edit

My distribution is melodic, and I just copy the code from a robot official website. By the way, how do you find the distribution of the code?

Dullyter gravatar image Dullyter  ( 2020-08-21 03:31:17 -0500 )edit

Besides, I hope to study the code

Dullyter gravatar image Dullyter  ( 2020-08-21 03:36:02 -0500 )edit

On github for example, you can see at the top of the file the name of the current branch (you can also find it in the url) which generally contains the ros distribution.

I just copy the code from a robot official website.

Maybe the link can be helpful here. And anyway even if it's from an official source you can change the branch (thus the distribution) so if your link wasn't pointing to the default branch (for amcl it's melodic) you don't get the correct version.

Delb gravatar image Delb  ( 2020-08-21 03:38:16 -0500 )edit

thanks, I will give it a try

Dullyter gravatar image Dullyter  ( 2020-08-21 03:53:32 -0500 )edit