ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

[rospy] keep all tf frames with short validity

asked 2014-08-01 18:33:41 -0500

courrier gravatar image


I need to save the poses of several objects and then perform transformations between them (for instance what was the coordinates of the pen with respect to the table at time t). The fact is that coordinates are not published in real time, they are read from a file publishing the frames of the objects from 0 to 100 seconds.

I would like a cache of, say 100ms, but if I want the transformer not to drop all the first 0 to 99.900 seconds so I cannot use them later. So I need a cache of 100 seconds. But with this long cache a transform is valid during 100 seconds, so when an objects disappears 10 seconds, the lookupTransform continues returning the 10s aged transform , while I would prefer it raises an exception in it's more than 100ms old.

My code is, at the moment, something like: cache_time = 100 # 100 seconds of cache to keep all frames in memory transformer = tf.Transformer(False, cache_time) transform = TransformStamped() transform.header.frame_id = "world"

for line in file:
    (time, obj_name, x, y, z, qx, qy, qz, qw) = line.split()
    transform.child_frame_id = obj_name
    transform.header.stamp = rospy.Time(float(time))
    transform.transform = ... # Fill with x, y, z, qx, qy, qz, qw

for t in all_times:
    print t, transformer.lookupTransform("table", "pen", rospy.Time(t))

I could solve it by doing everything in one pass instead of two, but I would like to separate the step "Reading of frame data" and "Usage of frame data" since the second step may be complicated or done interactively with ipython, etc... I could also use the tf.transformations methods with transforms stored in my own arrays but I'm seduced by the idea of the tf.Transformer being the only data structure that I can talk to to perform transformations.

In my problem I consider two kinds of caches: the duration a frame VALID and the duration a frame is KEPT in memory. I'm afraid this is not the tf philosophy.

Any idea before definitively dropping the tf.Transformer option? Thanks :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-02 01:53:17 -0500

ahendrix gravatar image

Perhaps you can do some of your own validity checking using tf.Transformer.getLatestCommonTime() ?

The full docs for the python tf.Transfromer are:

edit flag offensive delete link more


That's what I do in the end yes. While I read the file I also build a table with all common times for all objects. Then I compare and voila.

courrier gravatar image courrier  ( 2014-08-19 04:50:52 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-08-01 18:33:41 -0500

Seen: 244 times

Last updated: Aug 02 '14