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

[foxy] Is there any equivalent of matrix transformations for tf2 in ros 2 ?

asked 2020-11-19 04:23:22 -0500

Alrevan gravatar image

Hello,

In Ros1 you could use functions from these imports:

from tf_matrix_ops import tf_to_matrix, matrix_to_tf 
from tf.transformations import decompose_matrix

where you could transform tf to matrix then multiply them, take the inverse or extract informations from them.

I have a code sample that do the following and I would like to know if it is possible to do the same with ros2 and tf 2:

 m1 = tf_to_matrix(tf1)  
 m2 = tf_to_matrix(tf2)
 delta = np.matmul(m1, np.linalg.inv(m2)) 
 scale, shear, angles, t, perspective = decompose_matrix(delta)

I think the tf_matrix_ops and tf.transformations are not available in ros2 (or at least i did not find them) so maybe there is a new way to do this kind of thing ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-01 07:30:20 -0500

Alrevan gravatar image

An update on this question:

I realised that "tf_matrix_ops is actually" a homemade package I wrote some time ago... For the case of "transformations.py" it is reallsy starightforward to convert it to ROS 2 as it is bascically a mathematic operation package.

After this one can easily write "tf_to_matrix" and "matrix_to_tf" helper functions using euler_from_quaternion, quaternion_from_euler, compose_matrix and decompose_matrix from transformations.py.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-11-19 04:23:22 -0500

Seen: 776 times

Last updated: Dec 01 '20