# [rospy] keep all tf frames with short validity

Hello,

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.transform = ... # Fill with x, y, z, qx, qy, qz, qw
transformer.setTransform(transform)

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 close merge delete

Sort by » oldest newest most voted

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

The full docs for the python tf.Transfromer are: http://docs.ros.org/hydro/api/tf/html...

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.

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