Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(utils/misc): add guard for image_timestamp_list array #78

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions perception_dataset/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def get_lidar_camera_synced_frame_info(
for lidar_index, lidar_timestamp in enumerate(lidar_timestamp_list):
if lidar_index >= num_load_frames:
break
if current_image_index >= len(image_timestamp_list):
break
image_timestamp = image_timestamp_list[current_image_index]

while image_timestamp - lidar_timestamp < lidar_to_camera_latency_sec - (
Expand Down
19 changes: 19 additions & 0 deletions tests/utils/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,22 @@ def test_get_lidar_camera_synced_frame_info_num_load_frames():
num_load_frames=num_load_frames,
)
assert_synced_frame_info_list(expected, synced_frame_info_list)


def test_get_lidar_camera_synced_frame_info_too_large_num_load_frames():
# Test case where len(lidar_timestamp_list) >= num_load_frames > len(image_timestamp_list)
image_timestamp_list = [0.552, 0.652]
lidar_timestamp_list = [0.4, 0.499, 0.6]

expected = [[0, 0, None], [1, 1, None]]
num_load_frames = 3

synced_frame_info_list = misc_utils.get_lidar_camera_synced_frame_info(
image_timestamp_list=image_timestamp_list,
lidar_timestamp_list=lidar_timestamp_list,
lidar_to_camera_latency_sec=0.162,
system_scan_period_sec=0.1,
max_camera_jitter_sec=0.03,
num_load_frames=num_load_frames,
)
assert_synced_frame_info_list(expected, synced_frame_info_list)
Loading