diff --git a/CMakeLists.txt b/CMakeLists.txt index 0380b8a2f..bbf7de2e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ message(STATUS "GTSAM_SOURCE_ROOT_DIR: [${GTSAM_SOURCE_ROOT_DIR}]") # Load build type flags and default to Debug mode include(GtsamBuildTypes) +include(GtsamPythonWrap) # Use macros for creating tests/timing scripts include(GtsamTesting) @@ -344,6 +345,10 @@ if (GTSAM_INSTALL_MATLAB_TOOLBOX) add_subdirectory(matlab) endif() +if(GTSAM_BUILD_PYTHON) + add_subdirectory(python) +endif() + # Build gtsam_unstable if (GTSAM_BUILD_UNSTABLE) add_subdirectory(gtsam_unstable) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 000000000..be739d7b4 --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,25 @@ +include_directories("${PROJECT_SOURCE_DIR}/gtsam") + +#set the default path for built executables to the "bin" directory +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) +#set the default path for built libraries to the "lib" directory +set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) + +#include_directories(${EIGEN_INCLUDE_DIRS}) + +file(GLOB base_src "base/*.cpp") +file(GLOB geometry_src "geometry/*.cpp") +file(GLOB inference_src "inference/*.cpp") +file(GLOB linear_src "linear/*.cpp") +file(GLOB nonlinear_src "nonlinear/*.cpp") +file(GLOB slam_src "slam/*.cpp") +file(GLOB symbolic_src "symbolic/*.cpp") + +#wrap_python("base" ${PROJECT_SOURCE_DIR}/python/${PROJECT_NAME} ${base_src}) +wrap_python("geometry" ${PROJECT_SOURCE_DIR}/python/gtsam ${geometry_src}) + +#add_python_export_library(${PROJECT_NAME}_test ${PROJECT_SOURCE_DIR}/python/${PROJECT_NAME} +# ${AUTOGEN_TEST_FILES} +#) \ No newline at end of file diff --git a/python/base/DerivedValue.cpp b/python/base/DerivedValue.cpp new file mode 100644 index 000000000..b389d14fc --- /dev/null +++ b/python/base/DerivedValue.cpp @@ -0,0 +1,9 @@ +#include +#include "gtsam/base/DerivedValue.h" + +using namespace boost::python; +using namespace gtsam; + +/*void exportDerivedValue(){ + class_ >("DerivedValue", no_init); +}*/ \ No newline at end of file diff --git a/python/base/Value.cpp b/python/base/Value.cpp new file mode 100644 index 000000000..052334dbf --- /dev/null +++ b/python/base/Value.cpp @@ -0,0 +1,10 @@ +#include +#include "gtsam/base/Value.h" + +using namespace boost::python; +using namespace gtsam; + +// Virtual class, no init +void exportValue(){ + class_("Value", no_init); +} \ No newline at end of file diff --git a/python/geometry/Point2.cpp b/python/geometry/Point2.cpp new file mode 100644 index 000000000..0f87a6e48 --- /dev/null +++ b/python/geometry/Point2.cpp @@ -0,0 +1,23 @@ +#include +#include "gtsam/geometry/Point2.h" + +using namespace boost::python; +using namespace gtsam; + +BOOST_PYTHON_FUNCTION_OVERLOADS(equals_overloads, &Point2::equals, 1, 2) + +void exportPoint2(){ + + class_("Point2", init<>()) + .def(init()) + .def("print", &Point2::print) + .def("equals", &Point2::equals) + .def("inverse", &Point2::inverse) + .def("compose", &Point2::compose) + .def("between", &Point2::between) + .def("dim", &Point2::dim) + .def("retract", &Point2::retract) + .def("x", &Point2::x) + .def("y", &Point2::y) + ; +} \ No newline at end of file diff --git a/python/geometry/exportGeometry.cpp b/python/geometry/exportGeometry.cpp new file mode 100644 index 000000000..55bf7a83b --- /dev/null +++ b/python/geometry/exportGeometry.cpp @@ -0,0 +1,10 @@ +#include +#include + +void exportPoint2(); + +BOOST_PYTHON_MODULE(libgeometry){ + using namespace boost::python; + + exportPoint2(); +} \ No newline at end of file