def angle_between_quaternions(q1, q2):
  """ Returns the angle between two quaternions, q1 and q2. """
  if np.allclose(q1.q, q2.q, atol=1.e-12):
    return 0.0
  return 2. * np.arccos((q1 * q2.inverse()).w)
 Returns the angle between two quaternions, q1 and q2. 
hand_eye_calibration/python/hand_eye_calibration/quaternion.py