Revert python module to use old handwritten files
Just noticed several handwritten files here. I'm reverting the python module to use these handwritten files to later add the files I was wrapping to the same framework. Classes from geometry were wrapped for an old C++ interface, so several boost python's .def(...) were commented out. Conflicts: python/gtsam/.gitignorerelease/4.3a0
parent
7680b533ac
commit
ffae37a675
|
@ -347,8 +347,16 @@ endif()
|
||||||
|
|
||||||
# Python wrap
|
# Python wrap
|
||||||
if (GTSAM_BUILD_PYTHON)
|
if (GTSAM_BUILD_PYTHON)
|
||||||
include(GtsamPythonWrap)
|
# NOTE: The automatic generation of python wrapper from the gtsampy.h interface is
|
||||||
|
# not working yet, so we're using a handwritten wrapper files on python/handwritten.
|
||||||
|
# Once the python wrapping from the interface file is working, you can _swap_ the
|
||||||
|
# comments on the next lines
|
||||||
|
|
||||||
|
# include(GtsamPythonWrap)
|
||||||
# wrap_and_install_python(gtsampy.h "${GTSAM_ADDITIONAL_LIBRARIES}" "")
|
# wrap_and_install_python(gtsampy.h "${GTSAM_ADDITIONAL_LIBRARIES}" "")
|
||||||
|
|
||||||
|
add_subdirectory(python)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build gtsam_unstable
|
# Build gtsam_unstable
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Obtain Dependencies
|
||||||
|
# Boost Python
|
||||||
|
find_package(Boost COMPONENTS python REQUIRED)
|
||||||
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
# Find Python
|
||||||
|
find_package(PythonLibs 2.7 REQUIRED)
|
||||||
|
include_directories(${PYTHON_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
# Numpy_Eigen
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/gtsam/3rdparty/numpy_eigen/include/)
|
||||||
|
|
||||||
|
add_subdirectory(handwritten)
|
|
@ -0,0 +1 @@
|
||||||
|
/libgtsam_python.so
|
|
@ -1,5 +1 @@
|
||||||
import registernumpyeigen
|
from libgtsam_python import *
|
||||||
import noiseModel
|
|
||||||
from geometry import *
|
|
||||||
from nonlinear import *
|
|
||||||
from slam import *
|
|
|
@ -1,27 +1,48 @@
|
||||||
include_directories("${PROJECT_SOURCE_DIR}/gtsam")
|
# Macro to get list of subdirectories
|
||||||
|
MACRO(SUBDIRLIST result curdir)
|
||||||
|
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
||||||
|
SET(dirlist "")
|
||||||
|
FOREACH(child ${children})
|
||||||
|
IF(IS_DIRECTORY ${curdir}/${child})
|
||||||
|
LIST(APPEND dirlist ${child})
|
||||||
|
ENDIF()
|
||||||
|
ENDFOREACH()
|
||||||
|
SET(${result} ${dirlist})
|
||||||
|
ENDMACRO()
|
||||||
|
|
||||||
#set the default path for built executables to the "bin" directory
|
# get subdirectories list
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
#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)
|
# get the sources needed to compile gtsam python module
|
||||||
|
SET(gtsam_python_srcs "")
|
||||||
|
FOREACH(subdir ${SUBDIRS})
|
||||||
|
file(GLOB ${subdir}_src "${subdir}/*.cpp")
|
||||||
|
LIST(APPEND gtsam_python_srcs ${${subdir}_src})
|
||||||
|
ENDFOREACH()
|
||||||
|
|
||||||
#include_directories(${EIGEN_INCLUDE_DIRS})
|
# Create the library
|
||||||
|
set(moduleName gtsam)
|
||||||
|
set(gtsamLib gtsam)
|
||||||
|
add_library(${moduleName}_python SHARED exportgtsam.cpp ${gtsam_python_srcs})
|
||||||
|
|
||||||
file(GLOB base_src "base/*.cpp")
|
set_target_properties(${moduleName}_python PROPERTIES
|
||||||
file(GLOB geometry_src "geometry/*.cpp")
|
OUTPUT_NAME ${moduleName}_python
|
||||||
file(GLOB inference_src "inference/*.cpp")
|
CLEAN_DIRECT_OUTPUT 1)
|
||||||
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})
|
target_link_libraries(${moduleName}_python ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARY} ${gtsamLib}) #temp
|
||||||
wrap_python("pygtsam" ${PROJECT_SOURCE_DIR}/python/gtsam exportgtsam.cpp
|
|
||||||
${geometry_src} ${linear_src} ${nonlinear_src} ${slam_src})
|
# On OSX and Linux, the python library must end in the extension .so. Build this
|
||||||
#wrap_python("nonlinear" ${PROJECT_SOURCE_DIR}/python/gtsam ${nonlinear_src})
|
# filename here.
|
||||||
#wrap_python("slam" ${PROJECT_SOURCE_DIR}/python/gtsam ${slam_src})
|
get_property(PYLIB_OUTPUT_FILE TARGET ${moduleName}_python PROPERTY LOCATION)
|
||||||
#add_python_export_library(${PROJECT_NAME}_test ${PROJECT_SOURCE_DIR}/python/${PROJECT_NAME}
|
set(PYLIB_OUTPUT_FILE $<TARGET_FILE:${moduleName}_python>)
|
||||||
# ${AUTOGEN_TEST_FILES}
|
get_filename_component(PYLIB_OUTPUT_NAME ${PYLIB_OUTPUT_FILE} NAME_WE)
|
||||||
#)
|
set(PYLIB_SO_NAME lib${moduleName}_python.so)
|
||||||
|
|
||||||
|
# Installs the library in the gtsam folder, which is used by setup.py to create the gtsam package
|
||||||
|
set(PYTHON_MODULE_DIRECTORY ${CMAKE_SOURCE_DIR}/python/gtsam)
|
||||||
|
# Cause the library to be output in the correct directory.
|
||||||
|
add_custom_command(TARGET ${moduleName}_python
|
||||||
|
POST_BUILD
|
||||||
|
COMMAND cp -v ${PYLIB_OUTPUT_FILE} ${PYTHON_MODULE_DIRECTORY}/${PYLIB_SO_NAME}
|
||||||
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
COMMENT "Copying library files to python directory" )
|
||||||
|
|
|
@ -45,7 +45,7 @@ typedef gtsam::BetweenFactor<gtsam::Pose2> Pose2BetweenFactor;
|
||||||
|
|
||||||
//-----------------------------------//
|
//-----------------------------------//
|
||||||
|
|
||||||
BOOST_PYTHON_MODULE(libgtsam){
|
BOOST_PYTHON_MODULE(libgtsam_python){
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
exportPoint2();
|
exportPoint2();
|
||||||
exportRot2();
|
exportRot2();
|
||||||
|
|
|
@ -15,9 +15,9 @@ void exportPoint2(){
|
||||||
.def("print", &Point2::print, print_overloads(args("s")))
|
.def("print", &Point2::print, print_overloads(args("s")))
|
||||||
.def("equals", &Point2::equals, equals_overloads(args("q","tol")))
|
.def("equals", &Point2::equals, equals_overloads(args("q","tol")))
|
||||||
.def("inverse", &Point2::inverse)
|
.def("inverse", &Point2::inverse)
|
||||||
.def("compose", &Point2::compose, compose_overloads(args("q", "H1", "H2")))
|
// .def("compose", &Point2::compose, compose_overloads(args("q", "H1", "H2")))
|
||||||
.def("between", &Point2::between)
|
.def("between", &Point2::between)
|
||||||
.def("dim", &Point2::dim)
|
// .def("dim", &Point2::dim)
|
||||||
.def("retract", &Point2::retract)
|
.def("retract", &Point2::retract)
|
||||||
.def("x", &Point2::x)
|
.def("x", &Point2::x)
|
||||||
.def("y", &Point2::y)
|
.def("y", &Point2::y)
|
||||||
|
|
|
@ -17,15 +17,15 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(range_overloads, Pose2::range, 1, 3)
|
||||||
|
|
||||||
void exportPose2(){
|
void exportPose2(){
|
||||||
|
|
||||||
double (Pose2::*range1)(const Pose2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
// double (Pose2::*range1)(const Pose2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
||||||
= &Pose2::range;
|
// = &Pose2::range;
|
||||||
double (Pose2::*range2)(const Point2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
// double (Pose2::*range2)(const Point2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
||||||
= &Pose2::range;
|
// = &Pose2::range;
|
||||||
|
|
||||||
Rot2 (Pose2::*bearing1)(const Pose2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
// Rot2 (Pose2::*bearing1)(const Pose2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
||||||
= &Pose2::bearing;
|
// = &Pose2::bearing;
|
||||||
Rot2 (Pose2::*bearing2)(const Point2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
// Rot2 (Pose2::*bearing2)(const Point2&, boost::optional<Matrix&>, boost::optional<Matrix&>) const
|
||||||
= &Pose2::bearing;
|
// = &Pose2::bearing;
|
||||||
|
|
||||||
class_<Pose2>("Pose2", init<>())
|
class_<Pose2>("Pose2", init<>())
|
||||||
.def(init<Pose2>())
|
.def(init<Pose2>())
|
||||||
|
@ -34,11 +34,11 @@ void exportPose2(){
|
||||||
.def("print", &Pose2::print, print_overloads(args("s")))
|
.def("print", &Pose2::print, print_overloads(args("s")))
|
||||||
|
|
||||||
.def("equals", &Pose2::equals, equals_overloads(args("pose","tol")))
|
.def("equals", &Pose2::equals, equals_overloads(args("pose","tol")))
|
||||||
.def("inverse", &Pose2::inverse)
|
// .def("inverse", &Pose2::inverse)
|
||||||
.def("compose", &Pose2::compose, compose_overloads(args("p2", "H1", "H2")))
|
// .def("compose", &Pose2::compose, compose_overloads(args("p2", "H1", "H2")))
|
||||||
.def("between", &Pose2::between, between_overloads(args("p2", "H1", "H2")))
|
// .def("between", &Pose2::between, between_overloads(args("p2", "H1", "H2")))
|
||||||
.def("dim", &Pose2::dim)
|
// .def("dim", &Pose2::dim)
|
||||||
.def("retract", &Pose2::retract)
|
// .def("retract", &Pose2::retract)
|
||||||
|
|
||||||
.def("transform_to", &Pose2::transform_to,
|
.def("transform_to", &Pose2::transform_to,
|
||||||
transform_to_overloads(args("point", "H1", "H2")))
|
transform_to_overloads(args("point", "H1", "H2")))
|
||||||
|
@ -55,12 +55,12 @@ void exportPose2(){
|
||||||
.def("translation", &Pose2::translation, return_value_policy<copy_const_reference>())
|
.def("translation", &Pose2::translation, return_value_policy<copy_const_reference>())
|
||||||
.def("rotation", &Pose2::rotation, return_value_policy<copy_const_reference>())
|
.def("rotation", &Pose2::rotation, return_value_policy<copy_const_reference>())
|
||||||
|
|
||||||
.def("bearing", bearing1, bearing_overloads())
|
// .def("bearing", bearing1, bearing_overloads())
|
||||||
.def("bearing", bearing2, bearing_overloads())
|
// .def("bearing", bearing2, bearing_overloads())
|
||||||
|
|
||||||
// Function overload example
|
// Function overload example
|
||||||
.def("range", range1, range_overloads())
|
// .def("range", range1, range_overloads())
|
||||||
.def("range", range2, range_overloads())
|
// .def("range", range2, range_overloads())
|
||||||
|
|
||||||
|
|
||||||
.def("Expmap", &Pose2::Expmap)
|
.def("Expmap", &Pose2::Expmap)
|
||||||
|
|
|
@ -28,11 +28,11 @@ void exportRot2(){
|
||||||
|
|
||||||
.def("print", &Rot2::print, print_overloads(args("s")))
|
.def("print", &Rot2::print, print_overloads(args("s")))
|
||||||
.def("equals", &Rot2::equals, equals_overloads(args("q","tol")))
|
.def("equals", &Rot2::equals, equals_overloads(args("q","tol")))
|
||||||
.def("inverse", &Rot2::inverse)
|
// .def("inverse", &Rot2::inverse)
|
||||||
.def("compose", &Rot2::compose, compose_overloads(args("q", "H1", "H2")))
|
// .def("compose", &Rot2::compose, compose_overloads(args("q", "H1", "H2")))
|
||||||
.def("between", &Rot2::between)
|
// .def("between", &Rot2::between)
|
||||||
.def("dim", &Rot2::dim)
|
// .def("dim", &Rot2::dim)
|
||||||
.def("retract", &Rot2::retract)
|
// .def("retract", &Rot2::retract)
|
||||||
|
|
||||||
.def("Expmap", &Rot2::Expmap)
|
.def("Expmap", &Rot2::Expmap)
|
||||||
.staticmethod("Expmap")
|
.staticmethod("Expmap")
|
||||||
|
|
Loading…
Reference in New Issue