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

Could not find a connection between '/map' and '/base_link'

asked 2014-05-02 01:09:03 -0500

RB gravatar image

updated 2014-05-03 05:39:43 -0500

Hi,

I want to calculate robot's current position with respect to the map. Autonomous navigation of ROS works fine.

Following is my "rosrun tf view_frames"

tf tree

I have tried following two commands which gives robot position?? And it works correctly

rosrun tf tf_echo /map /base_link

rosrun tf tf_echo /odom /base_footprint

Code snippet used the listen the transform is given below::::::I have used this code inside a nodelet's init() method..Code compiled successfully. transform and listener are made public class members.

 while (nh.ok())
  {
    //tf::StampedTransform transform;
    try
    {
        //ROS_INFO("Attempting to read pose...");
        listener.lookupTransform("/map","/base_link",ros::Time(0), transform);
        //listener.lookupTransform("/odom","/base_footprint",ros::Time(0), transform); //SECOND STATEMENT//

        ROS_INFO("Got a transform! x = %f, y = %f",transform.getOrigin().x(),transform.getOrigin().y());
    }
    catch (tf::TransformException ex)
    {
        ROS_ERROR("Nope! %s", ex.what());
    } 


    //rate.sleep();

  }

ERROR lookupTransform.jpg

Even if I try "SECOND STATEMENT"(see code snippet), we get following error.

[ERROR] [1399027108.366171508]: Nope! Could not find a connection between '/odom' and '/base_footprint' because they are not part of the same tree.Tf has two or more unconnected trees.
[ERROR] [1399027108.366232448]: Nope! Could not find a connection between '/odom' and '/base_footprint' because they are not part of the same tree.Tf has two or more unconnected trees.

Thank you for any kind of help...................

rxconsole OUTPUT transform.jpg and "rosrun tf tf_echo /map /base_link" output map to base_link.jpg

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-05-02 01:37:09 -0500

dornhege gravatar image

If this is happening during an init method the reason for the error is likely that the transform data just has not arrived at the tf listener, yet. You need to wait for the buffers to fill, before the queries will be successful. The /map -> /odom transform is probably missing, which may take some time as SLAM/localization will need to be running and producing data first.

edit flag offensive delete link more

Comments

ok ... I should remove the code from init() or move around the environment to get the buffer full...

RB gravatar image RB  ( 2014-05-02 06:57:28 -0500 )edit

Depending on the algorithms you should not have to move. If everything is streaming constantly, it just takes a short time to setup connections and receive some data. A simple waitForTransform might be sufficient. Or get the transform when you need it in the code later.

dornhege gravatar image dornhege  ( 2014-05-02 09:51:28 -0500 )edit

I want to know whether above code represents the difference in pose between /map and /base_link. Since after using, waitForTransform(with ros::Duration(1.0)), I am getting "Got a transform! x = 0.000000, y =0.000000", even after 1min. But "rosrun tf tf_echo /map /base_link", gives actual robot position with respect to the map.

RB gravatar image RB  ( 2014-05-03 05:16:03 -0500 )edit

The duration would wait 1 second, not 1 minute. If you actually get to the printout in that code, that should be a real tf transform as the exception did not trigger.

dornhege gravatar image dornhege  ( 2014-05-03 07:24:17 -0500 )edit

Ok thanks for the comment..I am just wondering why the results of the code and that of "rosrun tf tf_echo /map /base_link" is not matching?...Is there any other way to get exact position or mimic the command 'rosrun tf tf_echo /map /base_link' in the code?? I have added two new screenshots in question....

RB gravatar image RB  ( 2014-05-03 07:58:47 -0500 )edit

Got the answer, thanks once again...@dornhege

RB gravatar image RB  ( 2014-05-05 05:29:30 -0500 )edit

If you can say what the actual problem/solution was, that might be helpful for other people.

dornhege gravatar image dornhege  ( 2014-05-05 05:33:53 -0500 )edit

I forgot to add the following line after waitForTransform()................................... listener.lookupTransform("/map","/base_link",ros::Time(0), transform);

RB gravatar image RB  ( 2014-05-05 19:07:19 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-05-02 01:09:03 -0500

Seen: 6,423 times

Last updated: May 03 '14