-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
148 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (c) 2021-2023, Martin Valgur | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import math | ||
|
||
import pytest | ||
import velodyne_decoder as vd | ||
import yaml | ||
|
||
MODELS = list(vd.Model.__members__) | ||
|
||
|
||
def test_config_constructor(calib_data_dir): | ||
vd.Config() | ||
vd.Config(model=vd.Model.VLP16) | ||
calibration = vd.Calibration.read(str(calib_data_dir / "VLP-16.yml")) | ||
vd.Config(model=vd.Model.VLP16, calibration=calibration) | ||
|
||
|
||
@pytest.mark.parametrize("model_id", MODELS) | ||
def test_bundled_calibrations(model_id): | ||
model_id = vd.Model.__members__[model_id] | ||
calib = None | ||
if model_id.name.startswith("HDL64E"): | ||
calib_file = { | ||
vd.Model.HDL64E_S1: "HDL-64E_S1-utexas.yml", | ||
vd.Model.HDL64E_S2: "HDL-64E_S2.1-sztaki.yml", | ||
vd.Model.HDL64E_S3: "HDL-64E_S3-VeloView.yml", | ||
}[model_id] | ||
calib = vd.get_bundled_calibration(calib_file) | ||
vd.ScanDecoder(vd.Config(model=model_id, calibration=calib)) | ||
|
||
|
||
@pytest.mark.parametrize("model_id", [m for m in MODELS if not m.startswith("HDL64E")]) | ||
def test_default_calib_vertical_offsets(model_id): | ||
"""Check that the pre-defined vertical offset calibration values are sensible.""" | ||
model_id = vd.Model.__members__[model_id] | ||
calib = vd.Calibration.default_calibs[model_id] | ||
lasers = yaml.safe_load(calib.to_string())["lasers"] | ||
focal_distance = { | ||
vd.Model.AlphaPrime: 58.63e-3, | ||
vd.Model.HDL32E: 28.83e-3, | ||
vd.Model.PuckHiRes: 41.91e-3, | ||
vd.Model.VLP16: 41.91e-3, | ||
vd.Model.VLP32A: 42.4e-3, | ||
vd.Model.VLP32B: 42.4e-3, | ||
vd.Model.VLP32C: 42.4e-3, | ||
}[model_id] | ||
for laser in lasers: | ||
approx_offset = focal_distance * math.tan(-laser["vert_correction"]) | ||
thr = 0.5e-3 if model_id == vd.Model.PuckHiRes else 0.1e-3 | ||
assert pytest.approx(approx_offset, abs=thr) == laser["vert_offset_correction"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2021-2023, Martin Valgur | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import numpy as np | ||
import velodyne_decoder as vd | ||
|
||
|
||
def test_pcap_as_contiguous_array(sample_pcap_path): | ||
pcds = list(vd.read_pcap(sample_pcap_path, as_pcl_structs=False)) | ||
assert len(pcds) == 94 | ||
stamp, pcd = pcds[0] | ||
assert stamp.host == 1427759049.259595 | ||
assert pcd.shape == (27657, 8) | ||
assert pcd.dtype.name == "float32" | ||
# Check that the column index is monotonically increasing | ||
column_idx = pcd[:, vd.PointField.column].astype(int) | ||
assert np.diff(column_idx).min() == 0 | ||
|
||
|
||
def test_pcap_as_struct_array(sample_pcap_path, pcl_struct_dtype): | ||
pcds = list(vd.read_pcap(sample_pcap_path, as_pcl_structs=True)) | ||
assert len(pcds) == 94 | ||
stamp, pcd = pcds[0] | ||
assert stamp.host == 1427759049.259595 | ||
assert pcd.shape == (27657,) | ||
assert pcd.dtype == pcl_struct_dtype | ||
# Check that the column index is monotonically increasing | ||
column_idx = pcd["column"].astype(int) | ||
assert np.diff(column_idx).min() == 0 | ||
|
||
|
||
def test_pcap_time_range(sample_pcap_path): | ||
t0 = 1427759050 | ||
pcds = list(vd.read_pcap(sample_pcap_path, as_pcl_structs=False, time_range=(t0, None))) | ||
stamp, pcd = pcds[0] | ||
assert stamp.host >= t0 | ||
assert stamp.device >= t0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2021-2023, Martin Valgur | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
import velodyne_decoder as vd | ||
|
||
|
||
def test_bag_as_contiguous_array(sample_bag_path): | ||
pcds = list(vd.read_bag(sample_bag_path, topics="/velodyne_packets", as_pcl_structs=False)) | ||
assert len(pcds) == 13 | ||
stamp, pcd, topic, frame_id = pcds[0] | ||
assert topic == "/velodyne_packets" | ||
assert stamp.host == 1636622716.742135 | ||
assert pcd.shape == (27300, 8) | ||
assert pcd.dtype.name == "float32" | ||
assert frame_id == "velodyne" | ||
|
||
|
||
def test_bag_as_struct_array(sample_bag_path, pcl_struct_dtype): | ||
pcds = list(vd.read_bag(sample_bag_path, topics="/velodyne_packets", as_pcl_structs=True)) | ||
assert len(pcds) == 13 | ||
stamp, pcd, topic, frame_id = pcds[0] | ||
assert topic == "/velodyne_packets" | ||
assert stamp.host == 1636622716.742135 | ||
assert pcd.shape == (27300,) | ||
assert pcd.dtype == pcl_struct_dtype | ||
assert frame_id == "velodyne" | ||
|
||
|
||
def test_bag_automatic_topic(sample_bag_path): | ||
pcds = list(vd.read_bag(sample_bag_path)) | ||
assert len(pcds) == 13 | ||
stamp, pcd, topic, frame_id = pcds[0] | ||
assert topic == "/velodyne_packets" | ||
assert stamp.host == 1636622716.742135 | ||
assert pcd.shape == (27300, 8) | ||
assert frame_id == "velodyne" | ||
|
||
|
||
def test_bag_time_range(sample_bag_path): | ||
t0 = 1636622717 | ||
pcds = list(vd.read_bag(sample_bag_path, time_range=(t0, None))) | ||
assert pcds[0].stamp.host >= t0 |
This file was deleted.
Oops, something went wrong.