Go to file
Ayush Baid c5eb449e08 Squashed 'wrap/' changes from b28b3570d..d37b8a972
d37b8a972 Merge pull request #31 from ayushbaid/feature/pickle
efd4a0fb4 removing tab
42fd231f3 adding newline for test compare
0aa316150 removing extra brackets
7fe1d7d0f adding pickle code to expected file
9c3ab7a8b fixing string format for new classname
2f89284e8 moving pickle support with the serialization code
5a8abc916 adding pickle support for select classes using serialization

git-subtree-dir: wrap
git-subtree-split: d37b8a972f6f3aa99a657831102fc22a73b59f21
2021-03-08 14:58:50 -05:00
.github/workflows Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
cmake Squashed 'wrap/' changes from 85d34351c..b28b3570d 2021-02-15 19:42:16 -05:00
docs Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
gtwrap Squashed 'wrap/' changes from b28b3570d..d37b8a972 2021-03-08 14:58:50 -05:00
pybind11 Squashed 'wrap/' changes from 49d831588..314b121fd 2020-09-16 18:03:25 -04:00
scripts Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -05:00
sphinx Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
tests Squashed 'wrap/' changes from b28b3570d..d37b8a972 2021-03-08 14:58:50 -05:00
utilities Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
.gitignore Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -05:00
CMakeLists.txt Squashed 'wrap/' changes from 85d34351c..b28b3570d 2021-02-15 19:42:16 -05:00
LICENSE Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -05:00
README.md Squashed 'wrap/' changes from 85d34351c..b28b3570d 2021-02-15 19:42:16 -05:00
matlab.h Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
pybind_wrapper.tpl.example Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
requirements.txt Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
setup.py Squashed 'wrap/' changes from 186ed2c79..85d34351c 2021-01-13 10:54:22 -05:00

README.md

WRAP

The wrap library wraps the GTSAM library into a Python library or MATLAB toolbox. It was designed to be more general than just wrapping GTSAM. For notes on creating a wrap interface, see gtsam.h for what features can be wrapped into a toolbox, as well as the current state of the toolbox for GTSAM.

Prerequisites: Pybind11 and pyparsing

  1. This library uses pybind11, which is included as a subdirectory in GTSAM.
  2. The interface_parser.py in this library uses pyparsing to parse the interface file gtsam.h. Please install it first in your current Python environment before attempting the build.
python3 -m pip install pyparsing

Getting Started

Clone this repository to your local machine and perform the standard CMake install:

mkdir build && cd build
cmake ..
make install # use sudo if needed

Using wrap in your project is straightforward from here. In your CMakeLists.txt file, you just need to add the following:

find_package(gtwrap)

pybind_wrap(${PROJECT_NAME}_py # target
            ${PROJECT_SOURCE_DIR}/cpp/${PROJECT_NAME}.h # interface header file
            "${PROJECT_NAME}.cpp" # the generated cpp
            "${PROJECT_NAME}" # module_name
            "${PROJECT_MODULE_NAME}" # top namespace in the cpp file e.g. gtsam
            "${ignore}" # ignore classes
            ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.tpl # the wrapping template file
            ${PROJECT_NAME} # libs
            "${PROJECT_NAME}" # dependencies
            ON # use boost
            )

For more information, please follow our tutorial.

GTSAM Python wrapper

WARNING: On macOS, you have to statically build GTSAM to use the wrapper.

  1. Set GTSAM_BUILD_PYTHON=ON while configuring the build with cmake.
  2. What you can do in the build folder:
    1. Just run python then import GTSAM and play around:

      
      import gtsam
      gtsam.__dir__()
      
    2. Run the unittests:

      python -m unittest discover
      
    3. Edit the unittests in python/gtsam/*.py and simply rerun the test. They were symlinked to <build_folder>/gtsam/*.py to facilitate fast development.

      python -m unittest gtsam/tests/test_Pose3.py
      
      • NOTE: You might need to re-run cmake .. if files are deleted or added.
  3. Do make install and cd <gtsam_install_folder>/python. Here, you can:
    1. Run the unittests:
      python setup.py test
      
    2. Install gtsam to your current Python environment.
      python setup.py install
      
      • NOTE: It's a good idea to create a virtual environment otherwise it will be installed in your system Python's site-packages.