Initial stages of python wrapping. Issues with method overloading, boost optionals. Testing with Point2 only now
parent
6ea0644559
commit
ec934770f3
|
@ -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)
|
||||
|
|
|
@ -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}
|
||||
#)
|
|
@ -0,0 +1,9 @@
|
|||
#include <boost/python.hpp>
|
||||
#include "gtsam/base/DerivedValue.h"
|
||||
|
||||
using namespace boost::python;
|
||||
using namespace gtsam;
|
||||
|
||||
/*void exportDerivedValue(){
|
||||
class_<DerivedValue, bases<Value> >("DerivedValue", no_init);
|
||||
}*/
|
|
@ -0,0 +1,10 @@
|
|||
#include <boost/python.hpp>
|
||||
#include "gtsam/base/Value.h"
|
||||
|
||||
using namespace boost::python;
|
||||
using namespace gtsam;
|
||||
|
||||
// Virtual class, no init
|
||||
void exportValue(){
|
||||
class_<Value>("Value", no_init);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#include <boost/python.hpp>
|
||||
#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>("Point2", init<>())
|
||||
.def(init<double, double>())
|
||||
.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)
|
||||
;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#include <boost/python.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
void exportPoint2();
|
||||
|
||||
BOOST_PYTHON_MODULE(libgeometry){
|
||||
using namespace boost::python;
|
||||
|
||||
exportPoint2();
|
||||
}
|
Loading…
Reference in New Issue