Skip to content

Commit a3fd04f

Browse files
fix error: 'numpy.ndarray' object has no attribute 'append' (AtsushiSakai#662)
* Update grid_map_lib.py fix error: 'numpy.ndarray' object has no attribute 'append' * Update test_grid_map_lib.py * Update test_grid_map_lib.py Co-authored-by: Atsushi Sakai <[email protected]>
1 parent e18799c commit a3fd04f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Mapping/grid_map_lib/grid_map_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def set_value_from_polygon(self, pol_x, pol_y, val, inside=True):
120120

121121
# making ring polygon
122122
if (pol_x[0] != pol_x[-1]) or (pol_y[0] != pol_y[-1]):
123-
pol_x.append(pol_x[0])
124-
pol_y.append(pol_y[0])
123+
np.append(pol_x, pol_x[0])
124+
np.append(pol_y, pol_y[0])
125125

126126
# setting value for all grid
127127
for x_ind in range(self.width):

tests/test_grid_map_lib.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from Mapping.grid_map_lib.grid_map_lib import GridMap
2+
import numpy as np
23

34

45
def test_position_set():
@@ -19,6 +20,8 @@ def test_polygon_set():
1920
grid_map = GridMap(600, 290, 0.7, 60.0, 30.5)
2021

2122
grid_map.set_value_from_polygon(ox, oy, 1.0, inside=False)
23+
grid_map.set_value_from_polygon(np.array(ox), np.array(oy),
24+
1.0, inside=False)
2225

2326

2427
if __name__ == '__main__':

0 commit comments

Comments
 (0)