ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Tue, 01 Dec 2020 07:30:20 -0600[foxy] Is there any equivalent of matrix transformations for tf2 in ros 2 ?https://answers.ros.org/question/365958/foxy-is-there-any-equivalent-of-matrix-transformations-for-tf2-in-ros-2/ 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 ?Thu, 19 Nov 2020 04:23:22 -0600https://answers.ros.org/question/365958/foxy-is-there-any-equivalent-of-matrix-transformations-for-tf2-in-ros-2/Answer by Alrevan for <p>Hello,</p>
<p>In Ros1 you could use functions from these imports:</p>
<pre><code>from tf_matrix_ops import tf_to_matrix, matrix_to_tf
from tf.transformations import decompose_matrix
</code></pre>
<p>where you could transform tf to matrix then multiply them, take the inverse or extract informations from them.</p>
<p>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:</p>
<pre><code> 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)
</code></pre>
<p>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 ?</p>
https://answers.ros.org/question/365958/foxy-is-there-any-equivalent-of-matrix-transformations-for-tf2-in-ros-2/?answer=366722#post-id-366722An 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.Tue, 01 Dec 2020 07:30:20 -0600https://answers.ros.org/question/365958/foxy-is-there-any-equivalent-of-matrix-transformations-for-tf2-in-ros-2/?answer=366722#post-id-366722