Skip to content

Commit

Permalink
add a test case for grid map lib
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiSakai committed Aug 3, 2019
1 parent 097a289 commit 9858491
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/test_grid_based_sweep_coverage_path_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../Mapping/grid_map_lib")
try:
import grid_based_sweep_coverage_path_planner
except:
except ImportError:
raise

class TestPlanning(TestCase):
Expand Down
38 changes: 38 additions & 0 deletions tests/test_grid_map_lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import sys
import unittest

sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../Mapping/grid_map_lib")
try:
from grid_map_lib import GridMap
except ImportError:
raise


class MyTestCase(unittest.TestCase):

def test_position_set(self):
grid_map = GridMap(100, 120, 0.5, 10.0, -0.5)

grid_map.set_value_from_xy_pos(10.1, -1.1, 1.0)
grid_map.set_value_from_xy_pos(10.1, -0.1, 1.0)
grid_map.set_value_from_xy_pos(10.1, 1.1, 1.0)
grid_map.set_value_from_xy_pos(11.1, 0.1, 1.0)
grid_map.set_value_from_xy_pos(10.1, 0.1, 1.0)
grid_map.set_value_from_xy_pos(9.1, 0.1, 1.0)

self.assertEqual(True, True)

def test_polygon_set(self):
ox = [0.0, 20.0, 50.0, 100.0, 130.0, 40.0]
oy = [0.0, -20.0, 0.0, 30.0, 60.0, 80.0]

grid_map = GridMap(600, 290, 0.7, 60.0, 30.5)

grid_map.set_value_from_polygon(ox, oy, 1.0, inside=False)

self.assertEqual(True, True)


if __name__ == '__main__':
unittest.main()

0 comments on commit 9858491

Please sign in to comment.