0
$\begingroup$

Rosanswers logo

tf2_ros.Buffer offers a cache_time argument in both C++ and Python implementations.

However, on calling the buffer.all_frames_as_yaml(), the frames including those outside the cache time are included. Is there a way to clear the cache periodically or to filter the "stale" frames without having to read the YAML/string for the field: most_recent_transform and then convert it into a number (which also results in a loss of precision)?

PS: My understanding of cache_time might be wrong, so I'll rephrase my question for clarity: How do I

  • Get only frames with a TF within the cache_time provided to the tf2_ros.Buffer OR
  • Clear the expired cache of tf2_ros.Buffer in Python (there's a clear function, but like in C++, it clears the entire cache)

Originally posted by kunaltyagi on ROS Answers with karma: 105 on 2021-02-15

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

There is not a method to clear the "expired" data. Due to there not being a clear definition of "now" at the library level the data is not evaluated compared to "now" but is compared to the lastest information heard on that topic. The cache expiration is only evaluated on insertion into that specific transform's history. This means that you'll have cache_time amount of history for each frame.

If you want to get the list of only frameids that have an updated data within the last X seconds I think that parsing the yaml as you're saying is likely going to be your best approach. Worrying about the precision for this seems to be a distraction compared to any useful cache duration.

A new clear method could be added to the core, however you're getting into more of the internal buffer and cache implementation and away from the specifically simple public interface for running queries.


Originally posted by tfoote with karma: 58457 on 2021-02-16

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.