dataclass
Box3D
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) –SemanticLabelobject. -
confidence(float) –Confidence score of the box.
-
uuid(str | None) –Unique box identifier.
-
position(Vector3) –Box center position (x, y, z).
-
rotation(Quaternion) –Box rotation quaternion.
-
shape(Shape) –Shapeobject. -
velocity(Vector3 | None) –Box velocity (vx, vy, vz).
-
num_points(int | None) –The number of points inside the box.
-
visibility(VisibilityLevel) –Box visibility.
-
future(Future | None) –Box trajectory in the future of each mode.
Examples:
>>> # without future
>>> box3d = Box3D(
... unix_time=100,
... frame_id="base_link",
... semantic_label=SemanticLabel("car"),
... position=(1.0, 1.0, 1.0),
... rotation=(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],
... )
size
property
Return the box size in the order of (width, length, height).
Returns:
-
Vector3–(width, length, height) values.
with_future
Return a self instance setting future attribute.
Parameters:
-
(timestampsArrayLike) –Array of future timestamps at each waypoint in the shape of (T).
-
(confidencesArrayLike) –Array of confidences for each mode in the shape of (M).
-
(waypointsArrayLike) –Array of waypoints for each mode in the shape of (M, T, D).
Returns:
-
Self–Self instance after setting
future.
translate
rotate
corners
Return the bounding box corners.
Parameters:
-
(box_scalefloat, 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
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) –SemanticLabelobject. -
confidence(float) –Confidence score of the box.
-
uuid(str | None) –Unique box identifier.
-
roi(Roi | None) –Roiobject. -
position(Vector3 | None) –3D position (x, y, z).
Examples:
>>> # without 3D position
>>> box2d = Box2D(
... unix_time=100,
... frame_id="camera",
... semantic_label=SemanticLabel("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
Return a self instance setting position attribute.
Parameters:
-
(positionVector3Like) –3D position.
Returns:
-
Self–Self instance after setting
position.
distance_box
Return a box distance from base_link.
Parameters:
-
(boxBoxLike) –A box.
-
(tf_matrixHomogeneousMatrix) –Transformation matrix.
Raises:
-
TypeError–Expecting type of box is
Box2DorBox3D.
Returns:
-
float | None–float | None: Return
Noneif the type of box isBox2Dand itspositionisNone, otherwise returns distance frombase_link.
PointCloud
Abstract base dataclass for pointcloud data.
num_dims
abstractmethod
staticmethod
Return the number of the point dimensions.
Returns:
-
int(int) –The number of the point dimensions.
from_file
abstractmethod
classmethod
Create an object from pointcloud file.
Parameters:
-
(filepathstr) –File path of the pointcloud file.
Returns:
-
Self–Self instance.
LidarPointCloud
A dataclass to represent lidar pointcloud.
Attributes:
-
points(NDArrayFloat) –Points matrix in the shape of (4, N).
RadarPointCloud
A dataclass to represent radar pointcloud.
Attributes:
-
points(NDArrayFloat) –Points matrix in the shape of (18, N).
SegmentationPointCloud
A dataclass to represent segmentation pointcloud.
Attributes:
-
points(NDArrayFloat) –Points matrix in the shape of (4, N).
-
labels(NDArrayU8) –Label matrix.
ObjectPath
A dataclass to represent object path including timestamps, confidences, and waypoints.
num_mode
property
num_timestamp
property
shape
property
translate
rotate
Past
Bases: ObjectPath
Represent the past trajectory features.
Note that the expected shape of waypoints is (1, T, D).
Attributes:
-
timestamps(NDArrayInt) –Sequence of timestamps (T,).
-
confidences(NDArrayFloat) –Confidences array for the mode (1,).
-
waypoints(Trajectory) –Waypoints matrix in the shape of (1, T, 3).
Examples:
>>> past = Past(
... timestamps=[1.0, 2.0]
... confidences=[1.0],
... waypoints=[[[1.0, 1.0, 1.0], [2.0, 2.0, 2.0]]],
... )
# Get the number of modes.
>>> len(past)
1
# Access the shape of waypoints matrix: (M, T, 3).
>>> past.shape
(1, 2, 3)
# Access waypoints as subscriptable.
>>> past[0] # for mode0
array([[1., 1., 1.],
[2., 2., 2.]])
>>> past[0, 0] # point0 at mode0
array([1., 1., 1.])
# Access confidence and waypoints for each mode as iterable.
>>> for i, (timestamp, confidence, waypoints) in past:
... print(f"Mode{i}: {timestamp}, {confidence}, {waypoints}")
...
Mode0: 1.0, 1.0, [[1. 1. 1.] [2. 2. 2.]]
Future
Bases: ObjectPath
Represent the future trajectory features.
Note that the expected shape of waypoints is (M, T, D).
Attributes:
-
timestamps(NDArrayInt) –Sequence of timestamps (T,).
-
confidences(NDArrayFloat) –Confidences array for each mode (M,).
-
waypoints(Trajectory) –Waypoints matrix in the shape of (M, T, 3).
Examples:
>>> future = Future(
... timestamps=[1.0, 2.0]
... confidences=[1.0],
... waypoints=[[[1.0, 1.0, 1.0], [2.0, 2.0, 2.0]]],
... )
# Get the number of modes.
>>> len(future)
1
# Access the shape of waypoints matrix: (M, T, 3).
>>> future.shape
(1, 2, 3)
# Access waypoints as subscriptable.
>>> future[0] # for mode0
array([[1., 1., 1.],
[2., 2., 2.]])
>>> future[0, 0] # point0 at mode0
array([1., 1., 1.])
# Access confidence and waypoints for each mode as iterable.
>>> for i, (timestamp, confidence, waypoints) in future:
... print(f"Mode{i}: {timestamp}, {confidence}, {waypoints}")
...
Mode0: 1.0, 1.0, [[1. 1. 1.] [2. 2. 2.]]
TransformBuffer
A buffer class to store transformation matrices.
Attributes:
-
buffer(dict[tuple[str, str], HomogeneousMatrix]) –Matrix buffer whose key is
(src, dst).
set_transform
Set transform matrix to the buffer. Also, if its inverse transformation has not been registered, registers it too.
Parameters:
-
(matrixHomogeneousMatrix) –Transformation matrix.
lookup_transform
Look up the transform matrix corresponding to the src and dst frame ID.
Parameters:
Returns:
-
HomogeneousMatrix | None–Returns
HomogeneousMatrixif the corresponding matrix can be found, otherwise it returnsNone.
do_translate
Translate specified items with the matrix corresponding to src and dst frame ID.
Parameters:
Returns:
-
TranslateItemLike | None–TranslateItemLike | None: Returns translated items if the corresponding matrix can be found, otherwise it returns
None.
do_rotate
Rotate specified items with the matrix corresponding to src and dst frame ID.
Parameters:
Returns:
-
RotateItemLike | None–TranslateItemLike | None: Returns rotated items if the corresponding matrix can be found, otherwise it returns
None.
do_transform
Transform specified items with the matrix corresponding to src and dst frame ID.
Parameters:
Returns:
-
TransformItemLike | None–TranslateItemLike | None: Returns transformed items if the corresponding matrix can be found, otherwise it returns
None.
HomogeneousMatrix
shape
property
yaw_pitch_roll
property
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:
rotation_matrix
property
as_identity
classmethod
Construct a new object with identity.
Parameters:
-
(frame_idstr) –Frame ID.
Returns:
-
Self–Constructed self instance.
from_matrix
classmethod
from_matrix(
matrix: Matrix4x4Like | HomogeneousMatrix,
src: str | None = None,
dst: str | None = None,
) -> Self
Construct a new object from a homogeneous matrix.
Parameters:
-
(matrixMatrix4x4Like | HomogeneousMatrix) –4x4 homogeneous matrix.
-
(srcstr | None, default:None) –Source frame ID. This must be specified only if the input matrix is
Matrix4x4Like. -
(dststr | None, default:None) –Destination frame ID. This must be specified only if the input matrix is
Matrix4x4Like.
Returns:
-
Self–Constructed self instance.
dot
Return a dot product of myself and another.
Parameters:
-
(otherHomogeneousMatrix) –HomogeneousMatrixobject.
Raises:
-
ValueError–self.srcandother.dstmust be the same frame ID.
Returns:
-
HomogeneousMatrix–Result of a dot product.