ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to callback specific tf joint from openni_tracker

asked 2013-06-24 02:29:20 -0600

uwlau gravatar image

updated 2013-11-14 12:33:06 -0600

tfoote gravatar image

hey, I'm trying to write a callback for tf's from the openni_tracker node but i get errors at runtime. To "echo" the data, i launch the tracker with this parameters:

<node pkg="openni_tracker" type="openni_tracker" name="openni_tracker">
<param name="tf_prefix" value="tracker" />
 <param name="camera_frame_id" value="/camera_link" />

i'm using the following code (excerpt) to get the data:

ros::Subscriber openni_sub = n.subscribe("tf", 1000, openniCallback);
void openniCallback(const tf::tfMessage openni_sub) {

    tf::TransformListener listener;
    tf::StampedTransform tf_right_hand;

    ros::NodeHandle n;

    try {
                "/tracker/right_hand_1", ros::Time(0), tf_right_hand);
        x_right_hand = tf_right_hand.getOrigin().x();
                    //same with left_hand and head.

    catch (tf::TransformException ex) {
              ROS_ERROR("%s", ex.what());

My Problem is, that i get the data for right_hand, left_hand and head, but i also get a lot of errors like:

[ERROR] [1372076533.053340930]: Frame id /tracker/right_hand_1 does not exist! Frames (15): Frame /tracker/torso_1 exists with parent /camera_link.

My idea is, that i get a callback, but there is no data to lookup. so:

  1. how can i get a callback if there is new data for the right_hand, left_hand and head, not a callback for any tfMessage?
  2. is it possible not to use a transformListener.lookupTransform like "openni_sub.getOrigin().x()? - i did not get that one work, too...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-06-24 03:19:35 -0600

dornhege gravatar image

You are using tf wrong. It doesn't work like "normal" ROS topics, but does collect its data on its own. So usually you never subscribe to a tfMessage yourself, but just create the listener, which does all that for your, and then use waitForTransform to check when the transform is available.

Make sure that you create the listener somewhere static, so that it isn't deleted as it needs to fill its buffers.

The reason for this is that in many cases there will never be a tfMessage that contains your transform, but only a path through transforms from different messages that enables the tf listener to built up that transform.

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


Asked: 2013-06-24 02:29:20 -0600

Seen: 912 times

Last updated: Jun 24 '13