3 from .registry
import converts_from_numpy, converts_to_numpy
4 from nav_msgs.msg
import OccupancyGrid, MapMetaData
7 from numpy.lib.stride_tricks
import as_strided
11 data = np.asarray(msg.data, dtype=np.int8).reshape(msg.info.height, msg.info.width)
13 return np.ma.array(data, mask=data==-1, fill_value=-1)
18 if not len(arr.shape) == 2:
19 raise TypeError(
'Array must be 2D')
20 if not arr.dtype == np.int8:
21 raise TypeError(
'Array must be of int8s')
23 grid = OccupancyGrid()
24 if isinstance(arr, np.ma.MaskedArray):
27 grid.data = arr.ravel()
28 grid.info = info
or MapMetaData()
29 grid.info.height = arr.shape[0]
30 grid.info.width = arr.shape[1]
def converts_from_numpy(msgtype, plural=False)
def converts_to_numpy(msgtype, plural=False)
def numpy_to_occupancy_grid(arr, info=None)
def occupancygrid_to_numpy(msg)