Example on how to wrap templated classes such as factors
parent
2455780829
commit
d0efbadac8
|
@ -19,7 +19,7 @@ file(GLOB symbolic_src "symbolic/*.cpp")
|
||||||
|
|
||||||
#wrap_python("base" ${PROJECT_SOURCE_DIR}/python/${PROJECT_NAME} ${base_src})
|
#wrap_python("base" ${PROJECT_SOURCE_DIR}/python/${PROJECT_NAME} ${base_src})
|
||||||
wrap_python("geometry" ${PROJECT_SOURCE_DIR}/python/gtsam ${geometry_src})
|
wrap_python("geometry" ${PROJECT_SOURCE_DIR}/python/gtsam ${geometry_src})
|
||||||
|
wrap_python("slam" ${PROJECT_SOURCE_DIR}/python/gtsam ${slam_src})
|
||||||
#add_python_export_library(${PROJECT_NAME}_test ${PROJECT_SOURCE_DIR}/python/${PROJECT_NAME}
|
#add_python_export_library(${PROJECT_NAME}_test ${PROJECT_SOURCE_DIR}/python/${PROJECT_NAME}
|
||||||
# ${AUTOGEN_TEST_FILES}
|
# ${AUTOGEN_TEST_FILES}
|
||||||
#)
|
#)
|
|
@ -1,9 +0,0 @@
|
||||||
#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);
|
|
||||||
}*/
|
|
|
@ -1,10 +0,0 @@
|
||||||
#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,13 @@
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <gtsam/slam/BearingFactor.h>
|
||||||
|
|
||||||
|
using namespace boost::python;
|
||||||
|
using namespace gtsam;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
template<class VALUE>
|
||||||
|
void exposeBearingFactor(const std::string& name){
|
||||||
|
class_<VALUE>(name, init<>())
|
||||||
|
;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <gtsam/slam/BetweenFactor.h>
|
||||||
|
|
||||||
|
using namespace boost::python;
|
||||||
|
using namespace gtsam;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
template<class VALUE>
|
||||||
|
void exposeBetweenFactor(const std::string& name){
|
||||||
|
class_<VALUE>(name, init<>())
|
||||||
|
.def(init<Key, Key, VALUE, SharedNoiseModel>())
|
||||||
|
;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <gtsam/slam/PriorFactor.h>
|
||||||
|
|
||||||
|
using namespace boost::python;
|
||||||
|
using namespace gtsam;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
template<class VALUE>
|
||||||
|
void exposePriorFactor(const std::string& name){
|
||||||
|
class_<VALUE>(name, init<>())
|
||||||
|
.def(init<Key, VALUE, SharedNoiseModel>())
|
||||||
|
;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <boost/cstdint.hpp>
|
||||||
|
|
||||||
|
#include <gtsam/geometry/Point2.h>
|
||||||
|
#include <gtsam/geometry/Pose2.h>
|
||||||
|
#include <gtsam/slam/PriorFactor.h>
|
||||||
|
#include <gtsam/slam/BetweenFactor.h>
|
||||||
|
|
||||||
|
template<class VALUE> void exportPriorFactor(const std::string& name);
|
||||||
|
template<class VALUE> void exportBetweenFactor(const std::string& name);
|
||||||
|
|
||||||
|
BOOST_PYTHON_MODULE(libgeometry){
|
||||||
|
using namespace boost::python;
|
||||||
|
|
||||||
|
typedef gtsam::PriorFactor<gtsam::Point2> Point2PriorFactor;
|
||||||
|
typedef gtsam::PriorFactor<gtsam::Pose2> Pose2PriorFactor;
|
||||||
|
|
||||||
|
exportPriorFactor<Point2PriorFactor>("Point2PriorFactor");
|
||||||
|
exportPriorFactor<Pose2PriorFactor>("Pose2PriorFactor");
|
||||||
|
|
||||||
|
typedef gtsam::BetweenFactor<gtsam::Pose2> Pose2BetweenFactor;
|
||||||
|
|
||||||
|
exportBetweenFactor<Pose2BetweenFactor>("Pose2BetweenFactor");
|
||||||
|
}
|
Loading…
Reference in New Issue