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

Buffer error in ROS melodic

asked 2021-11-11 06:09:27 -0600

Eman.m gravatar image

Hi

This code fragment is perfectly working in ROS kinetic:

 tf::TransformListener tf_(ros::Duration(10));
  costmap_2d::Costmap2DROS willow_garage_costmap("willowgarage_costmap", tf_);

However, in ROS melodic, it gives error, I searched for it and tried to solve it by changing to:

 tf2_ros::Buffer tfBuffer;
  costmap_2d::Costmap2DROS willow_garage_costmap("willowgarage_costmap", tfBuffer);

But, this gives error:

Do not call canTransform or lookupTransform with a timeout unless you are using another thread for populating data. Without a dedicated thread it will always timeout. If you have a seperate thread servicing tf messages, call setUsingDedicatedThread(true) on your Buffer instance.

I think it is an issue with Buffer constructor, but I don't know how to fix it?

Help highly appreciated.

edit retag flag offensive close merge delete

Comments

Could you display the original error without changing to tfBuffer?

osilva gravatar image osilva  ( 2021-11-11 06:33:52 -0600 )edit

If I use:

tf::TransformListener tf_(ros::Duration(10));
  costmap_2d::Costmap2DROS willow_garage_costmap("willowgarage_costmap", tf_);

I got:

1-

error: no matching function for call to ‘costmap_2d::Costmap2DROS::Costmap2DROS(const char [21], tf::TransformListener&)’ costmap_2d::Costmap2DROS willow_garage_costmap("willowgarage_costmap", tf_);

2-

note: candidate: costmap_2d::Costmap2DROS::Costmap2DROS(const string&, tf2_ros::Buffer&) Costmap2DROS(const std::string &name, tf2_ros::Buffer& tf);

3-

note: no known conversion for argument 2 from ‘tf::TransformListener’ to ‘tf2_ros::Buffer&’

Eman.m gravatar image Eman.m  ( 2021-11-11 07:20:30 -0600 )edit

As described above, I got an error and 2 notes.

Eman.m gravatar image Eman.m  ( 2021-11-11 07:35:47 -0600 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2021-11-14 23:16:14 -0600

Eman.m gravatar image

In ROS melodic, this fix the problem:

  tf2_ros::Buffer tfBuffer(ros::Duration(10));
  tf2_ros::TransformListener tfListener(tfBuffer);
  costmap_2d::Costmap2DROS willow_garage_costmap("willowgarage_costmap", tfBuffer);
edit flag offensive delete link more
0

answered 2021-11-11 07:53:49 -0600

osilva gravatar image

updated 2021-11-11 09:06:00 -0600

thank you @Eman.m. To fix the original issue, this is caused by the costmap_2d package being converted to use tf2 instead of tf. Difference between Kinetic and Melodic.

There is a repo that you need to build this package from source that will fix this: https://github.com/ros-planning/navig...

Also you can consider using the wrapper: http://docs.ros.org/en/melodic/api/co...

There is more information on this prior answer: https://answers.ros.org/question/2875...

edit flag offensive delete link more

Comments

Many thanks osilva. I already installed the navigation for melodic by:

sudo apt-get install ros-melodic-navigation

Which I think includes costmap_2d.

Excuse me, could you give me an example on how to use the wrapper?

Thank you

Eman.m gravatar image Eman.m  ( 2021-11-11 08:12:59 -0600 )edit

Please take a look at this repo to see how it's implemented: https://github.com/noeperez/indires_n...

There is also a paper, but it's in Spanish.

osilva gravatar image osilva  ( 2021-11-11 08:55:26 -0600 )edit

@osilva: +100 for helping people, but we try to discourage link-only answers here on ROS Answers.

Pointing to a repository is not stand-alone enough.

Similar to Stack Overflow, try to make your answer stand-alone, by including the relevant parts of whatever external resource you are pointing to. That way, even if those external resources are changed or go away, your answer keeps its value.

gvdhoorn gravatar image gvdhoorn  ( 2021-11-11 08:59:23 -0600 )edit

Also if you do a quick search in GitHub for Costmap2DROS::Costmap2DROSyou can see other implementations: https://github.com/search?q=Costmap2D...

osilva gravatar image osilva  ( 2021-11-11 09:02:21 -0600 )edit

what about these two lines:

tf2_ros::Buffer tfBuffer;
costmap_2d::Costmap2DROS willow_garage_costmap("willowgarage_costmap", tfBuffer);

Is creating tfBuffer this way correct?

Eman.m gravatar image Eman.m  ( 2021-11-11 09:05:09 -0600 )edit

I modified the code to:

  // the follwoing three lines are used with ROS melodic
  tf2_ros::Buffer tfBuffer(ros::Duration(10));
  tf2_ros::TransformListener tfListener(tfBuffer);
  costmap_2d::Costmap2DROS willow_garage_costmap("willowgarage_costmap", tfBuffer);

but, now different error:

Warning: Invalid argument "/map" passed to canTransform argument target_frame in tf2 frame_ids cannot start with a '/' like: at line 134 in /tmp/binarydeb/ros-melodic-tf2-0.6.5/src/buffer_core.cpp

Any idea?

Eman.m gravatar image Eman.m  ( 2021-11-11 10:12:54 -0600 )edit

it should be map vs /mapnew tf2 convention as per https://github.com/ros-planning/navig...

osilva gravatar image osilva  ( 2021-11-11 10:36:45 -0600 )edit

And pls don't forget to accept the answer if it fixed the original problem :) Hopefully you will be up and running soon.

osilva gravatar image osilva  ( 2021-11-11 10:44:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2021-11-11 06:09:27 -0600

Seen: 385 times

Last updated: Nov 14 '21