Utils


Quaternions

to_quat

static utils.to_quat(orientation: Union[List[float], ndarray], format: str = 'xyzw', degrees: bool = False) ndarray

Convert orientation (A,B,C) to quaternion

Parameters:
  • orientation (3-element list or np.ndarray, optional) – The cartesian orientation to convert to quaternion

  • format (str, optional) – Quaternion format (default: “xyzw”)

  • degrees (bool, optional) – Whether the orientation is in degrees or radians (default: radians)

Raises:

AssertionError – If the format is not valid

Returns:

Quaternion in the specified format

Return type:

np.ndarray

from_quat

static utils.from_quat(quaternion: Union[List[float], ndarray], format: str = 'xyzw', degrees: bool = False) ndarray

Convert quaternion to orientation (A,B,C)

Parameters:
  • quaternion (3-element list or np.ndarray, optional) – The cartesian orientation to convert to quaternion

  • format (str, optional) – Quaternion format (default: “xyzw”)

  • degrees (bool, optional) – Whether the orientation will be returned in degrees or radians (default: radians)

Raises:

AssertionError – If the format is not valid

Returns:

Cartesian orientation (A,B,C)

Return type:

np.ndarray