forked from robotika/eduro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcube_test.py
More file actions
68 lines (61 loc) · 4.05 KB
/
cube_test.py
File metadata and controls
68 lines (61 loc) · 4.05 KB
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
67
68
#!/usr/bin/python
import unittest
from cube import detect_cubes
class CubeTest(unittest.TestCase):
def test_detection( self ):
# two cubes, 2016-09-13-apu2\czuB\src_laser_160913_191514.log
data = [6766, 6771, 6779, 6780, 6782, 6788, 6799, 6794, 6790, 6804, 6809, 6815, 6823,
6837, 6852, 6855, 6853, 6856, 6851, 6849, 6846, 6833, 6835, 6838, 6831,
6835, 6847, 6834, 6830, 6824, 6824, 8647, 7306, 7285, 6871, 6832, 6838,
0, 7301, 7314, 7310, 7311, 7311, 7311, 7314, 7296, 7298, 7310, 7312,
7313, 7299, 7321, 7302, 7322, 7312, 7313, 7334, 7322, 7319, 7329, 7347,
7333, 7335, 7344, 7353, 7354, 7360, 7363, 7367, 7378, 7392, 7393, 7399,
7407, 7419, 7426, 7434, 7448, 7452, 7468, 7481, 7488, 7505, 7515, 7529,
7551, 7562, 7578, 7589, 7617, 7635, 7657, 7683, 7691, 7716, 7749, 7773,
7798, 7835, 7872, 7912, 7941, 7987, 8031, 8071, 8124, 8188, 8247, 8303,
8370, 8446, 8529, 8621, 8718, 8832, 8946, 9086, 9237, 9354, 9350, 9338,
9345, 9405, 9397, 9390, 9381, 9374, 9376, 9363, 9356, 9360, 9361, 9350,
9353, 9354, 9359, 9349, 9358, 9369, 9374, 9373, 9291, 9313, 9326, 9323,
9344, 9350, 9358, 7801, 7799, 7767, 7729, 7740, 7741, 7756, 7768, 7788,
7810, 9561, 9584, 9613, 9641, 9660, 9689, 9721, 9752, 9791, 7143, 7161,
7144, 7121, 7105, 7109, 7095, 7083, 7078, 7071, 7068, 7080, 7088, 7092,
7105, 7098, 7114, 7132, 7147, 7150, 7108, 0, 9117, 0, 9785, 9756, 9717,
9685, 8171, 8497, 8516, 8507, 8487, 8401, 8388, 8441, 8438, 8455, 8433,
8506, 8522, 8542, 8376, 0, 9384, 9377, 9367, 9358, 9350, 0, 9343, 9341,
9331, 9309, 9332, 9331, 9341, 7989, 9333, 9334, 9338, 9331, 0, 9348,
9354, 9360, 9268, 9332, 0, 9404, 9405, 9415, 9217, 9039, 9059, 9105,
9115, 8617, 8534, 8533, 8556, 8605, 8608, 8611, 8632, 0, 9367, 9362, 0,
0, 8803, 8795, 8841, 8902, 8889, 0, 9770, 9703, 9668, 9742, 9755, 9811,
9867, 9932]
self.assertEqual(len(data), 271)
cubes = detect_cubes(data)
self.assertEqual(cubes, [])
# 2016-09-13-apu2\czuB\src_laser_160913_191555.log
data = [165, 167, 175, 173, 177, 179, 180, 183, 188, 198, 208, 203, 208, 217, 221,
230, 241, 264, 269, 270, 260, 263, 264, 265, 253, 244, 242, 245, 246,
241, 242, 237, 234, 236, 235, 228, 230, 237, 230, 236, 231, 418, 2405,
2372, 2340, 2301, 2263, 2235, 2210, 2181, 2159, 2131, 2106, 2077, 2057,
2036, 2012, 1986, 1974, 1949, 1933, 1917, 1909, 1886, 1877, 1857, 1847,
1830, 1822, 1815, 1802, 1788, 1784, 1772, 1769, 1755, 1757, 1750, 1745,
1740, 1732, 1726, 1723, 1759, 543, 543, 543, 542, 541, 543, 544, 565, # cube on the left
539, 541, 546, 546, 545, 545, 548, 531, 1766, 1771, 1781, 1782, 1798,
1797, 1819, 1828, 1835, 1844, 1863, 1875, 1893, 1910, 1926, 1940, 1955,
1977, 1990, 2011, 2032, 2059, 2080, 2107, 2134, 2164, 2190, 2223, 2252,
2291, 2324, 2363, 2403, 2442, 2487, 2532, 2580, 2633, 2692, 1039, 1009, # cube in front
1004, 986, 971, 969, 967, 998, 1017, 1043, 2752, 2704, 2681, 2659,
2636, 2613, 2594, 2576, 2563, 2546, 2529, 2512, 2500, 2478, 2381, 2372,
2374, 2362, 2357, 2345, 2338, 2329, 2325, 2326, 2318, 2319, 2312, 2312,
2311, 2319, 2308, 2310, 2308, 2317, 2321, 2324, 2328, 2337, 2340, 2351,
2352, 2356, 2360, 2370, 2383, 2397, 2408, 0, 0, 2452, 2475, 2648, 1066,
2523, 2548, 1129, 1156, 1127, 1106, 1090, 1086, 1090, 1095, 1146, 1221,
1194, 1178, 1169, 1049, 1084, 1144, 1144, 4347, 2302, 2350, 2364, 576,
538, 535, 2214, 2184, 2283, 829, 810, 859, 842, 838, 827, 833, 820,
750, 727, 716, 707, 712, 734, 769, 757, 759, 752, 761, 768, 782, 793,
747, 751, 815, 823, 842, 856, 875, 916, 947, 1040, 0, 647, 0, 1687,
1687, 1691, 1689, 1691]
cubes = detect_cubes(data)
self.assertEqual(cubes, [(91, 565),]) # cube angle center
if __name__ == "__main__":
unittest.main()
#-------------------------------------------------------------------
# vim: expandtab sw=4 ts=4