def pose_2_xyzrpw(H):
"""Calculates the equivalent position and euler angles ([x,y,z,r,p,w] array) of the given pose according to the following operation:
Note: transl(x,y,z)*rotz(w*pi/180)*roty(p*pi/180)*rotx(r*pi/180)
See also: xyzrpw_2_pose()
:param H: pose
:type H: :class:`.Mat`"""
x = H[0,3]
y = H[1,3]
z = H[2,3]
if (H[2,0] > (1.0 - 1e-6)):
p = -pi/2
r = 0
w = math.atan2(-H[1,2],H[1,1])
elif H[2,0] < -1.0 + 1e-6:
p = pi/2
r = 0
w = math.atan2(H[1,2],H[1,1])
else:
p = math.atan2(-H[2,0],sqrt(H[0,0]*H[0,0]+H[1,0]*H[1,0]))
w = math.atan2(H[1,0],H[0,0])
r = math.atan2(H[2,1],H[2,2])
return [x, y, z, r*180/pi, p*180/pi, w*180/pi]
评论列表
文章目录