Go to file
Varun Agrawal 58a9622777 Squashed 'wrap/' changes from aae9b4605..3eff76f60
3eff76f60 Merge pull request #53 from borglab/feature/refactor
13215dfa7 Merge pull request #52 from borglab/fix/tests
696913b11 install setuptools
9523328ba Merge branch 'master' into fix/tests
7c630b361 some more cleanup
656993a71 cleaned up  Typename
a16f6f38e move qualified and basis type outside to their own class scope
72ead8bd7 Merge pull request #51 from borglab/fix/test-interface-parser
6deefd4fc added tests for interface_parser
50d490a85 Merge pull request #50 from borglab/feature/refs-all-types
be4511290 updated docs for BasisType
0e80b0d8c update MATLAB tests
0015d7397 added support for shared pointer and ref for basis types
86d2158f1 remove std::string from list of Basis types
94f928441 ignore code coverage reports
2033dd345 replace prints with log.debug statements
ae98091b3 fix deprecation in doc tests
13a2f66c4 Merge pull request #46 from borglab/feature/new-shared-pointer
3c7d85865 updated docs
6d7897088 use @ for raw pointer, go back to * for shared pointer
1d6194c57 updated matlab wrapper to handle both raw and shared pointers
1448f6924 fix some failing tests
2ab1dae32 Merge branch 'master' into feature/new-shared-pointer
96f8a56bd Merge pull request #47 from borglab/fix/ci
6003203f3 run CI only for pull requests
a8f29ead1 fix the python version yml key
fcae17227 check if directory exists when testing
f592f08c9 explicit pip3 so that we don't use Python2
d49c2f3c2 correct call for pip
dfe360526 fix the CI
149b7c523 docs for templated functions
f2189acc6 support typedefing for templated functions
965458a2b added test for templated functions
eaff6e6ab made is_const common for all types
3d9c70b32 added tests and cleaned up a bit
010b89626 support for simple pointers on basis types
6b98fd80c new syntax for shared_ptr
ff7ad0b78 support for templated functions
a1a443c8d Merge pull request #43 from borglab/fix/cmake-and-matlab
2f3a055e4 remove accidentally committed file
770d055e2 set proper paths for cmake and eschew relative paths
773d01ae1 fix bug in matlab wrapper
721ef740f Merge pull request #41 from borglab/feature/type-hints
67aac9758 minor refactor of CI yml
e6a63ae0c fix all mypy issues
a3aaa3e7c remove a lot of linter issues from matlab_wrapper
a96db522f static typing for interface_parser

git-subtree-dir: wrap
git-subtree-split: 3eff76f604b5ba9e71cf4947654e288142ed7a94
2021-03-24 00:36:02 -04:00
.github/workflows Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
cmake Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
docs Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
gtwrap Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
pybind11 Squashed 'wrap/' changes from 49d831588..314b121fd 2020-09-16 18:03:25 -04:00
scripts Squashed 'wrap/' changes from b0eb968f2..d19cda546 2021-03-13 12:01:28 -05:00
sphinx Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
tests Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
utilities Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
.gitignore Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
CMakeLists.txt Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
DOCS.md Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -04:00
LICENSE Squashed 'wrap/' changes from dfa624e77..09f8bbf71 2021-01-04 13:11:36 -05:00
README.md Squashed 'wrap/' changes from b0eb968f2..d19cda546 2021-03-13 12:01:28 -05:00
matlab.h Squashed 'wrap/' content from commit 21ee82f75 2020-08-17 14:44:43 -04:00
pybind_wrapper.tpl.example Squashed 'wrap/' changes from b0eb968f2..d19cda546 2021-03-13 12:01:28 -05:00
requirements.txt Squashed 'wrap/' changes from aae9b4605..3eff76f60 2021-03-24 00:36:02 -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.

Documentation

Documentation for wrapping C++ code can be found here.

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.

Matlab Wrapper

In the CMake, simply include the MatlabWrap.cmake file.

include(MatlabWrap)

This cmake file defines functions for generating MATLAB wrappers.

  • wrap_and_install_library(interfaceHeader linkLibraries extraIncludeDirs extraMexFlags) Generates wrap code and compiles the wrapper.

Usage example:

`wrap_and_install_library("lba.h" "" "" "")`

Arguments:

  • interfaceHeader: The relative or absolute path to the wrapper interface definition file.
  • linkLibraries: Any additional libraries to link. Your project library (e.g. lba), libraries it depends on, and any necessary MATLAB libraries will be linked automatically. So normally, leave this empty.
  • extraIncludeDirs: Any additional include paths required by dependent libraries that have not already been added by include_directories. Again, normally, leave this empty.
  • extraMexFlags: Any additional flags to pass to the compiler when building the wrap code. Normally, leave this empty.