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))
The 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.
The 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.