Ask Your Question
0

incorrect tf results

asked 2012-08-22 04:59:58 -0500

Astronaut gravatar image

updated 2012-08-23 01:30:45 -0500

Hello

I tried to make a node that gives me the distance between the fixed point and the baselink over the time. But I get wrong distances. hould 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

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

Yes Sure

The output of

rosrun tf tf_echo /base_link /door1 is

At time 1301628270.947
- Translation: [4.651, 10.067, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.532, 0.847]
            in RPY [0.000, 0.000, -1.122]
At time 1301628270.947
- Translation: [4.651, 10.067, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.532, 0.847]
            in RPY [0.000, 0.000, -1.122]
At time 1301628270.947
- Translation: [4.651, 10.067, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.532, 0.847]
            in RPY [0.000, 0.000, -1.122]
^CAt time 1301628270.947
- Translation: [4.651, 10.067, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.532, 0.847]
            in RPY [0.000, 0.000, -1.122]

and the distance is 

[ INFO] [1345720655.721469719, 1301628270.653578061]:  Dist to Door1 =11.086891
[ INFO] [1345720655.868379126, 1301628270.793675137]:  Dist to Door1 =11.087869
[ INFO] [1345720656.020382546, 1301628270.803828608]:  Dist to Door1 =11.090092
[ INFO] [1345720656.039301088, 1301628270.950554490]:  Dist to Door1 =11.090092

And the output of rosrun tf tf_echo /world /door1

At time 1301628270.978
- Translation: [4.500, 4.500, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
            in RPY [0.000, -0.000, 0.000]
At time 1301628270.978
- Translation: [4.500, 4.500, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
            in RPY [0.000, -0.000, 0.000]
At time 1301628270.978
- Translation: [4.500, 4.500, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
            in RPY [0.000, -0.000, 0.000]
^CAt time 1301628270.978
- Translation: [4.500, 4.500, 0.000]
- Rotation: in Quaternion [0.000, 0.000, 0.000, 1.000]
            in RPY [0.000, -0.000, 0.000]

[ INFO] [1345721049.231849091, 1301628270.478065900]:  Dist to Door1 =6.513392
[ INFO] [1345721049.371391812, 1301628270.634387495]:  Dist to Door1 =6.513717
[ INFO] [1345721049.535096985, 1301628270 ...
(more)
edit retag flag offensive close merge delete

Comments

What is the comment or answer of the question? I can not see it

Astronaut gravatar image Astronaut  ( 2012-08-22 14:20:01 -0500 )edit

Can you post the output of these commands?

rosrun tf tf_echo /base_link /door1
rosrun tf tf_echo /world /door1
rosrun tf tf_echo /world /base_link

... along with the distances you get (i.e., the output of your program)?

Martin Günther gravatar image Martin Günther  ( 2012-08-22 22:36:25 -0500 )edit

i just post it

Astronaut gravatar image Astronaut  ( 2012-08-23 01:23:25 -0500 )edit

Please always set the tags correctly to maximize the chance that the right people who can answer your question get notified.

Lorenz gravatar image Lorenz  ( 2012-08-23 02:41:18 -0500 )edit

Ok, How to set this tag???

Astronaut gravatar image Astronaut  ( 2012-08-23 02:43:06 -0500 )edit

You can retag your question by clicking the "retag" button.

Martin Günther gravatar image Martin Günther  ( 2012-08-23 05:49:31 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2012-08-23 06:03:06 -0500

I tried to make a node that gives me the distance between the fixed point and the baselink over the time. [...]

  listener.lookupTransform("/base_link", "/door1",  
                          ros::Time(0), transform);

What are you trying to do? Find the distance between /world and /base_link or between base_link and door1? Your explanation and your code don't match.

Also, I am a little confused what your "Dist to Door1" outputs mean. In the first two cases, it seems as if they give the distance between the frames you mention in the rosrun tf tf_echo output, but the third one seems to be wrong.

From the tf_echo outputs it seems that everything is correct: /door1 is about 6.5 meters away from /world, /base_link is about 5.5 meters away from /world, and because they are rotated by about 180° and /world is almost in the middle between the two frames, the total distance from /base_link to /door1 is about 11 m.

You have to look at the RPY angles (in radian). Simply put, the rotation is applied before the translation.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-22 04:59:58 -0500

Seen: 332 times

Last updated: Aug 23 '12