0
$\begingroup$

Rosanswers logo

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

Any help???

This my frames.pdfimage description


Originally posted by Astronaut on ROS Answers with karma: 330 on 2012-08-21

Post score: 1


Original comments

Comment by Astronaut on 2012-08-22:
I add the pdf. frame. Any help?

Comment by Lorenz on 2012-08-22:
You are now having a different problem that has nothing to do with the original question. Please open a new question.

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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


Originally posted by Aslund with karma: 289 on 2012-08-22

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Astronaut on 2012-08-22:
i have a strange pdf saying no tf data recieved, When should I execute the g "rosrun tf view_frames"??

Comment by Aslund on 2012-08-22:
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

Comment by Astronaut on 2012-08-22:
Ok. Still no data recieved. Whats the problem?

Comment by Aslund on 2012-08-22:
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?

Comment by Astronaut on 2012-08-22:
I got it. I got the pdf now. Any help now?

Comment by Aslund on 2012-08-22:
Try changing your transform to:

Comment by Astronaut on 2012-08-22:
Sorry, Dont understand. What to change???

Comment by Aslund on 2012-08-22:
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/

Comment by Astronaut on 2012-08-22:
ok. Will try. thanks

Comment by Astronaut on 2012-08-22:
I changed and is not ok. It gives me the wrong distance

Comment by Aslund on 2012-08-22:
What is the distance and what should it be? Just telling it is wrong is neither helpful for me or you. I noticed I accidently wrote door2 in my code instead of door1, did you fix that mistake?

Comment by Astronaut on 2012-08-22:
Well the distance is changing during the time. should be in the range of 0 to some like 10 meters. But I got totaly uncenece datas.. like start from 5 and than go till 15 . So no cence results

Comment by Aslund on 2012-08-22:
Atleast your problems with the tf tree is solved. I am a bit unsure whether the values are correct from static_transform_publisher, but if the position of the door is wrong according to the world frame (you can use RViz) you must change them accordingly

Comment by Astronaut on 2012-08-22:
How do I know if my position of the door is wrong? Why that changes? The door is fixed in the map frame. I do not understand that

Comment by Aslund on 2012-08-22:
As I wrote, use RViz: http://www.ros.org/wiki/rviz/UserGuide. You can see how the frames moves over time. You claim your results are uncertain but to me it just looks like you are dealing with an offset. Either wrong position of the door or something else

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Lorenz with karma: 22731 on 2012-08-21

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by Astronaut on 2012-08-22:
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

Comment by Lorenz on 2012-08-22:
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.

Comment by Astronaut on 2012-08-22:
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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.