| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * 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) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * @brief wraps ConstantTwistScenario class to python | 
					
						
							|  |  |  |  * @author Frank Dellaert | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <boost/python.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define NO_IMPORT_ARRAY
 | 
					
						
							|  |  |  | #include <numpy_eigen/NumpyEigenConverter.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "gtsam/navigation/ImuFactor.h"
 | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  | #include "gtsam/navigation/GPSFactor.h"
 | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace boost::python; | 
					
						
							|  |  |  | using namespace gtsam; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-28 13:23:36 +08:00
										 |  |  | typedef gtsam::OptionalJacobian<3, 9> OptionalJacobian39; | 
					
						
							| 
									
										
										
										
											2016-01-28 07:15:55 +08:00
										 |  |  | typedef gtsam::OptionalJacobian<9, 6> OptionalJacobian96; | 
					
						
							| 
									
										
										
										
											2016-01-28 13:23:36 +08:00
										 |  |  | typedef gtsam::OptionalJacobian<9, 9> OptionalJacobian9; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(print_overloads, print, 0, 1) | 
					
						
							|  |  |  | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(attitude_overloads, attitude, 0, 1) | 
					
						
							|  |  |  | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(position_overloads, position, 0, 1) | 
					
						
							|  |  |  | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(velocity_overloads, velocity, 0, 1) | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(equals_overloads, PreintegratedImuMeasurements::equals, 1, 2) | 
					
						
							| 
									
										
										
										
											2016-06-05 16:16:35 +08:00
										 |  |  | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(predict_overloads, PreintegrationBase::predict, 2, 4) | 
					
						
							| 
									
										
										
										
											2016-01-28 07:15:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  | void exportImuFactor() { | 
					
						
							| 
									
										
										
										
											2016-01-28 13:23:36 +08:00
										 |  |  |   class_<OptionalJacobian39>("OptionalJacobian39", init<>()); | 
					
						
							| 
									
										
										
										
											2016-01-28 07:15:55 +08:00
										 |  |  |   class_<OptionalJacobian96>("OptionalJacobian96", init<>()); | 
					
						
							| 
									
										
										
										
											2016-01-28 13:23:36 +08:00
										 |  |  |   class_<OptionalJacobian9>("OptionalJacobian9", init<>()); | 
					
						
							| 
									
										
										
										
											2016-01-28 07:15:55 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  |   class_<NavState>("NavState", init<>()) | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  |       .def(init<const Rot3&, const Point3&, const Velocity3&>()) | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  |       // TODO(frank): overload with jacobians
 | 
					
						
							| 
									
										
										
										
											2016-01-28 13:23:36 +08:00
										 |  |  |       .def("print", &NavState::print, print_overloads()) | 
					
						
							|  |  |  |       .def("attitude", &NavState::attitude, | 
					
						
							|  |  |  |            attitude_overloads()[return_value_policy<copy_const_reference>()]) | 
					
						
							|  |  |  |       .def("position", &NavState::position, | 
					
						
							|  |  |  |            position_overloads()[return_value_policy<copy_const_reference>()]) | 
					
						
							|  |  |  |       .def("velocity", &NavState::velocity, | 
					
						
							|  |  |  |            velocity_overloads()[return_value_policy<copy_const_reference>()]) | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  |       .def(repr(self)) | 
					
						
							|  |  |  |       .def("pose", &NavState::pose); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   class_<imuBias::ConstantBias>("ConstantBias", init<>()) | 
					
						
							|  |  |  |       .def(init<const Vector3&, const Vector3&>()) | 
					
						
							|  |  |  |       .def(repr(self)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-28 06:15:16 +08:00
										 |  |  |   class_<PreintegrationParams, boost::shared_ptr<PreintegrationParams>>( | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  |       "PreintegrationParams", init<const Vector3&>()) | 
					
						
							|  |  |  |       .def_readwrite("gyroscopeCovariance", | 
					
						
							|  |  |  |                      &PreintegrationParams::gyroscopeCovariance) | 
					
						
							|  |  |  |       .def_readwrite("omegaCoriolis", &PreintegrationParams::omegaCoriolis) | 
					
						
							|  |  |  |       .def_readwrite("body_P_sensor", &PreintegrationParams::body_P_sensor) | 
					
						
							|  |  |  |       .def_readwrite("accelerometerCovariance", | 
					
						
							|  |  |  |                      &PreintegrationParams::accelerometerCovariance) | 
					
						
							|  |  |  |       .def_readwrite("integrationCovariance", | 
					
						
							|  |  |  |                      &PreintegrationParams::integrationCovariance) | 
					
						
							|  |  |  |       .def_readwrite("use2ndOrderCoriolis", | 
					
						
							|  |  |  |                      &PreintegrationParams::use2ndOrderCoriolis) | 
					
						
							|  |  |  |       .def_readwrite("n_gravity", &PreintegrationParams::n_gravity) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       .def("MakeSharedD", &PreintegrationParams::MakeSharedD) | 
					
						
							|  |  |  |       .staticmethod("MakeSharedD") | 
					
						
							|  |  |  |       .def("MakeSharedU", &PreintegrationParams::MakeSharedU) | 
					
						
							|  |  |  |       .staticmethod("MakeSharedU"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  |   // NOTE(frank): https://mail.python.org/pipermail/cplusplus-sig/2016-January/017362.html
 | 
					
						
							|  |  |  |   register_ptr_to_python< boost::shared_ptr<PreintegrationParams> >(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-05 16:04:01 +08:00
										 |  |  |   class_<PreintegrationType>( | 
					
						
							| 
									
										
										
										
											2016-06-05 16:16:35 +08:00
										 |  |  | #ifdef GTSAM_TANGENT_PREINTEGRATION
 | 
					
						
							|  |  |  |       "TangentPreintegration", | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |       "ManifoldPreintegration", | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-06-05 16:04:01 +08:00
										 |  |  |       init<const boost::shared_ptr<PreintegrationParams>&, const imuBias::ConstantBias&>()) | 
					
						
							|  |  |  |       .def("predict", &PreintegrationType::predict, predict_overloads()) | 
					
						
							|  |  |  |       .def("computeError", &PreintegrationType::computeError) | 
					
						
							|  |  |  |       .def("resetIntegration", &PreintegrationType::resetIntegration) | 
					
						
							|  |  |  |       .def("deltaTij", &PreintegrationType::deltaTij); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   class_<PreintegratedImuMeasurements, bases<PreintegrationType>>( | 
					
						
							|  |  |  |       "PreintegratedImuMeasurements", | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  |       init<const boost::shared_ptr<PreintegrationParams>&, const imuBias::ConstantBias&>()) | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  |       .def(repr(self)) | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  |       .def("equals", &PreintegratedImuMeasurements::equals, equals_overloads(args("other", "tol"))) | 
					
						
							|  |  |  |       .def("integrateMeasurement", &PreintegratedImuMeasurements::integrateMeasurement) | 
					
						
							|  |  |  |       .def("integrateMeasurements", &PreintegratedImuMeasurements::integrateMeasurements) | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  |       .def("preintMeasCov", &PreintegratedImuMeasurements::preintMeasCov); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  |   class_<ImuFactor, bases<NonlinearFactor>, boost::shared_ptr<ImuFactor>>("ImuFactor") | 
					
						
							| 
									
										
										
										
											2016-01-28 13:23:36 +08:00
										 |  |  |       .def("error", &ImuFactor::error) | 
					
						
							| 
									
										
										
										
											2016-01-28 06:15:16 +08:00
										 |  |  |       .def(init<Key, Key, Key, Key, Key, const PreintegratedImuMeasurements&>()) | 
					
						
							|  |  |  |       .def(repr(self)); | 
					
						
							| 
									
										
										
										
											2016-02-25 03:01:19 +08:00
										 |  |  |   register_ptr_to_python<boost::shared_ptr<ImuFactor>>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   class_<ImuFactor2, bases<NonlinearFactor>, boost::shared_ptr<ImuFactor2>>("ImuFactor2") | 
					
						
							|  |  |  |       .def("error", &ImuFactor2::error) | 
					
						
							|  |  |  |       .def(init<Key, Key, Key, const PreintegratedImuMeasurements&>()) | 
					
						
							|  |  |  |       .def(repr(self)); | 
					
						
							|  |  |  |   register_ptr_to_python<boost::shared_ptr<ImuFactor2>>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   class_<GPSFactor, bases<NonlinearFactor>, boost::shared_ptr<GPSFactor>>("GPSFactor") | 
					
						
							|  |  |  |       .def("error", &GPSFactor::error) | 
					
						
							|  |  |  |       .def(init<Key, const Point3&, noiseModel::Base::shared_ptr>()); | 
					
						
							|  |  |  |   register_ptr_to_python<boost::shared_ptr<GPSFactor>>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   class_<GPSFactor2, bases<NonlinearFactor>, boost::shared_ptr<GPSFactor2>>("GPSFactor2") | 
					
						
							|  |  |  |       .def("error", &GPSFactor2::error) | 
					
						
							|  |  |  |       .def(init<Key, const Point3&, noiseModel::Base::shared_ptr>()); | 
					
						
							|  |  |  |   register_ptr_to_python<boost::shared_ptr<GPSFactor2>>(); | 
					
						
							| 
									
										
										
										
											2016-01-28 05:16:52 +08:00
										 |  |  | } |