Ask Your Question
0

lookupTransform is throwing error

asked 2018-04-05 02:02:17 -0600

Ravi Joshi gravatar image

I have a static transformation, which I am trying to fetch using lookupTransform. However, it is not working and throwing following error- "base" passed to lookupTransform argument target_frame does not exist.

Below is the code snippet-

tf2_ros::Buffer tfBuffer;
tf2_ros::TransformListener tfListener(tfBuffer);

try {
    // get the latest available transformation
    geometry_msgs::TransformStamped t = tfBuffer.lookupTransform("base", "kinect2_link", ros::Time(0));
}
catch (tf2::TransformException& ex) {
    ROS_ERROR_STREAM("Unable to fetch static transformation. " << ex.what());
}

I tried to debug the issue. The transformation is available in rostopic. Please see below

ravi@lab:~/ros_ws$ rostopic echo /tf_static
transforms:
  -
    header:
      seq: 0
      stamp:
        secs: 1522910703
        nsecs: 637645959
      frame_id: base
    child_frame_id: kinect2_link
    transform:
      translation:
        x: 0.824234432376
        y: 0.100365580648
        z: 0.140681429475
      rotation:
        x: -0.345864766717
        y: 0.656658630544
        z: -0.629654174274
        w: 0.229592305828

A similar question was asked here but unfortunately, it doesn't contain any answer.

My question is how to get the static transformations from tf using C++. I am using ROS Indigo on Ubuntu 14.04 LTS OS.

edit retag flag offensive close merge delete

Comments

Unless we've run into a regression or undiscovered bug, this might be just a matter of not waiting long enough for the buffer to actually contain those transforms. See #q287540 for a possible duplicate.

gvdhoorn gravatar imagegvdhoorn ( 2018-04-05 02:07:42 -0600 )edit

I need to check the reference, you provided. However I have a question regarding wait time for buffer. I am trying to access static transformation, which is never going to change. Is the wait concept applies to this scenario as well?

Ravi Joshi gravatar imageRavi Joshi ( 2018-04-05 02:19:53 -0600 )edit

I would have to verify that for static transforms. But in general instantiating a buffer and listener and then using them immediately is not going to work. The infrastructure needs some time to be able to gather all the information (essentially: receive TF msgs and process it).

gvdhoorn gravatar imagegvdhoorn ( 2018-04-05 03:56:55 -0600 )edit

Yes even static transform information must be propagated after the listener is created. It needs time to set up the communication channels and for the messages to be sent from all the sources.

tfoote gravatar imagetfoote ( 2018-04-05 05:13:36 -0600 )edit

@tfoote: I see. I am going to initialize the buffer with a wait time. But how do we decide this wait time? Too much wait is useless and too less doesn't work !

Ravi Joshi gravatar imageRavi Joshi ( 2018-04-05 07:09:15 -0600 )edit
1

tf2_ros::Buffer has a method canTransform(..) that you can use to see whether the necessary information is present in the local buffer.

gvdhoorn gravatar imagegvdhoorn ( 2018-04-05 07:34:33 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-04-05 15:14:36 -0600

tfoote gravatar image

Overall you need to wait for the transforms to become available. All calls should use a mechanism to check if the transform is available and have a retry or wait policy.

There's a tutorial here: http://wiki.ros.org/tf2/Tutorials/tf2...

In general one may fail, but a later piece of data might be usable later once the transform data becomes available.

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

1 follower

Stats

Asked: 2018-04-05 02:02:17 -0600

Seen: 458 times

Last updated: Apr 05 '18