geometry2 icon indicating copy to clipboard operation
geometry2 copied to clipboard

Python call callback with transform data when it becomes available

Open sloretz opened this issue 6 years ago • 4 comments

Feature

It would be convenient if there was an API that returned transform information in a callback.

Feature description

It looks like C++ has an overload of waits_for_transform that calls the callback with a future containing the transform. https://github.com/ros2/geometry2/blob/71f823e90b699c9535ce682db777f7bc88cdfbcd/tf2_ros/include/tf2_ros/buffer.h#L214-L216

Implementation considerations

It should be possible using the callbacks on the future returned by wait_for_transform_async, however the returned future is not associated with an executor so done callbacks are never called (ros2/rclpy#460).

https://github.com/ros2/geometry2/blob/71f823e90b699c9535ce682db777f7bc88cdfbcd/tf2_ros/src/tf2_ros/buffer.py#L217-L226

However, even if the done callbacks were called the result on future doesn't contain any info about the transform. It should probably have that.

sloretz avatar Nov 15 '19 18:11 sloretz

@sloretz would you mind if I looked into doing this?

allenh1 avatar Dec 06 '19 15:12 allenh1

@sloretz would you mind if I looked into doing this?

@allenh1 please do, and thank you!

sloretz avatar Dec 06 '19 15:12 sloretz

It should be possible using the callbacks on the future returned by wait_for_transform_async, however the returned future is not associated with an executor so done callbacks are never called (ros2/rclpy#460).

@sloretz since the issue you mentioned is closed now, I'm assuming this can be done as you were saying by using wait_for_transform_async, right? I'll send a PR in with that assumption and we can talk further if that wasn't a good one.

allenh1 avatar Jan 12 '20 18:01 allenh1

I've removed myself from this because I don't have the time to do this before the galactic release. Anyone who feels led to should feel free to pick up this issue. Otherwise, I might have time in a while to revisit this.

allenh1 avatar Jan 30 '21 13:01 allenh1