paralleldomain.model.sensor

class CameraModel

Camera Model short hands for value-safe access.

OPENCV_PINHOLE

Returns internally used string-representation for OpenCV Pinhole camera model.

Accepts distortion parameters (k1,k2,p1,p2[,k3[,k4,k5,k6]]) and uses projection (+ distortion) function as described in the OpenCV Pinhole documentation

Type

str

OPENCV_FISHEYE

Returns internally used string-representation for OpenCV Fisheye camera model

Accepts distortion parameters (k1,k2,k3,k4) and uses projection (+ distortion) function as described in the OpenCV Fisheye documentation

Type

str

PD_FISHEYE

Returns internally used string-representation for Parallel Domain Fisheye camera model

Uses custom distortion lookup table for translation between non-distorted and distorted angles.

Type

str

class SensorFrame(sensor_name, frame_id, decoder)
class LidarSensorFrame(sensor_name, frame_id, decoder)
class CameraSensorFrame(sensor_name, frame_id, decoder)
class Sensor(sensor_name, decoder)
class CameraSensor(sensor_name, decoder)
class LidarSensor(sensor_name, decoder)
class SensorPose(quaternion=None, translation=None)
Parameters
  • quaternion (Union[pyquaternion.quaternion.Quaternion, List[float], numpy.ndarray]) –

  • translation (Union[numpy.ndarray, List]) –

as_euler_angles(order, degrees=False)

Returns the rotation of a Transformation object as euler angles.

Parameters
  • order (str) – Defines the axes rotation order. Use lower case for extrinsic rotation, upper case for intrinsic rotation. Ex: xyz, ZYX, xzx.

  • degrees (bool) – Defines if euler angles should be returned in degrees instead of radians. Default: False

Returns

Ordered array of euler angles with length 3.

Return type

ndarray

classmethod from_euler_angles(angles, order, translation=None, degrees=False)

Creates a transformation object from euler angles and optionally translation (default: (0,0,0))

Parameters
  • angles (Union[numpy.ndarray, List[float]]) – Ordered euler angles array with length 3

  • translation (Optional[numpy.ndarray]) – Translation vector in order (x,y,z). Default: [0,0,0]

  • order (str) – Defines the axes rotation order. Use lower case for extrinsic rotation, upper case for intrinsic rotation. Ex: xyz, ZYX, xzx.

  • degrees (bool) – Defines if euler angles are provided in degrees instead of radians. Default: False

Returns

Instance of Transformation with provided parameters.

Return type

Transformation

classmethod from_transformation_matrix(mat)

Creates a Transformation object from an homogeneous transformation matrix of shape (4,4)

Parameters

mat (numpy.ndarray) – Transformation matrix as described in transformation_matrix

Returns

Instance of Transformation with provided parameters.

Return type

Transformation

property inverse: paralleldomain.utilities.transformation.Transformation

Returns the inverse transformation as a new Transformation object.

Return type

Transformation

property quaternion: pyquaternion.quaternion.Quaternion

Returns the rotation as a pyquaternion.quaternion.Quaternion instance.

Full documentation can be found in pyquaternion API Documentation.

To get the quaternion coefficients, either call .elements, iterate over the object itself or use the dedicated named properties. The element order (until explicitly stated otherwise) should always be assumed as (w,x,y,z) for function w + xi+ yj + zk

from paralleldomain.model.transformation import Transformation

tf = Transformation.from_euler_angles(yaw=90, pitch=0, roll=0, is_degrees=True)

assert(tf.quaternion.elements[0] == tf.quaternion[0] == tf.quaternion.w)
assert(tf.quaternion.elements[1] == tf.quaternion[1] == tf.quaternion.x)
assert(tf.quaternion.elements[2] == tf.quaternion[2] == tf.quaternion.y)
assert(tf.quaternion.elements[3] == tf.quaternion[3] == tf.quaternion.z)

Please note that when using scipy.spatial.transform.Rotation, scipy assumes the order as (x,y,w,z).

from paralleldomain.model.transformation import Transformation
from scipy.spatial.transform import Rotation
import numpy as np

tf = Transformation.from_euler_angles(yaw=90, pitch=0, roll=0, is_degrees=True)
tf_scipy = Rotation.from_quat([
    tf.quaternion.x,
    tf.quaternion.y,
    tf.quaternion.z,
    tf.quaternion.w
])

# Check that rotation quaternion is equal within tolerance
np.allclose(tf.rotation == tf_scipy.as_matrix())  # returns True
Return type

Quaternion

property rotation: numpy.ndarray

Returns the rotation matrix in shape (3,3).

