Ask Your Question
1

retrieve tf transform

asked 2014-04-01 00:07:32 -0500

Maya gravatar image

updated 2016-10-24 09:03:35 -0500

ngrennan gravatar image

Hellow,

I'm trying to obtain information from the a tf transform. I've loaded my URDF file in the parameter server and run robot and joint state publish. Here is a picture of some links :

Frames

So I can see that the transform between /base_link and /camera is publish.

Now here is my code which is very simple as it is a test :

#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::Duration(10));



tf::StampedTransform transform;
try{
    geometry_msgs::PointStamped base_point;

    listener.lookupTransform("/camera", "/base_link", ros::Time(0), transform);
}
catch(tf::TransformException& ex){
    ROS_ERROR("Received an exception trying to transform a point from \"camera\" to \"base_link\": %s", ex.what());
}

};

I'm just trying to have the transformation between /camera and /base_link. But I run in that error :

 rosrun tobot_goal listen 
[ERROR] [1396346328.110845542]: Received an exception trying to transform a point from "camera" to "base_link": Frame id /camera does not exist! Frames (1):

which would tend to mean that /camera is not publish. And if I try with any other frame I have, the result is the same...

Why can't I seem to not access those transformations ?

Thanks a lot !

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-04-01 00:15:26 -0500

demmeln gravatar image

I guess this is a timing issue, since you set up the tf listener and the immediately look up the transform, no tf data will have been received yet.

Try to use waitForTransform before the first lookup.

Also, you are not spinning, but IIRC the transform listener has its own threaded message queue for the tf topic, so that should be ok in this case.

edit flag offensive delete link more

Comments

Thanks a lot ! Adding waitForTransform for the thing to do.

Maya gravatar imageMaya ( 2014-04-01 01:40:07 -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

1 follower

Stats

Asked: 2014-04-01 00:07:32 -0500

Seen: 552 times

Last updated: Apr 01 '14