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

transform composition in tf with python

asked 2016-08-23 05:52:13 -0600

Anis gravatar image


In C++, it is possible to have transform composition to determine a relative transform between two transforms like follow:

tf::Transform relative_transform = init_transform.inverse() * current_transform;
distance_moved= relative_transform.getOrigin().length();

However, I could not find similar alternative in Python.

Is there any means in Python to do a similar relative transformation like the C++ code?

Thank you Anis

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-23 06:55:55 -0600

Airuno2L gravatar image

The python TF library uses the module which is really nice. If you haven't used it, the main idea is it uses 4x4 matrices to represent transformations and there are tons of functions for linear algebra and converting to different representations. It's really just a wrapper around numpy, but it does a good job.

To use it, I do from tf import transformations as t

The whole module is just that one file I linked to, the documentation/examples in the comments are really good.

It has t.inverse_matrix()instead of .inverse(). Also t.translation_from_matrix() will do what .getOrigin() does. And for .length() you would use t.vector_norm()

You can probably figure out the rest, if not I can help in the comments.

edit flag offensive delete link more


Thank you very much, it helps a lot. I will try these hints!

Anis gravatar image Anis  ( 2016-08-25 05:10:16 -0600 )edit

Question Tools

1 follower


Asked: 2016-08-23 05:52:13 -0600

Seen: 1,847 times

Last updated: Aug 23 '16