-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathtest_binding.py
66 lines (48 loc) · 1.91 KB
/
test_binding.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import unittest
import numpy as np
try:
import pyct_icp as pct
_with_pct = True
except ImportError as e:
print(e.msg)
_with_pct = False
class TestBinding(unittest.TestCase):
def test_installation(self):
self.assertEqual(True, _with_pct) # add assertion here
def test_frame(self):
self.test_installation()
frame = pct.LiDARFrame()
n = 100
np_array = np.random.randn(n, 3)
np_raw_points = np.random.randn(n, 3)
timestamps = np.random.rand(n)
alpha_timestamps = np.random.rand(n)
index_frames = np.random.randint(0, 10, n)
struct_array = np.rec.fromarrays([np_raw_points, np_array, timestamps, alpha_timestamps, index_frames],
dtype=[
("raw_point", 'f8', 3),
("pt", 'f8', 3),
("alpha_timestamp", 'f8', 1),
("timestamp", 'f8', 1),
("index_frame", 'i4', 1)])
frame.SetFrame(struct_array)
array = frame.GetStructuredArrayRef()
diff2 = np.abs(array["pt"] - np_array).max()
diff0 = np.abs(array["raw_point"] - np_raw_points).max()
self.assertEqual(diff2, 0.0)
self.assertEqual(diff0, 0.0)
array[:10]["pt"] = 0.0
array_bis = frame.GetStructuredArrayRef()
xs = array["pt"]
xs_bis = array_bis["pt"]
diff = np.abs(xs - xs_bis).max()
self.assertEqual(diff, 0.0)
# Check that GetWrappingArray returns a reference
# And SetFrame makes a copy
def test_odometry(self):
self.test_installation()
options = pct.OdometryOptions()
options.motion_compensation = pct.NONE
pct.Odometry(options)
if __name__ == '__main__':
unittest.main()