Pose Rotation Order

You can use the URScript codes rotvec2rpy(rotation_vector) and rpy2rotvec(rpy_vector) to convert the rotation vectors to RPY and vice versa in URScript.
They are both explained in the script manual.

Below are some example formulas that can be used in URScript before the above functions were implemented (3.3.0.145), other methods might work just as fine.

For conversion from RPY to rotation vector:

  def rpy2rv(roll,pitch,yaw):
  
  alpha = yaw
  beta = pitch
  gamma = roll
  
  ca = cos(alpha)
  cb = cos(beta)
  cg = cos(gamma)
  sa = sin(alpha)
  sb = sin(beta)
  sg = sin(gamma)
  
  r11 = ca*cb
  r12 = ca*sb*sg-sa*cg
  r13 = ca*sb*cg+sa*sg
  r21 = sa*cb
  r22 = sa*sb*sg+ca*cg
  r23 = sa*sb*cg-ca*sg
  r31 = -sb
  r32 = cb*sg
  r33 = cb*cg
  
  theta = acos((r11+r22+r33-1)/2)
  sth = sin(theta)
  kx = (r32-r23)/(2*sth)
  ky = (r13-r31)/(2*sth)
  kz = (r21-r12)/(2*sth)
  
  rv[0] = theta*kx
  rv[1] = theta*ky
  rv[2] = theta*kz
  
  return rv
  
  end

For conversion from rotation vector to RPY:

  def rv2rpy(rx,ry,rz):
  
  theta = sqrt(rx*rx + ry*ry + rz*rz)
  kx = rx/theta
  ky = ry/theta
  kz = rz/theta
  cth = cos(theta)
  sth = sin(theta)
  vth = 1-cos(theta)
  
  r11 = kx*kx*vth + cth
  r12 = kx*ky*vth - kz*sth
  r13 = kx*kz*vth + ky*sth
  r21 = kx*ky*vth + kz*sth
  r22 = ky*ky*vth + cth
  r23 = ky*kz*vth - kx*sth
  r31 = kx*kz*vth - ky*sth
  r32 = ky*kz*vth + kx*sth
  r33 = kz*kz*vth + cth
  
  beta = atan2(-r31,sqrt(r11*r11+r21*r21))
  
  if beta > d2r(89.99):
  beta = d2r(89.99)
  alpha = 0
  gamma = atan2(r12,r22)
  elif beta < -d2r(89.99):
  beta = -d2r(89.99)
  alpha = 0
  gamma = -atan2(r12,r22)
  else:
  cb = cos(beta)
  alpha = atan2(r21/cb,r11/cb)
  gamma = atan2(r32/cb,r33/cb)
  end
  
  rpy[0]= gamma
  rpy[1]= beta
  rpy[2]= alpha
  
  return rpy
  
  end

Additionally, check out this article.

4 Likes