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.0Mon, 05 Jun 2017 07:35:49 -0500tf transformations euler and rotation matrix not uniquehttps://answers.ros.org/question/263133/tf-transformations-euler-and-rotation-matrix-not-unique/ I have written a little test to learn the inner wokings of tf.transformations. I make a rotation matrix from euler angels (euler_matrix) and then extract the angels from this matrix(euler_from_matrix); many times the result is not equal to the initial inbput. I am sampling euler angels from 0-pi range and I also compare tangents(also not equal). What am I doing wrong?
Here is my code
euler1 = (np.random.rand(1,3)*math.pi).tolist()[0]
R1 = euler_matrix(*euler1)
eu1 = euler_from_matrix(R1)
print np.isclose(eu1,euler1)
print np.isclose(np.tan(eu1),np.tan(euler1))Sat, 03 Jun 2017 17:48:33 -0500https://answers.ros.org/question/263133/tf-transformations-euler-and-rotation-matrix-not-unique/Comment by jarvisschultz for <p>I have written a little test to learn the inner wokings of tf.transformations. I make a rotation matrix from euler angels (euler_matrix) and then extract the angels from this matrix(euler_from_matrix); many times the result is not equal to the initial inbput. I am sampling euler angels from 0-pi range and I also compare tangents(also not equal). What am I doing wrong? </p>
<p>Here is my code</p>
<pre><code>euler1 = (np.random.rand(1,3)*math.pi).tolist()[0]
R1 = euler_matrix(*euler1)
eu1 = euler_from_matrix(R1)
print np.isclose(eu1,euler1)
print np.isclose(np.tan(eu1),np.tan(euler1))
</code></pre>
https://answers.ros.org/question/263133/tf-transformations-euler-and-rotation-matrix-not-unique/?comment=263191#post-id-263191The mapping from SO(3) (rotation matrices) to Euler angles is not unique -- there are an infinite number of Euler angles that give the same rotation matrix. I don't think that you should expect this test to always return the same set of Euler angles.Mon, 05 Jun 2017 07:33:49 -0500https://answers.ros.org/question/263133/tf-transformations-euler-and-rotation-matrix-not-unique/?comment=263191#post-id-263191Comment by jarvisschultz for <p>I have written a little test to learn the inner wokings of tf.transformations. I make a rotation matrix from euler angels (euler_matrix) and then extract the angels from this matrix(euler_from_matrix); many times the result is not equal to the initial inbput. I am sampling euler angels from 0-pi range and I also compare tangents(also not equal). What am I doing wrong? </p>
<p>Here is my code</p>
<pre><code>euler1 = (np.random.rand(1,3)*math.pi).tolist()[0]
R1 = euler_matrix(*euler1)
eu1 = euler_from_matrix(R1)
print np.isclose(eu1,euler1)
print np.isclose(np.tan(eu1),np.tan(euler1))
</code></pre>
https://answers.ros.org/question/263133/tf-transformations-euler-and-rotation-matrix-not-unique/?comment=263192#post-id-263192The more important question is, does the set of returned Euler angles actually represent the same rotation as the original set (even if the numerical values disagree)? You could try converting back to a rotation matrix and compare that to R1.Mon, 05 Jun 2017 07:35:49 -0500https://answers.ros.org/question/263133/tf-transformations-euler-and-rotation-matrix-not-unique/?comment=263192#post-id-263192