airobot.utils.common¶
-
airobot.utils.common.
ang_in_mpi_ppi
(angle)[source]¶ Convert the angle to the range [-pi, pi).
Parameters: angle (float) – angle in radians. Returns: float – equivalent angle in [-pi, pi).
-
airobot.utils.common.
clamp
(n, minn, maxn)[source]¶ Clamp the input value to be in [minn, maxn].
Parameters: Returns: float or int – clamped value.
-
airobot.utils.common.
create_se3
(ori, trans=None)[source]¶ Parameters: - ori (np.ndarray) – orientation in any following form: rotation matrix (shape: \([3, 3]\)) quaternion (shape: \([4]\)) euler angles (shape: \([3]\)).
- trans (np.ndarray) – translational vector (shape: \([3]\))
Returns: np.ndarray – a transformation matrix (shape: \([4, 4]\))
-
airobot.utils.common.
euler2quat
(euler, axes='xyz')[source]¶ Convert euler angles to quaternion.
Parameters: - euler (list or np.ndarray) – euler angles (shape: \([3,]\)).
- axes (str) – Specifies sequence of axes for rotations. 3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations (rotation about the axes of a coordinate system XYZ attached to a moving body), or {‘x’, ‘y’, ‘z’} for extrinsic rotations (rotation about the axes of the fixed coordinate system).
Returns: np.ndarray – quaternion [x,y,z,w] (shape: \([4,]\)).
-
airobot.utils.common.
euler2rot
(euler, axes='xyz')[source]¶ Convert euler angles to rotation matrix.
Parameters: - euler (list or np.ndarray) – euler angles (shape: \([3,]\)).
- axes (str) – Specifies sequence of axes for rotations. 3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations (rotation about the axes of a coordinate system XYZ attached to a moving body), or {‘x’, ‘y’, ‘z’} for extrinsic rotations (rotation about the axes of the fixed coordinate system).
Returns: np.ndarray – rotation matrix (shape: \([3, 3]\)).
-
airobot.utils.common.
linear_interpolate_path
(start_pos, delta_xyz, interval)[source]¶ Linear interpolation in a path.
Parameters: Returns: np.ndarray – waypoints along the path (shape: \([N, 3]\)).
-
airobot.utils.common.
list_class_names
(dir_path)[source]¶ Return the mapping of class names in all files in dir_path to their file path.
Parameters: dir_path (str) – absolute path of the folder. Returns: dict – mapping from the class names in all python files in the folder to their file path.
-
airobot.utils.common.
load_class_from_path
(cls_name, path)[source]¶ Load a class from the file path.
Parameters: Returns: Python Class – return the class A which is named as cls_name. You can call A() to create an instance of this class using the return value.
-
airobot.utils.common.
print_blue
(skk)[source]¶ print the text in blue color.
Parameters: skk (str) – text to be printed.
-
airobot.utils.common.
print_cyan
(skk)[source]¶ print the text in cyan color.
Parameters: skk (str) – text to be printed.
-
airobot.utils.common.
print_green
(skk)[source]¶ print the text in green color.
Parameters: skk (str) – text to be printed.
-
airobot.utils.common.
print_purple
(skk)[source]¶ print the text in purple color.
Parameters: skk (str) – text to be printed.
-
airobot.utils.common.
print_red
(skk)[source]¶ print the text in red color.
Parameters: skk (str) – text to be printed.
-
airobot.utils.common.
print_yellow
(skk)[source]¶ print the text in yellow color.
Parameters: skk (str) – text to be printed.
-
airobot.utils.common.
quat2euler
(quat, axes='xyz')[source]¶ Convert quaternion to euler angles.
Parameters: - quat (list or np.ndarray) – quaternion [x,y,z,w] (shape: \([4,]\)).
- axes (str) – Specifies sequence of axes for rotations. 3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations (rotation about the axes of a coordinate system XYZ attached to a moving body), or {‘x’, ‘y’, ‘z’} for extrinsic rotations (rotation about the axes of the fixed coordinate system).
Returns: np.ndarray – euler angles (shape: \([3,]\)).
-
airobot.utils.common.
quat2rot
(quat)[source]¶ Convert quaternion to rotation matrix.
Parameters: quat (list or np.ndarray) – quaternion [x,y,z,w] (shape: \([4,]\)). Returns: np.ndarray – rotation matrix (shape: \([3, 3]\)).
-
airobot.utils.common.
quat2rotvec
(quat)[source]¶ Convert quaternion to rotation vector.
Parameters: quat (list or np.ndarray) – quaternion [x,y,z,w] (shape: \([4,]\)). Returns: np.ndarray – rotation vector (shape: \([3,]\)).
-
airobot.utils.common.
quat_inverse
(quat)[source]¶ Return the quaternion inverse.
Parameters: quat (list or np.ndarray) – quaternion [x,y,z,w] (shape: \([4,]\)). Returns: np.ndarray – inverse quaternion (shape: \([4,]\)).
-
airobot.utils.common.
quat_multiply
(quat1, quat2)[source]¶ Quaternion mulitplication.
Parameters: Returns: np.ndarray – quat1 * quat2 (shape: \([4,]\)).
-
airobot.utils.common.
rot2euler
(rot, axes='xyz')[source]¶ Convert rotation matrix to euler angles.
Parameters: - rot (np.ndarray) – rotation matrix (shape: \([3, 3]\)).
- axes (str) – Specifies sequence of axes for rotations. 3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations (rotation about the axes of a coordinate system XYZ attached to a moving body), or {‘x’, ‘y’, ‘z’} for extrinsic rotations (rotation about the axes of the fixed coordinate system).
Returns: np.ndarray – euler angles (shape: \([3,]\)).
-
airobot.utils.common.
rot2quat
(rot)[source]¶ Convert rotation matrix to quaternion.
Parameters: rot (np.ndarray) – rotation matrix (shape: \([3, 3]\)). Returns: np.ndarray – quaternion [x,y,z,w] (shape: \([4,]\)).
-
airobot.utils.common.
rot2rotvec
(rot)[source]¶ Convert rotation matrix to quaternion.
Parameters: rot (np.ndarray) – rotation matrix (shape: \([3, 3]\)). Returns: np.ndarray – a rotation vector (shape: \([3,]\)).
-
airobot.utils.common.
rotvec2euler
(vec, axes='xyz')[source]¶ A rotation vector is a 3 dimensional vector which is co-directional to the axis of rotation and whose norm gives the angle of rotation (in radians).
Parameters: - vec (list or np.ndarray) – a rotational vector. Its norm represents the angle of rotation.
- axes (str) – Specifies sequence of axes for rotations. 3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations (rotation about the axes of a coordinate system XYZ attached to a moving body), or {‘x’, ‘y’, ‘z’} for extrinsic rotations (rotation about the axes of the fixed coordinate system).
Returns: np.ndarray – euler angles (shape: \([3,]\)).
-
airobot.utils.common.
rotvec2quat
(vec)[source]¶ A rotation vector is a 3 dimensional vector which is co-directional to the axis of rotation and whose norm gives the angle of rotation (in radians).
Parameters: vec (list or np.ndarray) – a rotational vector. Its norm represents the angle of rotation. Returns: np.ndarray – quaternion [x,y,z,w] (shape: \([4,]\)).
-
airobot.utils.common.
rotvec2rot
(vec)[source]¶ A rotation vector is a 3 dimensional vector which is co-directional to the axis of rotation and whose norm gives the angle of rotation (in radians).
Parameters: vec (list or np.ndarray) – a rotational vector. Its norm represents the angle of rotation. Returns: np.ndarray – rotation matrix (shape: \([3, 3]\)).
-
airobot.utils.common.
se3_to_trans_ori
(se3, ori='quat', axes='xyz')[source]¶ Parameters: Returns: 2-element tuple containing
- np.ndarray: translational vector (shape: \([3,]\)).
- np.ndarray: rotational vector/matrix.
-
airobot.utils.common.
to_euler_angles
(ori, axes='xyz')[source]¶ Convert orientation in any form (rotation matrix, quaternion, or euler angles) to euler angles (roll, pitch, yaw).
Parameters: - ori (list or np.ndarray) – orientation in any following form: rotation matrix (shape: \([3, 3]\)) quaternion (shape: \([4]\)) euler angles (shape: \([3]\)).
- axes (str) – Specifies sequence of axes for rotations. 3 characters belonging to the set {‘X’, ‘Y’, ‘Z’} for intrinsic rotations (rotation about the axes of a coordinate system XYZ attached to a moving body), or {‘x’, ‘y’, ‘z’} for extrinsic rotations (rotation about the axes of the fixed coordinate system).
Returns: np.ndarray –
- euler angles (shape: \([3,]\)).
By default, it’s [roll, pitch, yaw]
-
airobot.utils.common.
to_quat
(ori)[source]¶ Convert orientation in any form (rotation matrix, quaternion, or euler angles) to quaternion.
Parameters: ori (list or np.ndarray) – orientation in any following form: rotation matrix (shape: \([3, 3]\)) quaternion (shape: \([4]\)) euler angles (shape: \([3]\)). Returns: np.ndarray – quaternion [x, y, z, w](shape: \([4, ]\)).
-
airobot.utils.common.
to_rot_mat
(ori)[source]¶ Convert orientation in any form (rotation matrix, quaternion, or euler angles) to rotation matrix.
Parameters: ori (list or np.ndarray) – orientation in any following form: rotation matrix (shape: \([3, 3]\)) quaternion (shape: \([4]\)) euler angles (shape: \([3]\)). Returns: np.ndarray – orientation matrix (shape: \([3, 3]\)).