From 02e2b37b08d063ed189526fbabeb570209988af3 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 27 Jan 2016 14:15:50 -0800 Subject: [PATCH] Add a few more template arguments --- python/handwritten/nonlinear/Values.cpp | 19 ++++++++++++------- python/handwritten/slam/BetweenFactor.cpp | 18 +++++++++--------- python/handwritten/slam/PriorFactor.cpp | 7 ++++--- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/python/handwritten/nonlinear/Values.cpp b/python/handwritten/nonlinear/Values.cpp index 6715fb071..83d33ca3c 100644 --- a/python/handwritten/nonlinear/Values.cpp +++ b/python/handwritten/nonlinear/Values.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- - * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) @@ -26,6 +26,7 @@ #include "gtsam/geometry/Point3.h" #include "gtsam/geometry/Rot3.h" #include "gtsam/geometry/Pose3.h" +#include "gtsam/navigation/ImuBias.h" using namespace boost::python; using namespace gtsam; @@ -44,15 +45,15 @@ using namespace gtsam; * >>> v.at(2,gtsam.geometry.Rot3()) * >>> v.at(3,gtsam.geometry.Pose3()) * - * A more 'pythonic' way I think would be to not use this function and define different + * A more 'pythonic' way I think would be to not use this function and define different * 'at' methods below using the name of the type in the function name, like: * * .def("point3_at", &Values::at, return_internal_reference<>()) * .def("rot3_at", &Values::at, return_internal_reference<>()) * .def("pose3_at", &Values::at, return_internal_reference<>()) * - * and then they could be accessed from python as - * + * and then they could be accessed from python as + * * >>> import gtsam * >>> v = gtsam.nonlinear.Values() * >>> v.insert(1,gtsam.geometry.Point3()) @@ -76,8 +77,8 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(print_overloads, Values::print, 0, 1); void exportValues(){ - // NOTE: Apparently the class 'Value'' is deprecated, so the commented lines below - // will compile, but are useless in the python wrapper. We need to use specific + // NOTE: Apparently the class 'Value'' is deprecated, so the commented lines below + // will compile, but are useless in the python wrapper. We need to use specific // 'at' and 'insert' methods for each type. // const Value& (Values::*at1)(Key) const = &Values::at; // void (Values::*insert1)(Key, const Value&) = &Values::insert; @@ -88,6 +89,8 @@ void exportValues(){ void (Values::*insert_point3)(Key, const gtsam::Point3&) = &Values::insert; void (Values::*insert_rot3) (Key, const gtsam::Rot3&) = &Values::insert; void (Values::*insert_pose3) (Key, const gtsam::Pose3&) = &Values::insert; + void (Values::*insert_bias) (Key, const gtsam::imuBias::ConstantBias&) = &Values::insert; + void (Values::*insert_vector3) (Key, const gtsam::Vector3&) = &Values::insert; class_("Values", init<>()) @@ -110,6 +113,8 @@ void exportValues(){ .def("insert", insert_point3) .def("insert", insert_rot3) .def("insert", insert_pose3) + .def("insert", insert_bias) + .def("insert", insert_vector3) // NOTE: The following commented lines are another way of specializing the return type. // See long comment above. // .def("at", &ValuesAt, return_internal_reference<>()) @@ -117,7 +122,7 @@ void exportValues(){ // .def("at", &ValuesAt, return_internal_reference<>()) .def("point3_at", &Values::at, return_value_policy()) .def("rot3_at", &Values::at, return_value_policy()) - .def("pose3_at", &Values::at, return_value_policy()) + .def("pose3_at", &Values::at, return_value_policy()) .def("exists", exists1) .def("keys", &Values::keys) ; diff --git a/python/handwritten/slam/BetweenFactor.cpp b/python/handwritten/slam/BetweenFactor.cpp index b6fc552a0..0e0949fb5 100644 --- a/python/handwritten/slam/BetweenFactor.cpp +++ b/python/handwritten/slam/BetweenFactor.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- - * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) @@ -11,7 +11,7 @@ /** * @brief wraps BetweenFactor for several values to python - * @author Andrew Melim + * @author Andrew Melim * @author Ellon Paiva Mendes (LAAS-CNRS) **/ @@ -33,17 +33,17 @@ using namespace gtsam; using namespace std; -// template +// template // void exportBetweenFactor(const std::string& name){ -// class_(name, init<>()) -// .def(init()) +// class_(name, init<>()) +// .def(init()) // ; // } -#define BETWEENFACTOR(VALUE) \ - class_< BetweenFactor, bases, boost::shared_ptr< BetweenFactor > >("BetweenFactor"#VALUE) \ - .def(init()) \ - .def("measured", &BetweenFactor::measured, return_internal_reference<>()) \ +#define BETWEENFACTOR(T) \ + class_< BetweenFactor, bases, boost::shared_ptr< BetweenFactor > >("BetweenFactor"#T) \ + .def(init()) \ + .def("measured", &BetweenFactor::measured, return_internal_reference<>()) \ ; void exportBetweenFactors() diff --git a/python/handwritten/slam/PriorFactor.cpp b/python/handwritten/slam/PriorFactor.cpp index dcb9de8ea..3ada91f43 100644 --- a/python/handwritten/slam/PriorFactor.cpp +++ b/python/handwritten/slam/PriorFactor.cpp @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- - * GTSAM Copyright 2010, Georgia Tech Research Corporation, + * GTSAM Copyright 2010, Georgia Tech Research Corporation, * Atlanta, Georgia 30332-0415 * All Rights Reserved * Authors: Frank Dellaert, et al. (see THANKS for the full author list) @@ -11,7 +11,7 @@ /** * @brief wraps PriorFactor for several values to python - * @author Andrew Melim + * @author Andrew Melim * @author Ellon Paiva Mendes (LAAS-CNRS) **/ @@ -54,4 +54,5 @@ void exportPriorFactors() PRIORFACTOR(Point3) PRIORFACTOR(Rot3) PRIORFACTOR(Pose3) -} \ No newline at end of file + PRIORFACTOR(Vector3) +}