/              \
|R_11 R_12 R_13|
|R_21 R_22 R_23|
|R_31 R_32 R_33|
\              /
Return type

ndarray

property transformation_matrix: numpy.ndarray

Returns the homogeneous transformation matrix in shape (4,4).

/                  \
|R_11 R_12 R_13 t_x|
|R_21 R_22 R_23 t_y|
|R_31 R_32 R_33 t_z|
|0    0    0    1  |
\                  /
Return type

ndarray

property translation: numpy.ndarray

Returns the translation vector (x,y,z) in shape (3,).

Return type

ndarray

class SensorExtrinsic(quaternion=None, translation=None)
Parameters
  • quaternion (Union[pyquaternion.quaternion.Quaternion, List[float], numpy.ndarray]) –

  • translation (Union[numpy.ndarray, List]) –

as_euler_angles(order, degrees=False)

Returns the rotation of a Transformation object as euler angles.

Parameters
  • order (str) – Defines the axes rotation order. Use lower case for extrinsic rotation, upper case for intrinsic rotation. Ex: xyz, ZYX, xzx.

  • degrees (bool) – Defines if euler angles should be returned in degrees instead of radians. Default: False

Returns

Ordered array of euler angles with length 3.

Return type

ndarray

classmethod from_euler_angles(angles, order, translation=None, degrees=False)

Creates a transformation object from euler angles and optionally translation (default: (0,0,0))

Parameters
  • angles (Union[numpy.ndarray, List[float]]) – Ordered euler angles array with length 3

  • translation (Optional[numpy.ndarray]) – Translation vector in order (x,y,z). Default: [0,0,0]

  • order (str) – Defines the axes rotation order. Use lower case for extrinsic rotation, upper case for intrinsic rotation. Ex: xyz, ZYX, xzx.

  • degrees (bool) – Defines if euler angles are provided in degrees instead of radians. Default: False

Returns

Instance of Transformation with provided parameters.

Return type

Transformation

classmethod from_transformation_matrix(mat)

Creates a Transformation object from an homogeneous transformation matrix of shape (4,4)

Parameters

mat (numpy.ndarray) – Transformation matrix as described in transformation_matrix

Returns

Instance of Transformation with provided parameters.

Return type

Transformation

property inverse: paralleldomain.utilities.transformation.Transformation

Returns the inverse transformation as a new Transformation object.

Return type

Transformation

property quaternion: pyquaternion.quaternion.Quaternion

Returns the rotation as a pyquaternion.quaternion.Quaternion instance.

Full documentation can be found in pyquaternion API Documentation.

To get the quaternion coefficients, either call .elements, iterate over the object itself or use the dedicated named properties. The element order (until explicitly stated otherwise) should always be assumed as (w,x,y,z) for function w + xi+ yj + zk

from paralleldomain.model.transformation import Transformation

tf = Transformation.from_euler_angles(yaw=90, pitch=0, roll=0, is_degrees=True)

assert(tf.quaternion.elements[0] == tf.quaternion[0] == tf.quaternion.w)
assert(tf.quaternion.elements[1] == tf.quaternion[1] == tf.quaternion.x)
assert(tf.quaternion.elements[2] == tf.quaternion[2] == tf.quaternion.y)
assert(tf.quaternion.elements[3] == tf.quaternion[3] == tf.quaternion.z)

Please note that when using scipy.spatial.transform.Rotation, scipy assumes the order as (x,y,w,z).

from paralleldomain.model.transformation import Transformation
from scipy.spatial.transform import Rotation
import numpy as np

tf = Transformation.from_euler_angles(yaw=90, pitch=0, roll=0, is_degrees=True)
tf_scipy = Rotation.from_quat([
    tf.quaternion.x,
    tf.quaternion.y,
    tf.quaternion.z,
    tf.quaternion.w
])

# Check that rotation quaternion is equal within tolerance
np.allclose(tf.rotation == tf_scipy.as_matrix())  # returns True
Return type

Quaternion

property rotation: numpy.ndarray

Returns the rotation matrix in shape (3,3).

/              \
|R_11 R_12 R_13|
|R_21 R_22 R_23|
|R_31 R_32 R_33|
\              /
Return type

ndarray

property transformation_matrix: numpy.ndarray

Returns the homogeneous transformation matrix in shape (4,4).

/                  \
|R_11 R_12 R_13 t_x|
|R_21 R_22 R_23 t_y|
|R_31 R_32 R_33 t_z|
|0    0    0    1  |
\                  /
Return type

ndarray

property translation: numpy.ndarray

Returns the translation vector (x,y,z) in shape (3,).

Return type

ndarray