def quaternion_lerp(q_1, q_2, fraction):
  """ Quaternion lerp.

  Linear quaternion interpolation method.
  """
  assert fraction >= 0.0 and fraction <= 1.0, "fraction should be in [0,1]."
  assert isinstance(q_1, Quaternion), "q_1 should be of Quaternion type."
  assert isinstance(q_2, Quaternion), "q_2 should be of Quaternion type."
  assert np.isclose(
      q_1.norm(), 1.0, atol=1.e-8), "Slerp should only be used with unit quaternions."
  assert np.isclose(
      q_2.norm(), 1.0, atol=1.e-8), "Slerp should only be used with unit quaternions."

  q1 = q_1.q.copy()
  q2 = q_2.q.copy()
  if fraction == 0.0:
    return Quaternion(q=q1)
  if fraction == 1.0:
    return Quaternion(q=q2)

  dot_product = np.dot(q1, q2)
  return Quaternion(q=q1 + fraction * (q2 - q1))
 Quaternion lerp.

  Linear quaternion interpolation method.
  
hand_eye_calibration/python/hand_eye_calibration/quaternion.py