Skip to content

Commit

Permalink
test: update unit testings for viewer
Browse files Browse the repository at this point in the history
Signed-off-by: ktro2828 <[email protected]>
  • Loading branch information
ktro2828 committed Dec 3, 2024
1 parent 5d6d781 commit fb59f5c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion tests/viewer/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def dummy_viewer(label2id) -> RerunViewer:
return RerunViewer(
"test_viewer",
cameras=["camera"],
spawn=False,
spawn=False, # set this to True for debugging
).with_labels(label2id=label2id)
55 changes: 19 additions & 36 deletions tests/viewer/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ def test_format_entity() -> None:


def test_render_box3ds(dummy_viewer, dummy_box3ds) -> None:
"""Test rendering 3D boxes with `RerunViewer`.
Args:
dummy_viewer (RerunViewer): Viewer object.
dummy_box3ds (list[Box3D]): List of 3D boxes.
"""
"""Test rendering 3D boxes with `RerunViewer`."""
seconds = 1.0 # [sec]

dummy_viewer.render_box3ds(seconds, dummy_box3ds)
Expand All @@ -46,12 +41,7 @@ def test_render_box3ds(dummy_viewer, dummy_box3ds) -> None:


def test_render_box2ds(dummy_viewer, dummy_box2ds) -> None:
"""Test rendering 2D boxes with `RerunViewer`.
Args:
dummy_viewer (RerunViewer): Viewer object.
dummy_box2ds (list[Box2D): List of 2D boxes.
"""
"""Test rendering 2D boxes with `RerunViewer`."""
seconds = 1.0 # [sec]

dummy_viewer.render_box2ds(seconds, dummy_box2ds)
Expand All @@ -65,28 +55,29 @@ def test_render_box2ds(dummy_viewer, dummy_box2ds) -> None:


def test_render_pointcloud(dummy_viewer) -> None:
"""Test rendering pointcloud with `RerunViewer`.
Args:
dummy_viewer (RerunViewer): Viewer object.
"""
"""Test rendering pointcloud with `RerunViewer`."""
seconds = 1.0 # [sec]

dummy_pointcloud = LidarPointCloud(np.random.rand(4, 100))
dummy_viewer.render_pointcloud(seconds, "lidar", dummy_pointcloud)


def test_render_ego(dummy_viewer) -> None:
"""Test rendering ego pose with `RerunViewer`.
def test_render_image(dummy_viewer, dummy_camera_calibration) -> None:
"""Test rendering image with `RerunViewer`."""
seconds = 1.0 # [sec]

Args:
dummy_viewer (RerunViewer): Viewer object.
"""
(width, height), _ = dummy_camera_calibration
dummy_image = np.zeros((height, width, 3), dtype=np.uint8)
dummy_viewer.render_image(seconds=seconds, camera="camera", image=dummy_image)


def test_render_ego(dummy_viewer) -> None:
"""Test rendering ego pose with `RerunViewer`."""
seconds = 1.0 # [sec]

# without `EgoPose`
translation = [1, 0, 0]
rotation = Quaternion([0, 0, 0, 1])
rotation = Quaternion([1, 0, 0, 0])
dummy_viewer.render_ego(seconds, translation=translation, rotation=rotation)

# with `EgoPose`
Expand All @@ -99,22 +90,14 @@ def test_render_ego(dummy_viewer) -> None:
dummy_viewer.render_ego(ego_pose)


def test_render_calibration(dummy_viewer) -> None:
"""Test rendering sensor calibration with `RerunViewer`.
Args:
dummy_viewer (RerunViewer): Viewer object.
"""
def test_render_calibration(dummy_viewer, dummy_camera_calibration) -> None:
"""Test rendering sensor calibration with `RerunViewer`."""
# without `Sensor` and `CalibratedSensor`
channel = "camera"
modality = "camera"
translation = [1, 0, 0]
rotation = Quaternion([0, 0, 0, 1])
camera_intrinsic = [
[1000.0, 0.0, 100.0],
[0.0, 1000.0, 100.0],
[0.0, 0.0, 1.0],
]
translation = [1, 1, 1]
rotation = Quaternion([1, 0, 0, 0])
_, camera_intrinsic = dummy_camera_calibration
dummy_viewer.render_calibration(
channel=channel,
modality=modality,
Expand Down

0 comments on commit fb59f5c

Please sign in to comment.