Buffer error in ROS melodic
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.
Could you display the original error without changing to
tfBuffer
?If I use:
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&’
As described above, I got an error and 2 notes.