0
$\begingroup$

Rosanswers logo

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


Originally posted by MartinW on ROS Answers with karma: 464 on 2013-03-06

Post score: 1


Original comments

Comment by dornhege on 2013-03-07:
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.

Comment by MartinW on 2013-03-07:
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

Comment by Boris on 2013-03-07:
@MartinW, apart from compilation problem, what do you mean by saying "this method is too slow"?

Comment by MartinW on 2013-03-08:
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!

Comment by dornhege on 2013-03-08:
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).

Comment by Pino on 2013-07-25:
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

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Boris with karma: 3060 on 2013-03-06

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by MartinW on 2013-03-07:
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

Comment by Boris on 2013-03-07:
If you are using robot_state_publisher, then it will publish tf tree from URDF. So no need for additional transform publisher.

Comment by MartinW on 2013-03-08:
I am using robot_state_publisher, so is there a way to obtain transforms from this? Or is the method above doing this implicitly?

Comment by dornhege on 2013-03-08:
Yes, that is it.

$\endgroup$

Your Answer

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