diff --git a/python/breezyslam/algorithms.py b/python/breezyslam/algorithms.py index bb77f22..f48288d 100644 --- a/python/breezyslam/algorithms.py +++ b/python/breezyslam/algorithms.py @@ -122,7 +122,7 @@ class CoreSLAM(object): Sets current map pixels to values in bytearray, where bytearray length is square of map size passed to CoreSLAM.__init__(). ''' - self.map.__init__(mapbytes) + self.map.set(mapbytes) def __str__(self): diff --git a/python/pybreezyslam.c b/python/pybreezyslam.c index ca66f9f..680c14a 100644 --- a/python/pybreezyslam.c +++ b/python/pybreezyslam.c @@ -537,6 +537,26 @@ Map_get(Map * self, PyObject * args, PyObject * kwds) Py_RETURN_NONE; } +static PyObject * +Map_set(Map * self, PyObject * args, PyObject * kwds) +{ + PyObject * py_mapbytes = NULL; + + if (!PyArg_ParseTuple(args, "O", &py_mapbytes)) + { + return null_on_raise_argument_exception("Map", "get"); + } + + if (bad_mapbytes(py_mapbytes, self->map.size_pixels, "get")) + { + Py_RETURN_NONE; + } + + map_set(&self->map, PyByteArray_AsString(py_mapbytes)); + + Py_RETURN_NONE; +} + static PyObject * Map_update(Map *self, PyObject *args, PyObject *kwds) { @@ -584,6 +604,9 @@ static PyMethodDef Map_methods[] = {"get", (PyCFunction)Map_get, METH_VARARGS, "Map.get(bytearray) fills byte array with map pixels, where bytearray length is square of size of map." }, + {"set", (PyCFunction)Map_set, METH_VARARGS, + "Map.set(bytearray) fills current map with pixels in bytearray, where bytearray length is square of size of map." + }, {NULL} // Sentinel };