coverage
Toggle main menu visibility
読み取り中…
検索中…
一致する文字列を見つけられません
test_zone_map.py
[詳解]
1
"""ゾーン内セルの地図占有率計算を検証する(ROS不要)。"""
2
3
from
coverage.zone_map
import
ZoneOccupancy, point_in_polygon, zone_occupancy
4
5
6
def
_grid
(width, height, fill=0):
7
return
[fill] * (width * height)
8
9
10
def
test_point_in_polygon_square
():
11
sq = [(0.0, 0.0), (2.0, 0.0), (2.0, 2.0), (0.0, 2.0)]
12
assert
point_in_polygon(1.0, 1.0, sq)
13
assert
not
point_in_polygon(3.0, 1.0, sq)
14
assert
not
point_in_polygon(1.0, -1.0, sq)
15
16
17
def
test_free_zone_has_zero_occupancy
():
18
occ = zone_occupancy(10, 10, 1.0, 0.0, 0.0,
_grid
(10, 10),
19
[(1.0, 1.0), (4.0, 1.0), (4.0, 4.0), (1.0, 4.0)])
20
assert
occ.inside_cells == 9
21
assert
occ.occupied_ratio == 0.0
22
assert
occ.unknown_ratio == 0.0
23
24
25
def
test_wall_inside_zone_counts_occupied
():
26
data =
_grid
(10, 10)
27
for
cy
in
range(10):
28
data[cy * 10 + 2] = 100
29
occ = zone_occupancy(10, 10, 1.0, 0.0, 0.0, data,
30
[(1.0, 1.0), (4.0, 1.0), (4.0, 4.0), (1.0, 4.0)])
31
assert
occ.inside_cells == 9
32
assert
occ.occupied_ratio == 3 / 9
33
34
35
def
test_unknown_cells_are_reported_not_occupied
():
36
data =
_grid
(10, 10, fill=-1)
37
occ = zone_occupancy(10, 10, 1.0, 0.0, 0.0, data,
38
[(1.0, 1.0), (4.0, 1.0), (4.0, 4.0), (1.0, 4.0)])
39
assert
occ.inside_cells == 9
40
assert
occ.occupied_ratio == 0.0
41
assert
occ.unknown_ratio == 1.0
42
43
44
def
test_zone_outside_map_returns_empty
():
45
occ = zone_occupancy(10, 10, 1.0, 0.0, 0.0,
_grid
(10, 10),
46
[(20.0, 20.0), (22.0, 20.0), (22.0, 22.0)])
47
assert
occ ==
ZoneOccupancy
(0, 0.0, 0.0)
48
49
50
def
test_closed_ring_polygon_accepted
():
51
occ = zone_occupancy(10, 10, 1.0, 0.0, 0.0,
_grid
(10, 10),
52
[(1.0, 1.0), (4.0, 1.0), (4.0, 4.0),
53
(1.0, 4.0), (1.0, 1.0)])
54
assert
occ.inside_cells == 9
coverage.zone_map.ZoneOccupancy
ゾーン内セルの内訳。
定義
zone_map.py:20
coverage.zone_map
清掃ゾーン内セルの地図占有率をROS非依存で求める。
定義
zone_map.py:1
test_zone_map.test_wall_inside_zone_counts_occupied
test_wall_inside_zone_counts_occupied()
定義
test_zone_map.py:25
test_zone_map.test_zone_outside_map_returns_empty
test_zone_outside_map_returns_empty()
定義
test_zone_map.py:44
test_zone_map.test_unknown_cells_are_reported_not_occupied
test_unknown_cells_are_reported_not_occupied()
定義
test_zone_map.py:35
test_zone_map._grid
_grid(width, height, fill=0)
定義
test_zone_map.py:6
test_zone_map.test_point_in_polygon_square
test_point_in_polygon_square()
定義
test_zone_map.py:10
test_zone_map.test_free_zone_has_zero_occupancy
test_free_zone_has_zero_occupancy()
定義
test_zone_map.py:17
test_zone_map.test_closed_ring_polygon_accepted
test_closed_ring_polygon_accepted()
定義
test_zone_map.py:50
test
test_zone_map.py
構築:
1.18.0