Skip to content

dataclass

Box3D dataclass

Box3D(unix_time: int, frame_id: str, semantic_label: SemanticLabel, position: TranslationType, rotation: RotationType, shape: Shape, velocity: VelocityType | None = None, num_points: int | None = None, *, confidence: float = 1.0, uuid: str | None = None)

A class to represent 3D box.

Attributes:

  • unix_time (int) –

    Unix timestamp.

  • frame_id (str) –

    Coordinates frame ID where the box is with respect to.

  • semantic_label (SemanticLabel) –

    SemanticLabel object.

  • confidence (float) –

    Confidence score of the box.

  • uuid (str | None) –

    Unique box identifier.

  • position (TranslationType) –

    Box center position (x, y, z).

  • rotation (RotationType) –

    Box rotation quaternion.

  • shape (Shape) –

    Shape object.

  • velocity (VelocityType | None) –

    Box velocity (vx, vy, vz).

  • num_points (int | None) –

    The number of points inside the box.

  • future (list[Trajectory] | None) –

    Box trajectory in the future of each mode.

Examples:

>>> # without future
>>> box3d = Box3D(
...     unix_time=100,
...     frame_id="base_link",
...     semantic_label=SemanticLabel(LabelID.CAR),
...     position=(1.0, 1.0, 1.0),
...     rotation=Quaternion([0.0, 0.0, 0.0, 1.0]),
...     shape=Shape(shape_type=ShapeType.BOUNDING_BOX, size=(1.0, 1.0, 1.0)),
...     velocity=(1.0, 1.0, 1.0),
...     confidence=1.0,
...     uuid="car3d_0",
... )
>>> # with future
>>> box3d = box3d.with_future(
...     waypoints=[[[1.0, 1.0, 1.0], [2.0, 2.0, 2.0], [3.0, 3.0, 3.0]]],
...     confidences=[1.0],
... )

with_future

with_future(waypoints: list[TrajectoryType], confidences: list[float]) -> Self

Return a self instance setting future attribute.

Parameters:

  • waypoints (list[TrajectoryType]) –

    List of waypoints for each mode.

  • confidences (list[float]) –

    List of confidences for each mode.

Returns:

  • Self

    Self instance after setting future.

corners

corners(box_scale: float = 1.0) -> NDArrayF64

Return the bounding box corners.

Parameters:

  • box_scale (float, default: 1.0 ) –

    Multiply size by this factor to scale the box.

Returns:

  • NDArrayF64

    First four corners are the ones facing forward. The last four are the ones facing backwards, in the shape of (8, 3).

Box2D dataclass

Box2D(unix_time: int, frame_id: str, semantic_label: SemanticLabel, roi: Roi | None = None, *, confidence: float = 1.0, uuid: str | None = None)

A class to represent 2D box.

Attributes:

  • unix_time (int) –

    Unix timestamp.

  • frame_id (str) –

    Coordinates frame ID where the box is with respect to.

  • semantic_label (SemanticLabel) –

    SemanticLabel object.

  • confidence (float) –

    Confidence score of the box.

  • uuid (str | None) –

    Unique box identifier.

  • roi (Roi | None) –

    Roi object.

  • position (TranslationType | None) –

    3D position (x, y, z).

Examples:

>>> # without 3D position
>>> box2d = Box2D(
...     unix_time=100,
...     frame_id="camera",
...     semantic_label=SemanticLabel(LabelID.CAR),
...     roi=(100, 100, 50, 50),
...     confidence=1.0,
...     uuid="car2d_0",
... )
>>> # with 3D position
>>> box2d = box2d.with_position(position=(1.0, 1.0, 1.0))

with_position

with_position(position: TranslationType) -> Self

Return a self instance setting position attribute.

Parameters:

  • position (TranslationType) –

    3D position.

Returns:

  • Self

    Self instance after setting position.

distance_box

distance_box(box: BoxType, tf_matrix: HomogeneousMatrix) -> float | None

Return a box distance from base_link.

Parameters:

Raises:

  • TypeError

    Expecting type of box is Box2D or Box3D.

Returns:

  • float | None

    float | None: Return None if the type of box is Box2D and its position is None, otherwise returns distance from base_link.

LabelID

Enum of label elements.

SemanticLabel dataclass

SemanticLabel(label: LabelID, original: str | None = None, attributes: list[str] = list())

A dataclass to represent semantic labels.

Attributes:

  • label (LabelID) –

    Label ID.

  • original (str | None) –

    Original name of the label.

  • attributes (list[str]) –

    List of attribute names.

convert_label

convert_label(original: str, attributes: list[str] | None = None, *, name_mapping: dict[str, str] | None = None, update_default_mapping: bool = False) -> SemanticLabel

Covert string original label name to SemanticLabel object.

Parameters:

  • original (str) –

    Original label name. For example, vehicle.car.

  • attributes (list[str] | None, default: None ) –

    List of label attributes.

  • name_mapping (dict[str, str] | None, default: None ) –

    Name mapping for original and label. If None, DEFAULT_NAME_MAPPING will be used.

  • update_default_mapping (bool, default: False ) –

    Whether to update DEFAULT_NAME_MAPPING by name_mapping. If False and name_mapping is specified, the specified name_mapping is used instead of DEFAULT_NAME_MAPPING completely. Note that, this parameter works only if name_mapping is specified.

