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

C++ Compiler uses the wrong Costmap2DROS version

asked 2018-09-14 11:50:27 -0500

SteBisi gravatar image

updated 2018-09-14 13:42:23 -0500

gvdhoorn gravatar image

Hello everyone, I'm trying to write some c++ code that uses the Costmap2DROS class, but I have this error at compile time:

error: no matching function for call to ‘costmap_2d::Costmap2DROS::Costmap2DROS(std::__cxx11::string&, tf2_ros::Buffer&)

/opt/ros/kinetic/include/costmap_2d/costmap_2d_ros.h:80:3: note: candidate: costmap_2d::Costmap2DROS::Costmap2DROS(std::__cxx11::string, tf::TransformListener&)
   Costmap2DROS(std::string name, tf::TransformListener& tf);

The line that gives the problem is this one:

costmap = new costmap_2d::Costmap2DROS("global_planner", tfl);

where tfl is a tf2::Buffer& object.

I have seen from these reference pages that depending on the ROS version you have different constructors for the class. The problem is that I am working on ROS Kinetic, that according to the ROS wiki, uses the melodic version, so why my compiler is using the jade one? How can I solve this?

Thank you in advance to anyone who can help

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-09-14 12:35:20 -0500

alsora gravatar image

updated 2018-09-14 12:36:58 -0500

According to the docs, in ROS kinetic the constructor for the Costmap is the following

Costmap2DROS (std::string name, tf::TransformListener &tf)

From your error message your ros distro is kinetic, not jade or melodic, so you should go with this one (which in this particular case it's equal to the jade one).

edit flag offensive delete link more


Thank you. My bad, I misread the references

SteBisi gravatar image SteBisi  ( 2018-09-15 08:46:25 -0500 )edit

Question Tools

1 follower


Asked: 2018-09-14 11:50:27 -0500

Seen: 942 times

Last updated: Sep 14 '18