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

ros melodic tf to tf2 migration

asked 2019-11-11 07:24:26 -0500

marcs gravatar image

updated 2019-11-11 10:57:29 -0500

gvdhoorn gravatar image

Currently running ros melodic/ubuntu 18.0 and compiling this global planner code (which was written for ros indigo) gives the error message:

error: no matching function for call to ‘costmap_2d::Costmap2DROS::getRobotPose(tf::Stamped<tf::Transform>&)’
       if(dynamic_costmap_->getStaticROSCostmap()->getRobotPose(robot_pose))

Snippet of code as follows:

 try
  {
    geometry_msgs::Twist prev_vel = current_plan_.velocities.at(i - 2);
    if(prev_vel.linear.x == 0 && replanning_start_vel.linear.x == 0)
    {
      ROS_DEBUG("turn in place. update pose with amcl");
      tf::Stamped<tf::Transform> robot_pose;
      if(dynamic_costmap_->getStaticROSCostmap()->getRobotPose(robot_pose))
      {
        conti_pose.pose.position.x = robot_pose.getOrigin().getX();
        conti_pose.pose.position.y = robot_pose.getOrigin().getY();
      }
   }
  }

i'm suspecting this is because of the migration from tf to tf2. However i am really new to ROS and coding in general. I have tried reading the tf ros wiki, but it's really complicated and seems like i have to get a full understanding behind the workings of tf.

So i was wondering if there is any quick fix or how can i rewrite this particular part of the code?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2019-11-12 07:26:36 -0500

marcs gravatar image

updated 2019-11-12 07:31:14 -0500

@gvdhoorn: ah yes this seemed to do the trick, along with the tweaking of other lines in the code Found out a method which was to compare 2 same codes from diff versions side by side (i compared goal_functions.cpp from Indigo and Melodic era) and simply played spot the difference

this is the edited code which compiled:

 geometry_msgs::PoseStamped robot_pose;
      if(dynamic_costmap_->getStaticROSCostmap()->getRobotPose(robot_pose))
      {
        conti_pose.pose.position.x = robot_pose.pose.position.x;
        conti_pose.pose.position.y = robot_pose.pose.position.y;

also i added a few header files

#include <tf2/LinearMath/Matrix3x3.h>
#include <tf2/utils.h>
#include <tf2_geometry_msgs/tf2_geometry_msgs.h>

thanks for your help, it was greatly appreciated :)

edit flag offensive delete link more

Comments

So i was wondering if there is any quick fix or how can i rewrite this particular part of the code?

So in the end I would say: no, there is no "quick fix".

If trying to get code from 5 years ago to compile against current versions of ROS packages, there is a very good chance you'll have to port the code and accommodate for chances that the new version(s) of your dependencies have gone through.

This is not unique to ROS packages of course but something that applies to all software.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-12 07:43:29 -0500 )edit
0

answered 2019-11-11 11:03:46 -0500

If you're using ROS Melodic, use the ROS Melodic branch of the codebase. We don't support mix and matching.

edit flag offensive delete link more

Comments

Unfortunately i took this code from a research paper published 5 years ago, which was running on ros indigo and has no support for further versions, so i was hoping to integrate it into a current project which already has components running on ros melodic. So could you offer me some sort of solution about it, or possibly reference me to a suitable link (aside from the generic tf wiki page)? Thanks!

marcs gravatar image marcs  ( 2019-11-11 11:09:53 -0500 )edit

If you could link us to the code or the paper, we may be able to see whether there are any forks that have already done the work (for you).

gvdhoorn gravatar image gvdhoorn  ( 2019-11-11 11:10:42 -0500 )edit
1

For this particular error: looks like the argument was changed from tf::Stamped<tf::Transform>& to geometry_msgs::PoseStamped& (here).

See paulbovbel/frontier_exploration#38 for a similar error in a similar package.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-11 11:14:57 -0500 )edit

@marcs the answer would be to clone and build the ROS Navigation Indigo branch so that everything's written in Indigo.

stevemacenski gravatar image stevemacenski  ( 2019-11-11 12:08:22 -0500 )edit

@stevemacenski: the question is clearly about porting a global planner from whatever the state was at the time Indigo was still supported to Melodic. Checking out navigation from the Indigo-era is not something that helps with porting.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-11 12:46:37 -0500 )edit

I don't see any reference to porting. It's just asking how to build, I imagine the user just cloned navigation and since the default branch is melodic, that's what they're using.

If they're wanting to port, they should port their old code, not backport Navigation.

stevemacenski gravatar image stevemacenski  ( 2019-11-11 13:26:29 -0500 )edit

compiling this global planner code (which was written for ros indigo)

and

Unfortunately i took this code from a research paper published 5 years ago, which was running on ros indigo and has no support for further versions, so i was hoping to integrate it into a current project which already has components running on ros melodic.

look like porting to me.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-11 14:24:46 -0500 )edit

@stevemacenski: sorry if i didn't make things clear enough, i do believe it's an issue of porting.

My current project deals with an autonomous wheelchair which already uses the ROS Melodic navigation stack, and there are other people working on and writing code for different aspects of this project as well so I am unable to revert the entire code back to ROS Indigo.

I am trying to replace the current global planner with a new global planner package (Timed Based Lattice Planner, link: https://github.com/marinaKollmitz/lat...) and thus face issues building the package due to this compatibility(?) issue

marcs gravatar image marcs  ( 2019-11-11 22:09:59 -0500 )edit

Question Tools

Stats

Asked: 2019-11-11 07:22:26 -0500

Seen: 781 times

Last updated: Nov 11 '19