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

How to save entire tf tree for a single timestamp in python?

asked 2020-11-17 17:04:24 -0500

utkarshjp7 gravatar image

updated 2020-11-20 17:04:00 -0500

I want to be able to save the current state of tf tree in python so that I can lookup the desired transforms from the saved tf tree at a later point.

edit retag flag offensive close merge delete

Comments

Did you try rosrun tf view_frames?

skpro19 gravatar image skpro19  ( 2020-11-18 04:05:32 -0500 )edit
1

view_frames saves the tree as pdf. I want to save it in some format so that I can read from it programatically.

utkarshjp7 gravatar image utkarshjp7  ( 2020-11-18 08:29:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2020-11-20 16:32:57 -0500

lucasw gravatar image

updated 2020-11-20 16:37:58 -0500

It sounds like you want to serialize and the deserialize all the tf data in a tf2_ros Buffer, which doesn't look supported.

One possibly glitchy approach is to record the /tf and /tf_static topics into a bag for 10-20 seconds, then play it back in a loop, then do tf lookups. There may be glitches for lookups around when the bag loops, or around anything on tf_static.

To do better than that you would iterate through all the tf messages in the bag file (http://wiki.ros.org/rosbag/Code%20API...) and load them into a BufferCore object, which can be private and unchanging once your are done setting transforms into it (as opposed to listening to /tf and overwriting stored transforms with new ones, and forgetting transforms as they get too old with a regular paired buffer and transform listener). Then you can query the BufferCore. See #q289323

There is a get_frames method in Buffer that has a tf2_frames service- but it only returns what the frames are named and their parent child relationship in yaml, not their spatial relationship (and there would need to be a corresponding set_frames method to turn yaml back into a query-able Buffer). It looks like it was mainly meant to support the view_frames visualization.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-11-17 17:04:24 -0500

Seen: 561 times

Last updated: Nov 20 '20