Fixed slam.setmap()

This commit is contained in:
simondlevy
2018-07-26 02:07:43 -04:00
parent b13b27f817
commit abb0733d8d
2 changed files with 24 additions and 1 deletions

View File

@@ -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):

View File

@@ -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
};