tf2_ros_py: Add timeouts to async buffer interfaces #797
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In contrast to the blocking tf2 Buffer Python API the async one did not feature any timeouts, severely hindering real world usability, due to the risk of deadlocks. Sadly there is no async sleep or timeout build into
rclpy
, so this PR adds a workaround using timers, which can be created with relatively low overhead. The issue is detailed in ros2/rclpy#1234 . The procedure from there is adapted to provide a timeout mechanism for tf. Due to the timers being created on the node, this only works when the optional node reference is provided.In addition to that, I noticed that the transform is actually accidentally computed twice in the current implementation. This can be attributed to #664 changing the API without making use of it in the lookup functions.
Related issue: #438
Did you use Generative AI?
I have GitHub Copilot installed and use it for autocompletion.
Additional Information