Ask Your Question
1

How do I setup a static tf?

asked 2013-03-06 15:47:21 -0500

MartinW gravatar image

Hello all,

I want to set up a static transform from my kinect frame to my robot frame and I am finding that this method is too slow:

tf::TransformListener listener;
    tf::StampedTransform transform;
    try{
listener.waitForTransform("/base_link","/camera_depth_optical_frame",ros::Time::now(),ros::Duration(3));
        listener.lookupTransform("/base_link", "/camera_depth_optical_frame",ros::Time::now(), transform);
        }
    catch (tf::TransformException ex){
        ROS_WARN("Base to camera transform unavailable %s", ex.what());
        }

Since the transformation is static I tried to make transform a global variable in my program and use it in different places but I get a compiling error from this saying something along the lines of:

error: reference to ‘transform’ is ambiguous

How do I set up a static transform during an initialization part of a program so that I don't keep processing the same transformation over and over?

Kind Regards, Martin

edit retag flag offensive close merge delete

Comments

You're doing the right thing (if the above code is run once). The error you are getting seems related to your code. Either you have another transform defined somewhere else or you are using the same code multiple times (by copying or implicitly). How to do it correctly depends on your software.

dornhege gravatar imagedornhege ( 2013-03-06 23:49:31 -0500 )edit

Hey dornhege, I don't think I've defined it multiple times but I defined listener and transform as global variables and run an initialization and then just call the transform in my callback. I will try to figure this out and get back to you! thank you for the reply

MartinW gravatar imageMartinW ( 2013-03-07 06:28:01 -0500 )edit
1

@MartinW, apart from compilation problem, what do you mean by saying "this method is too slow"?

Boris gravatar imageBoris ( 2013-03-07 11:24:10 -0500 )edit

I am trying to run a real-time system that uses the kinect, does some processing on the point cloud and then feeds this information to a robot running at 10Hz. But adding this transformation really slows it down for some reason, if I comment it out I run at approximately the speed I want though!

MartinW gravatar imageMartinW ( 2013-03-08 06:55:57 -0500 )edit
2

If you don't want to cache the transform, one thing might be to use ros::Time(0) instead of ros::Time::now(). Whatever now is, the listener will always have to wait until the message from time=now arrives. With Time(0) it will just take the last one (which I guess is what you want).

dornhege gravatar imagedornhege ( 2013-03-08 07:26:58 -0500 )edit

Are you trying to publish the base_link->camera tf in the fovis package using the kinect? have you been able to do it? I'm still trying to implement this tf

Pino gravatar imagePino ( 2013-07-25 08:56:05 -0500 )edit

1 Answer

Sort by » oldest newest most voted
4

answered 2013-03-06 17:47:46 -0500

updated 2013-03-06 18:07:12 -0500

To setup transform between frames you have to broadcast (publish) transform instead of listening to it.

There are two ways to do that:

  1. Use static_transform_publisher -- this one is a ready to use node, that you can run from command line.
  2. Use tf::TransformBroadcaster -- to create transforms in a code.

EDIT: If the transform is already exist you can simply listen to it once outside of publishing cycle.

edit flag offensive delete link more

Comments

Hey Boris, In my urdf I have defined the joint and link connections (and thereby the transform), so do I still need to use a static transform publisher? It just seems like more work/system resources to add this, I just want my program to find this transform once, and reuse it to keepup program speed

MartinW gravatar imageMartinW ( 2013-03-07 06:30:53 -0500 )edit

If you are using robot_state_publisher, then it will publish tf tree from URDF. So no need for additional transform publisher.

Boris gravatar imageBoris ( 2013-03-07 11:08:56 -0500 )edit

I am using robot_state_publisher, so is there a way to obtain transforms from this? Or is the method above doing this implicitly?

MartinW gravatar imageMartinW ( 2013-03-08 06:52:58 -0500 )edit

Yes, that is it.

dornhege gravatar imagedornhege ( 2013-03-08 07:25:29 -0500 )edit

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: 2013-03-06 15:47:21 -0500

Seen: 13,265 times

Last updated: Mar 06 '13