Thank you very much for the comment.
Yes, I know that there are multiple rotation vectors that can describe an identical 3d rotation.
But I am not sure if that’s the point here.
In order to check if two rotation vectors are identical 3D rotation, you can for example calculate the rotation matrix, and see if they are identical.
For example, [pi, 0, 0] and [-pi, 0, 0] are identical 3D rotation, and those rotation matrices are
>>> scipy.spatial.transform.Rotation.from_rotvec([math.pi, 0, 0]).as_matrix()
array([[ 1.0000000e+00, 0.0000000e+00, 0.0000000e+00],
[ 0.0000000e+00, -1.0000000e+00, -1.2246468e-16],
[ 0.0000000e+00, 1.2246468e-16, -1.0000000e+00]])
>>> scipy.spatial.transform.Rotation.from_rotvec([-math.pi, 0, 0]).as_matrix()
array([[ 1.0000000e+00, -0.0000000e+00, 0.0000000e+00],
[ 0.0000000e+00, -1.0000000e+00, 1.2246468e-16],
[-0.0000000e+00, -1.2246468e-16, -1.0000000e+00]])
The RPY angle [pi, 0, 9/10 pi]
is converted to [-0.49145, 3.10291, 0]
with rpy2rotvec()
in the URScript, while it is converted to [-0.07688, 0.4854, 0]
with the script in the past post.
These two rotation vectors don’t seem to describe the same 3D rotation, because the rotation matrices are different.
>>> scipy.spatial.transform.Rotation.from_rotvec([-0.49145, 3.10291, 0]).as_matrix()
array([[-9.51057034e-01, -3.09015401e-01, 4.84641805e-06],
[-3.09015401e-01, 9.51057034e-01, 7.67593050e-07],
[-4.84641805e-06, -7.67593050e-07, -1.00000000e+00]])
>>> scipy.spatial.transform.Rotation.from_rotvec([-0.07688, 0.4854, 0]).as_matrix()
array([[ 0.8845455 , -0.01828624, 0.46609534],
[-0.01828624, 0.99710374, 0.07382243],
[-0.46609534, -0.07382243, 0.88164924]])
So my question is still, how the calculation is handled when sth
is close to zero in the script of Universal Robots - RPY to/from rotation vector ?
Is it safe to assume that similar calculation is done as in opencv’s Rodrigues function ?
opencv/modules/calib3d/src/calibration.cpp at 3901426d8515cd8d1c07654ec7e9e8bc3b51a06f · opencv/opencv · GitHub
When I calculate the conversion with openCV’s Rodrigues function, I got different results, but actually these 3D rotation are very close,
>>> scipy.spatial.transform.Rotation.from_rotvec([-0.49145, 3.10291, 0]).as_matrix()
array([[-9.51057034e-01, -3.09015401e-01, 4.84641805e-06],
[-3.09015401e-01, 9.51057034e-01, 7.67593050e-07],
[-4.84641805e-06, -7.67593050e-07, -1.00000000e+00]])
>>> scipy.spatial.transform.Rotation.from_rotvec([0.49145, -3.10291, 0]).as_matrix()
array([[-9.51057034e-01, -3.09015401e-01, -4.84641805e-06],
[-3.09015401e-01, 9.51057034e-01, -7.67593050e-07],
[ 4.84641805e-06, 7.67593050e-07, -1.00000000e+00]])
The other is that a well formulated axis angle vector is of the form [x, y, z]*rotation where the vector [x, y, z] us a unit vector (which is vector of length one) and the rotation is a rotation about this unit vector.
The rotation should ideally be within ±pi (±180deg) as a lager rotation could otherwise be described by a smaller rotation with the opposite sign.
And as far as I can see both of you examples have rotations that exceeds pi/2.
I am converting a Roll-Pitch-Yaw angle to a rotation vector, so as far as the all of the roll, pitch and yaw angles are within a specific range (+/- pi), I think rpy2rotvec()
should be able to handle the rotation angle to be within the +/- pi range, shouldn’t it?
Thanks,