Ask Your Question
0

How to get a specific latest transform from lookupTransform

asked 2020-03-20 04:50:14 -0500

pauljurczak gravatar image

updated 2020-03-20 16:51:46 -0500

I'm using tf2_ros::TransformListener listening on /tf topic, which contains various target_frame and source_frame pairs. I want to extract only a specific pair, say IMU and TURTLE. That pair is published at 250Hz according to rqt.

When I call: buffer.lookupTransform("IMU", "TURTLE", ros::Time(0)) I get "IMU" passed to lookupTransform argument target_frame does not exist exception most of the time, but occasionally a good result.

When I call: buffer.lookupTransform("IMU", "TURTLE", ros::Time::now()) or buffer.lookupTransform("IMU", "TURTLE", ros::Time::now()-ros::Duration(0.1)) I get Lookup would require extrapolation into the future... or Lookup would require extrapolation into the past...

What is a reliable way to retrieve the most current transform with given target_frame and source_frame?

EDIT

The issue was caused by simulation startup delay. waitForTransform() as suggested in the answer below is the solution to my problem. Even better is its newer incarnation: tf2_ros::Buffer::canTransform().

edit retag flag offensive close merge delete

Comments

Please edit your question provide more information about how to reproduce your problem. If the query with time zero is failing it likely means that you are not setting up your TransformListener with the right lifecycle to allow it to build up it's cache.

tfoote gravatar image tfoote  ( 2020-03-20 16:30:10 -0500 )edit

Glad to hear that worked. Please accept the answer below with the checkbox to let other know this solved your problem.

tfoote gravatar image tfoote  ( 2020-03-20 16:42:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-03-20 06:49:28 -0500

ir gravatar image

Hi, I'm not sure if that's what you are looking for, but you could use waitForTransform to wait for the transformation to become available.

Check: http://docs.ros.org/jade/api/tf/html/...

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

2 followers

Stats

Asked: 2020-03-20 04:50:14 -0500

Seen: 282 times

Last updated: Mar 20 '20