Skip to content

Commit 9858491

Browse files
committed
add a test case for grid map lib
1 parent 097a289 commit 9858491

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

tests/test_grid_based_sweep_coverage_path_planner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../Mapping/grid_map_lib")
77
try:
88
import grid_based_sweep_coverage_path_planner
9-
except:
9+
except ImportError:
1010
raise
1111

1212
class TestPlanning(TestCase):

tests/test_grid_map_lib.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
import sys
3+
import unittest
4+
5+
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../Mapping/grid_map_lib")
6+
try:
7+
from grid_map_lib import GridMap
8+
except ImportError:
9+
raise
10+
11+
12+
class MyTestCase(unittest.TestCase):
13+
14+
def test_position_set(self):
15+
grid_map = GridMap(100, 120, 0.5, 10.0, -0.5)
16+
17+
grid_map.set_value_from_xy_pos(10.1, -1.1, 1.0)
18+
grid_map.set_value_from_xy_pos(10.1, -0.1, 1.0)
19+
grid_map.set_value_from_xy_pos(10.1, 1.1, 1.0)
20+
grid_map.set_value_from_xy_pos(11.1, 0.1, 1.0)
21+
grid_map.set_value_from_xy_pos(10.1, 0.1, 1.0)
22+
grid_map.set_value_from_xy_pos(9.1, 0.1, 1.0)
23+
24+
self.assertEqual(True, True)
25+
26+
def test_polygon_set(self):
27+
ox = [0.0, 20.0, 50.0, 100.0, 130.0, 40.0]
28+
oy = [0.0, -20.0, 0.0, 30.0, 60.0, 80.0]
29+
30+
grid_map = GridMap(600, 290, 0.7, 60.0, 30.5)
31+
32+
grid_map.set_value_from_polygon(ox, oy, 1.0, inside=False)
33+
34+
self.assertEqual(True, True)
35+
36+
37+
if __name__ == '__main__':
38+
unittest.main()

0 commit comments

Comments
 (0)