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

How to get data from lookupTransform() without publishing tf data?

asked 2014-07-08 11:29:49 -0600

jlef gravatar image

Hi all,

I am working on processing some data stored in a bag file. I am perfectly comfortable reading data and messages from bag files using python's rosbag module. I am not sure if this is a silly or naive question, but my searching thus far has not led very far. Here's the situation:

I have my tf messages stored in a bag file. The tf values for different frames do not change over time (rigid system). I know the names and transforms for the frames since this is stored in the bag data. What I would like to do is get the same functionality from lookupTransform() without needing to publish my transforms and listen form them to get the calculations performed by this function. It would be excellent to achieve this python, since this is language that my processing code is using. Essentially, I'm trying to perform the following in python without needing to actually perform the lookup by the frame id string.

StampedTransform& transform    
tf::StampedTransform from_geometry_messages1, from_geometry_messages2;
transform.setData( temp2 * temp1);
transform.stamp_ = temp2.stamp_;
transform.frame_id_ = target_frame;
transform.child_frame_id_ = source_frame;

Instead I would simply like to perform the calculation portions of the lookupTransform code in python.

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2014-07-08 11:37:32 -0600

dornhege gravatar image

You can feed a python transformer manually with messages. This is what I used in some post processing code:

tf_t = tf.Transformer(True, rospy.Duration(3600.0))
bag = rosbag.Bag(bag_file)
for topic, msg, t in bag.read_messages(topics=['/tf']):
    for msg_tf in msg.transforms:
        tf_t.setTransform(msg_tf)
bag.close()

You can now use the tf.Transformer as if it was filled from topics, i.e. call lookupTransform, etc.

edit flag offensive delete link more

Comments

Excellent answer. Really helped.

RachitB11 gravatar image RachitB11  ( 2018-07-11 15:53:39 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2014-07-08 11:29:49 -0600

Seen: 1,938 times

Last updated: Jul 08 '14