Returns:

PointCloud dataclass

PointCloud(points: NDArrayFloat)

Abstract base dataclass for pointcloud data.

num_dims abstractmethod staticmethod

num_dims() -> int

Return the number of the point dimensions.

Returns:

  • int ( int ) –

    The number of the point dimensions.

from_file abstractmethod classmethod

from_file(filepath: str) -> Self

Create an object from pointcloud file.

Parameters:

  • filepath (str) –

    File path of the pointcloud file.

Returns:

  • Self

    Self instance.

num_points

num_points() -> int

Return the number of points.

Returns:

  • int ( int ) –

    description

LidarPointCloud dataclass

LidarPointCloud(points: NDArrayFloat)

A dataclass to represent lidar pointcloud.

ShapeType

Bases: Enum

from_name classmethod

from_name(name: str) -> Self

Return an enum object from the name of the member.

Parameters:

  • name (str) –

    Name of enum member.

Returns:

  • Self

    Enum object.

Shape dataclass

Shape(shape_type: ShapeType, size: SizeType, footprint: Polygon = None)

A dataclass to represent the 3D box shape.

Examples:

>>> shape = Shape(
...     shape_type=ShapeType.BOUNDING_BOX,
...     size=[1.0, 1.0, 1.0]
... )

Trajectory dataclass

Trajectory(waypoints: TrajectoryType, confidence: float = 1.0)

A dataclass to represent trajectory.

Attributes:

  • waypoints (TrajectoryType) –

    Waypoints matrix in the shape of (N, 3).

  • confidence (float) –

    Confidence score the trajectory.

Examples:

>>> trajectory = Trajectory(
...     waypoints=[[1.0, 1.0, 1.0], [2.0, 2.0, 2.0]],
...     confidence=1.0,
... )
# Get the number of waypoints.
>>> len(trajectory)
2
# Access the shape of waypoints matrix: (N, 3).
>>> trajectory.shape
(2, 3)
# Access each point as subscriptable.
>>> trajectory[0]
array([1., 1., 1.])
# Access each point as iterable.
>>> for point in trajectory:
...     print(point)
...
[1. 1. 1.]
[2. 2. 2.]

shape property

shape: tuple[int, ...]

Return the shape of the waypoints matrix.

Returns:

  • tuple[int, ...]

    Shape of the matrix (N, 3).

to_trajectories

to_trajectories(waypoints: list[TrajectoryType], confidences: list[float]) -> list[Trajectory]

Convert a list of waypoints and confidences to a list of Trajectorys for each mode.

Parameters:

  • waypoints (list[TrajectoryType]) –

    List of waypoints for each mode.

  • confidences (list[float]) –

    List of confidences for each mode.

Returns:

  • list[Trajectory]

    List of Trajectorys for each mode.

TransformBuffer dataclass

TransformBuffer()

set_transform

set_transform(matrix: HomogeneousMatrix) -> None

Set transform matrix to the buffer. Also, if its inverse transformation has not been registered, registers it too.

Parameters:

HomogeneousMatrix dataclass

HomogeneousMatrix(position: ArrayLike, rotation: ArrayLike | RotationType, src: str, dst: str)

Construct a new object.

Parameters:

  • position (ArrayLike) –

    3D position.

  • rotation (ArrayLike | RotationType) –

    3x3 rotation matrix or quaternion.

  • src (str) –

    Source frame ID.

  • dst (str) –

    Destination frame ID.

shape property

shape: tuple[int, ...]

Return a shape of the homogeneous matrix.

Returns:

  • tuple[int, ...]

    Return the shape of (4, 4).

yaw_pitch_roll property

yaw_pitch_roll: tuple[float, float, float]

Return yaw, pitch and roll.

NOTE

yaw: Rotation angle around the z-axis in [rad], in the range [-pi, pi]. pitch: Rotation angle around the y'-axis in [rad], in the range [-pi/2, pi/2]. roll: Rotation angle around the x"-axis in [rad], in the range [-pi, pi].

Returns:

  • tuple[float, float, float]

    Yaw, pitch and roll in [rad].

rotation_matrix property

rotation_matrix: NDArray

Return a 3x3 rotation matrix.

Returns:

  • NDArray

    3x3 rotation matrix.

as_identity classmethod

as_identity(frame_id: str) -> Self

Construct a new object with identity.

Parameters:

  • frame_id (str) –

    Frame ID.

Returns:

  • Self

    Constructed self instance.

from_matrix classmethod

from_matrix(matrix: NDArray | HomogeneousMatrix, src: str | None = None, dst: str | None = None) -> Self

Construct a new object from a homogeneous matrix.

Parameters:

  • matrix (NDArray | HomogeneousMatrix) –

    4x4 homogeneous matrix.

  • src (str | None, default: None ) –

    Source frame ID. This must be specified only if the input matrix is NDArray.

  • dst (str | None, default: None ) –

    Destination frame ID. This must be specified only if the input matrix is NDArray.

Returns:

  • Self

    Constructed self instance.

dot

dot(other: HomogeneousMatrix) -> HomogeneousMatrix

Return a dot product of myself and another.

Parameters:

Raises:

  • ValueError

    self.src and other.dst must be the same frame ID.

Returns:

inv

inv() -> HomogeneousMatrix

Return a inverse matrix of myself.

Returns: