ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS2 lookupTransform() - cannot get transform at time now()

asked 2021-08-24 15:09:38 -0600

kurshakuz gravatar image

updated 2021-08-24 15:12:46 -0600

I am having issues acquiring transformation at the required time using lookupTransform()

It works as expected when I use tf2::TimePointZero (i.e. the last transform) but is failing when I use this->get_clock()->now() (i.e. transformation at "now").

Code snippet:

  transformStamped = tf_buffer_->lookupTransform(
    toFrameRel, fromFrameRel,
    this->get_clock()->now(),
    50ms);

The exception I handle is as follows:

Lookup would require extrapolation into the future. Requested time 1629833266.557150 but the latest data is at time 0.000000, when looking up transform from frame [turtle1] to frame [turtle2]

I actually spawn the turtle2 and definitely it needs some time to broadcast its transform, but the error is always there. Full code is available here: https://github.com/kurshakuz/geometry...

It also seems strange to me that the the latest data is at time 0.000000 is never changing.

Please let me know if you have any ideas.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-08-24 15:13:37 -0600

tfoote gravatar image

Your problem isn't in the subscriber but the broadcaster where you're publishing the transforms with time zero.

https://github.com/kurshakuz/geometry...

You create the time object called "now" but you don't set the value to now, you just leave it default initialized which is time zero.

edit flag offensive delete link more

Comments

Thanks a lot! That makes it clear. Should I simply assign the now variable to this->get_clock()->now()?

kurshakuz gravatar image kurshakuz  ( 2021-08-24 16:02:28 -0600 )edit
1

I expect that's what you want to do if you want that variable to represent the current time when publishing.

tfoote gravatar image tfoote  ( 2021-08-24 16:08:57 -0600 )edit

Can I ask you a similar question, but based on Python? What I am trying to do is to acquire transform at time now and change the variable at https://github.com/kurshakuz/geometry... to now = self.get_clock().now(). But I always get the Could not transform turtle1 to turtle2: Lookup would require extrapolation into the future. error even when I pass the timeout parameter using different values (from 0.05 to 5.0 seconds). Do you have any clue why is that may happen? The call is as below: now = self.get_clock().now() trans = self.tf_buffer.lookup_transform( to_frame_rel, from_frame_rel, now, timeout=Duration(seconds=1.0))

kurshakuz gravatar image kurshakuz  ( 2021-08-27 11:17:11 -0600 )edit

Please ask a new question with enough information to reproduce your problem. If you can make a reduced test case that can show the problem it's easiest to help you. Also look for other similar questions on this forum first. This type of question has been asked many times.

tfoote gravatar image tfoote  ( 2021-08-27 15:25:49 -0600 )edit

Do you mind to take a look at https://answers.ros.org/question/3853... ? I added additional explanations there.

kurshakuz gravatar image kurshakuz  ( 2021-08-30 12:55:53 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2021-08-24 15:09:38 -0600

Seen: 2,021 times

Last updated: Aug 24 '21