Go to file
Varun Agrawal 7cc7232a99 Squashed 'wrap/' changes from dfa624e77..09f8bbf71
09f8bbf71 Merge pull request #25 from borglab/fix/function-name
0dbfb6c13 fix function name to be the correct one
f69f8b01f Merge pull request #24 from borglab/fix/pip
6519a6627 use pip install to overcome superuser issues
b11ecf4e8 Merge pull request #23 from borglab/fix/remove-pip-args
813030108 remove pip-args since we are using setup.py
498d233e0 Merge pull request #22 from borglab/fix/package-install
846212ac3 set correct flags for installing gtwrap package
62161cd20 Merge pull request #21 from borglab/feature/script-vars
93be1d9f8 set script variables and move pybind11 loading so gtwrap can be used under gtsam
8770e3c7e Merge pull request #20 from borglab/fix/pybind-include
8c3c83618 proper placement of pybind11 include
a9ad4f504 Merge pull request #19 from borglab/feature/package
99d8a12c7 added more documentation
4cbec1579 change to macro so we don't have to deal with function scopes
b83e405b8 updates to completely install the package
38a64b3de new scripts which will be installed to bin directory
bf9646235 Merge pull request #18 from borglab/fix/cmake-min
c7c280099 Consistent cmake minimum required
42df58f62 Merge pull request #17 from borglab/fix/cleanup
e580b282d version bump
4ccd66fa5 More finegrained handling of Python version
6476fd710 Merge pull request #16 from borglab/feature/better-find-python
8ac1296a0 use setup.py to install dependencies
e9ac473be install dependencies and support versions of CMake<3.12
cf272dbd2 Merge pull request #15 from borglab/feature/utils
ffc9cc4f7 new utils to reduce boilerplate
20e8e8b7a Merge pull request #11 from borglab/feature/package
04b844bd6 use new version of FindPython and be consistent
3f9d7a32a Merge pull request #13 from borglab/add_license
c791075a6 Add LICENSE
517b67c46 correct working directory for setup.py
1b22b47ae move matlab.h to root directory
37b407214 Proper source directory path for use in other projects
61696dd5d configure PybindWrap within the cmake directory
1b91fc9af add config file so we can use find_package
a1e6f4f53 small typo
da9f351be updated README and housekeeping
64b8f78d5 files needed to allow for packaging
bddda7f54 package structure

git-subtree-dir: wrap
git-subtree-split: 09f8bbf7172ba8b1bd3d2484795743f16e1a5893
2021-01-04 13:11:36 -05:00
.github/workflows Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
cmake Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -05:00
docs Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
gtwrap Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -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 dfa624e77..09f8bbf71 2021-01-04 13:11:36 -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 dfa624e77..09f8bbf71 2021-01-04 13:11:36 -05:00
LICENSE Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -05:00
README.md Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -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 dfa624e77..09f8bbf71 2021-01-04 13:11:36 -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 you CMakeLists.txt file, you just need to add the following:

include(PybindWrap)

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
            "gtsam" # top namespace in the cpp file
            "${ignore}" # ignore classes
            ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.tpl
            ${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.