Skip to content

Commit f40b750

Browse files
authored
fix bugs in check a position inside the polygon (AtsushiSakai#701)
* fix bugs in check a position inside the polygon It is possible that the position `(iox, ioy)` to be checked with `iox == min_x`. This will cause a incorrect inside check. * add a boundary condition for gridmap
1 parent 7716bdd commit f40b750

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Mapping/grid_map_lib/grid_map_lib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def check_inside_polygon(iox, ioy, x, y):
194194
min_x, max_x = x[i2], x[i1]
195195
else:
196196
min_x, max_x = x[i1], x[i2]
197-
if not min_x < iox < max_x:
197+
if not min_x <= iox < max_x:
198198
continue
199199

200200
tmp1 = (y[i2] - y[i1]) / (x[i2] - x[i1])
@@ -226,8 +226,8 @@ def plot_grid_map(self, ax=None):
226226

227227

228228
def test_polygon_set():
229-
ox = [0.0, 20.0, 50.0, 100.0, 130.0, 40.0]
230-
oy = [0.0, -20.0, 0.0, 30.0, 60.0, 80.0]
229+
ox = [0.0, 4.35, 20.0, 50.0, 100.0, 130.0, 40.0]
230+
oy = [0.0, -4.15, -20.0, 0.0, 30.0, 60.0, 80.0]
231231

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

tests/test_grid_map_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def test_position_set():
1414

1515

1616
def test_polygon_set():
17-
ox = [0.0, 20.0, 50.0, 100.0, 130.0, 40.0]
18-
oy = [0.0, -20.0, 0.0, 30.0, 60.0, 80.0]
17+
ox = [0.0, 4.35, 20.0, 50.0, 100.0, 130.0, 40.0]
18+
oy = [0.0, -4.15, -20.0, 0.0, 30.0, 60.0, 80.0]
1919

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

0 commit comments

Comments
 (0)