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