How to invert the Z axis of the referential (XYZ). The orientation is expressed in quarternion?
I am acquiring the position and orientation of a tag from an RGBD camera. If this tag is placed on a table the z axis is represented upwards, which is correct. My problem arises when I try to invert the tag's referential so that the z axis direction is reversed. By inverting the axis I make the tag orientation coincident with the axis of my end-effector of my robotic arm. Thus allowing to have the orientation to perform the pick of the object.
The position and orientation of the tag is represented in quaternion, which makes it more difficult to understand. I read in several places that to invert the referential just negate the value of orientation.z and orientation.w. I tried but it doesn't work.
In the image the Z axis has been inverted so that the Z axis orientation is coincident / has the same orientation as the gripper Z axis.
I use the function quat_to_ur_axis_angle -> [https://gist.github.com/felixvd/ffafe...]
def quat_to_ur_axis_angle(quaternion):
angle = 2*atan2(norm2(quaternion[0], quaternion[1], quaternion[2]), quaternion[3])
if abs(angle) > 1e-6:
axis_normed = [ quaternion[0]/sin(angle/2), quaternion[1]/sin(angle/2), quaternion[2]/sin(angle/2) ]
else:
axis_normed = 0.0
return [axis_normed[0]*angle, axis_normed[1]*angle, axis_normed[2]*angle]
Qauternion to euler and add pi
orientation_list = [0.00840802170772, -0.0617530093498, 0.047875229621, 0.996907133787]
euler_ang = quat_to_ur_axis_angle(orientation_list)
euler_ang[0] = euler_ang[0]+pi
print(euler_ang)
result: [3.1584260550724412, -0.12363350563099307, 0.09584929598175379]
Qauternion to euler and inverse signal orientation.w
orientation_list = [0.00840802170772, -0.0617530093498, 0.047875229621, -0.996907133787]
euler_ang = quat_to_ur_axis_angle(orientation_list)
print(euler_ang)
result: [0.6553908732887168, -4.813541179230207, 3.731792048228847]
The solution I applied to get around the problem was the conversion of the quaternion to euler angles, and then add "pi" to the ROLL, to invert the referential.
How can I reverse the referential in a more correct way?
I tried but it doesn't work.
- how exactly does it not work? Can you edit the question and add your reasons and how you checked it?Thanks, I have already edited the question. I know adding "pi" works because I've tested it on the robot and I have it working that way.
When you say "If this tag is placed on a table the z axis is represented upwards", which Transform Frame are you using for that pose?
That position is in the camera frame. Which I then transform to the frame of the robotic arm. The transformations are correct because the position is right, my only problem is in the orientation. Which only works by adding that "pi" to invert the z axis.
Can you draw your setup in Gimp or something like that? Adding pi to invert the
z
axis sounds like a rotation, not inverting, which one exactly?Yes, in this case I rotate around the Y-axis, so that the z-axis is reversed. Sorry I'm not allowed to upload a picture
I upvoted the question and your comments, you should have now enough karma to upload pictures, I hope
Thank you very much. I have now placed the images with the axis. To better understand how the inversion of the axis is made.