Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, first of all thank you for this wonderful library.
I recently implemented Python bindings for my own use and saw in issue #248 that an interface with Python could be useful for the community.
The Python bindings / interface is done with pybind11 a mature and efficient open-source binding library that integrates well with ROS.
For the moment I have only bound public functions of the
grid_map_core::GridMap
class (and their immediate dependencies) but more could easily be added, let me know.Main changes
grid_map_python
that will contain all the bindings containing:py_module.cpp
andpy_core.cpp
that generate the bindings librarysetup.py
andsrc/grid_map/__init__.py
that expose the moduletests
folder containing scripts to test bound functions from Pythonfrom_msg
andto_msg
functions to bridge the bound object with native Pythongrid_map_msgs/GridMap
structures.Exemple of usage
Using a
GridMap
object in a Python scripts is simply a matter of importing it from thegrid_map
module and calling its functions as with any Python object:Eigen matrices are exposed as numpy arrays (or compatibles) and vice-versa, making the use of
GridMap
frunctions straight-forward.I have been using this for the past month and saw no performance issues or big limitations. The bindings are still incomplete but I think that partial coverage is better than no coverage. If people find it important to add other modules or class to the bindings, they can easily be added afterwards.