Ask Your Question
0

How to callback specific tf joint from openni_tracker

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

uwlau gravatar image

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

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" />
</node>

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 {
        listener.lookupTransform("/camera_link",
                "/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
2

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

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

Stats

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

Seen: 806 times

Last updated: Jun 24 '13