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

Tf has two or more unconnected trees. Error

asked 2012-08-21 20:58:05 -0600

Astronaut gravatar image

updated 2012-08-22 04:35:11 -0600

Hello

I create the node that gives me the distance between the center of my robot which is my base link and some fixed point in the map. It was running and getting the correct distance but after a while (after playing differnt bag files) i start getting strange disttances I got this error at the begiing of calculation

Could not find a connection between '/base_link' and '/door2' because they are not part of the same tree.Tf has two or more unconnected trees.

This is my node

    #include <ros/ros.h>
#include <tf/transform_listener.h>


int main(int argc, char** argv){
  ros::init(argc, argv, "my_tf_listener");

  ros::NodeHandle node;
  tf::TransformListener listener;

  ros::Rate rate(10.0);

  while (node.ok())

    {
    tf::StampedTransform transform;
    try{
      listener.lookupTransform("/base_link", "/door1",  
                               ros::Time(0), transform);
    }
    catch (tf::TransformException ex){
      ROS_ERROR("%s",ex.what());
    }


    double x = transform.getOrigin().x();
        double y = transform.getOrigin().y();
    double dist1 = sqrt(x*x + y*y);
    ROS_INFO("%f", dist1);

    rate.sleep();


  }
  return 0;
};

And this the label in the launch file

<node pkg="tf" type="static_transform_publisher" name="door1" args="-1.25 4.5 0 0 0 0 /world /door1 10"/>

Any help???

This my frames.pdfimage description

edit retag flag offensive close merge delete

Comments

I add the pdf. frame. Any help?

Astronaut gravatar image Astronaut  ( 2012-08-22 04:29:22 -0600 )edit

You are now having a different problem that has nothing to do with the original question. Please open a new question.

Lorenz gravatar image Lorenz  ( 2012-08-22 04:36:56 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-08-22 02:23:53 -0600

Aslund gravatar image

You can view the connection between the frames by executing "rosrun tf view_frames". It helps getting an overview of tf.

edit flag offensive delete link more

Comments

i have a strange pdf saying no tf data recieved, When should I execute the g "rosrun tf view_frames"??

Astronaut gravatar image Astronaut  ( 2012-08-22 02:38:35 -0600 )edit

You should run it while you program is running. It will read all frames in the system and generate a pdf showing the connection between the frames

Aslund gravatar image Aslund  ( 2012-08-22 03:13:39 -0600 )edit

Ok. Still no data recieved. Whats the problem?

Astronaut gravatar image Astronaut  ( 2012-08-22 03:24:54 -0600 )edit
1

Apparently your system is not publishing any tf. Seems very strange, I wonder if you are executing it properly. Have you just jumped into programming with ROS or have you spend time with reading the tutorials? Have you tried to execute your node after the static_transform_publisher?

Aslund gravatar image Aslund  ( 2012-08-22 04:01:16 -0600 )edit

I got it. I got the pdf now. Any help now?

Astronaut gravatar image Astronaut  ( 2012-08-22 04:24:18 -0600 )edit
1

Try changing your transform to: <node pkg="tf" type="static_transform_publisher" name="door2" args="1.25 -4.5 0 0 0 0 /door2 /world 10"/>

Aslund gravatar image Aslund  ( 2012-08-22 04:30:08 -0600 )edit

Sorry, Dont understand. What to change???

Astronaut gravatar image Astronaut  ( 2012-08-22 04:31:23 -0600 )edit
2

Your static_transform_publisher to the one I showed you. Instead of door2 having world as parent then will door2 be the parent. It avoid having two threes. Had a smilar problem and this fixed it. You can see it here: http://answers.ros.org/question/41000/problems-with-tf-using-the-navigation-stack/

Aslund gravatar image Aslund  ( 2012-08-22 04:33:47 -0600 )edit
2

answered 2012-08-21 23:43:05 -0600

Lorenz gravatar image

You need to use listener.waitForTransform before you call lookupTransform. Have a look at this tutorial.

It takes a while until the listener object received the complete tree. Until then you might have disconnected trees.

edit flag offensive delete link more

Comments

Yes , but even after that is gives me not the correct distance. The distances just increased all the time. And before that was given the correct one

Astronaut gravatar image Astronaut  ( 2012-08-22 01:48:51 -0600 )edit

Please fix the code above. Seems like there went something wrong with copy-pasting it. Also, get rid of the includes of btQuaternion.h, btScalar.h. You should never use hard-coded include paths and you should not include anything from bullet when using tf anymore.

Lorenz gravatar image Lorenz  ( 2012-08-22 02:43:35 -0600 )edit

Sorry dont understand what you mean not include anything from bullet when using tf anymore. My problem is that once tf is running ok but next time with the same or other bag file ist totaly noncence. I dont get that

Astronaut gravatar image Astronaut  ( 2012-08-22 02:55:13 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-08-21 20:58:05 -0600

Seen: 12,691 times

Last updated: Aug 22 '12