| b28b3570d Merge pull request #30 from borglab/feature/remove_install cc2b07193 Cleanup 610ca176b Allow GTWRAP to be installed in a prefix 193b922c6 Merge pull request #29 from borglab/feature/remove_install 6d2b6ace6 fix path to package e5f220759 clean up some leftover code b0b158a0a install python package as a directory 3f4a7c775 Allow usage without install into global env 5040ba415 Merge pull request #28 from borglab/readme-update 14a7452fe updated README Getting Started section git-subtree-dir: wrap git-subtree-split: b28b3570d221b89f3568f44ed439d3a444903570 | ||
|---|---|---|
| .github/workflows | ||
| cmake | ||
| docs | ||
| gtwrap | ||
| pybind11 | ||
| scripts | ||
| sphinx | ||
| tests | ||
| utilities | ||
| .gitignore | ||
| CMakeLists.txt | ||
| LICENSE | ||
| README.md | ||
| matlab.h | ||
| pybind_wrapper.tpl.example | ||
| requirements.txt | ||
| setup.py | ||
		
			
				
				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
- This library uses pybind11, which is included as a subdirectory in GTSAM.
- The interface_parser.pyin this library usespyparsingto parse the interface filegtsam.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.
- Set GTSAM_BUILD_PYTHON=ONwhile configuring the build withcmake.
- What you can do in the buildfolder:- 
Just run python then import GTSAM and play around: import gtsam gtsam.__dir__()
- 
Run the unittests: python -m unittest discover
- 
Edit the unittests in python/gtsam/*.pyand simply rerun the test. They were symlinked to<build_folder>/gtsam/*.pyto 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.
 
- NOTE: You might need to re-run 
 
- 
- Do make installandcd <gtsam_install_folder>/python. Here, you can:- Run the unittests:
python setup.py test
- Install gtsamto 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.
 
 
- Run the unittests: