Ask Your Question
0

broadcast single tf message

asked 2015-05-29 05:00:52 -0600

updated 2015-06-01 03:15:58 -0600

Hello! I am working on an extrenal camera tracking a robot.

To initialize the tf between the robot and a marker. I put the robot in a known place and with the position of where the mark is detected, I deduce the relation between the mark and the robot.

Fisrt,I create the frame of where I put my robot_foot in my map:

       self.broadcaster.sendTransform(
            (req.x, req.y, 0), quaternion, rospy.Time.now(),
            "/mon_tf/" + ROBOT_FOOT, MAP)

Then I create the frame of where the head should be in my map :

 self.broadcaster.sendTransform(
            trans_foot_to_body, rot_foot_to_body, rospy.Time.now(),
            "/my_tf/" + req.robotpart,
            "/my_tf/" + ROBOT_FOOT)

Now that the supposed position of the head is known, and in the same branch of our detected marker, we can deduce the relation between the head and the mark :

        (trans_marker_to_body,
            rot_marker_to_body) = self.listener.lookupTransform(
            marker, "/my_tf/" + req.robotpart,
            rospy.Time(0))

I got the error:

Lookup would require extrapolation at time 1432892532.412094116, but only time 1432892532.912867069 is in the buffer, when looking up transform from frame [mon_tf/HeadTouchFront_frame] to frame [ar_marker_2]

I have found some similar questions on ros.answers, so I tried to switch rospy.Time.now() by rospy.Time(0) or to use waitForTransform rather than lookupTransform, and also to put some time.sleep(0.5) because it seems to solve the problem in another similar part of my code...

I would like to know if I am using the wrong tool for what I want to do ( because I am just broadcasting a single message) , or how to solve this tf buffer problem? What about tf2?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-01 03:47:11 -0600

tfoote gravatar image

To know what your problem is I'd need to see more of your system running. Overall it looks like you're on the right track, however your code is not robust to latencies in the system, with data and coordinate frames arriving in different orders than you are expecting.

I suggest you walk through the tf tutorials: http://wiki.ros.org/tf/Tutorials

Also make sure that you're repeatedly publishing the positions of the frames so that tf can correctly interpolate. If you only publish single datapoints for each frame_id at different times a lookup will never succeed.

edit flag offensive delete link more

Comments

OK so the problem must be because my function is called by a service so the broadcaster.sendTransform are not in a loop but called a single time.., I will try to improve that !

scarlett gravatar imagescarlett ( 2015-06-02 02:52:13 -0600 )edit

I made those publish and listener tf in a function which is called in a while loop aaand it works ! Thanks, I missed the importance of the "repeatedly" part while doing the tutorials !

scarlett gravatar imagescarlett ( 2015-06-02 03:20:25 -0600 )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: 2015-05-29 05:00:52 -0600

Seen: 272 times

Last updated: Jun 01 '15