Commit Graph

10357 Commits (b8de033bd0510367a044d0fddfa32127d7d61819)

Author SHA1 Message Date
Haldean Brown 2058b92882 rename Pose3 parameter from point to pose 2017-03-30 12:53:01 -07:00
Haldean Brown 5ae331ad04 add test for pose-to-pose bearing 2017-03-30 12:52:48 -07:00
Duy-Nguyen Ta dda8e31934 fix comment 2017-03-26 00:13:27 -04:00
Duy-Nguyen Ta 61a3475372 fix installation path 2017-03-26 00:13:05 -04:00
Duy-Nguyen Ta 123ae36c63 put back requirements.txt, now with backports. 2017-03-25 23:38:49 -04:00
Duy-Nguyen Ta 1ec09ddf6a more flexible destination folder for scripts installation 2017-03-25 23:35:46 -04:00
Duy-Nguyen Ta 0a979f6a55 install FindCython.cmake script to wrap other projects 2017-03-25 23:32:44 -04:00
Duy-Nguyen Ta b2243d950b get compiler settings from cmake 2017-03-21 18:05:41 -04:00
Duy-Nguyen Ta 90ea744619 [mac/clang/libc++/c++11] force clang to use libc++ for c++11, instead of the default old libstdc++4.2.1 which doesn't support c++11 2017-03-21 15:02:21 -04:00
Duy-Nguyen Ta a8d363c347 update expected pyx 2017-03-21 03:52:01 -04:00
Duy-Nguyen Ta 869dc811b0 graceful dynamic cast failures 2017-03-21 02:34:04 -04:00
Duy-Nguyen Ta b8d3292da3 force checking cython version in cmake 2017-03-21 00:55:50 -04:00
Duy-Nguyen Ta a2333b9ef2 update cython/readme to troubleshoot eigency installation problems 2017-03-20 17:22:40 -04:00
Duy-Nguyen Ta 87443621c4 make gtsam_unstable_cython_wrapper dependent on gtsam_cython_wrapper. 2017-03-20 17:16:17 -04:00
Duy-Nguyen Ta 3e4a8b6b48 update todo with some nice-to-have features 2017-03-18 23:06:19 -04:00
Duy-Nguyen Ta e624b6fe72 don't change matlab's generated filename (gtsam_wrapper), only cmake targets (to gtsam_matlab_wrapper) 2017-03-18 22:01:24 -04:00
Duy-Nguyen Ta e1fedad0a6 revert adding copy constructors 2017-03-18 21:23:12 -04:00
Duy-Nguyen Ta 0da506b3a9 change gtsam_wrapper --> gtsam_matlab_wrapper 2017-03-18 20:32:25 -04:00
Duy-Nguyen Ta 4a57d8cd27 update todo 2017-03-18 20:29:41 -04:00
Duy-Nguyen Ta 3daf8d7351 fix bad import * style 2017-03-18 19:50:35 -04:00
Duy-Nguyen Ta d6c75b57f8 update todo 2017-03-18 19:49:37 -04:00
Duy-Nguyen Ta c8e4648c66 better name: gtsam_short --> gtsam_test 2017-03-18 19:49:19 -04:00
Duy-Nguyen Ta ee75faa0df test cython wrapper's generated files 2017-03-18 18:35:28 -04:00
Duy-Nguyen Ta e3918da95c update test to comply with a cython wrapper's requirement: need an include for every class. 2017-03-18 18:33:01 -04:00
Duy-Nguyen Ta 2146aa140c default value for cython extra imports 2017-03-18 18:30:44 -04:00
Duy-Nguyen Ta 07b1bbfe7f remove namespace requirement for cython wrapper
Only for unittesting wrap geometry.h, not yet tested in real python/cython
2017-03-18 18:29:53 -04:00
Duy-Nguyen Ta 42deeb7bf0 fix/update matlab wrapper tests when wrap serialization option is off 2017-03-18 18:26:21 -04:00
Duy-Nguyen Ta aa43cf725c update TODO 2017-03-18 16:00:42 -04:00
Duy-Nguyen Ta d18e638b08 cython wrap unstable 2017-03-18 15:52:08 -04:00
Duy-Nguyen Ta a6281e1932 unify gtsam.h for matlab and cython wrapper 2017-03-18 15:33:01 -04:00
Duy-Nguyen Ta 6148f822ae update 2017-03-17 11:26:25 -04:00
Duy-Nguyen Ta ca165daaa8 Merge branch 'develop' into feature/cython_wrapper 2017-03-17 11:03:08 -04:00
Duy-Nguyen Ta 16a1643d17 gracefully rasing exception when trying to create obj of a class with no constructor 2017-03-15 22:47:14 -04:00
Duy-Nguyen Ta 52f54d07bd remove blank lines 2017-03-15 22:45:48 -04:00
Duy-Nguyen Ta c52f54221e update testWrap to call new function names 2017-03-15 17:03:13 -04:00
Duy-Nguyen Ta 347fed9377 wrap Vector,Matrix for Values::at in the short test 2017-03-15 13:57:01 -04:00
Duy-Nguyen Ta 685b0cb62f remove np_utils Matrix and Vector functions
Not needed anymore.
2017-03-15 13:54:00 -04:00
Duy-Nguyen Ta 6bf7ea23cf convert numpy input params to dtype float and order 'F' automatically
using numpy.astype(...). No copy if the params are already in the correct dtype and storage order.

For a function
    f(Matrix A, Matrix B),
simply wrapping it to pyx as
   f(A.astype(float, order='F', copy=False), B.astype(float, order='F', copy=False))
won't work.
It produces a strange side-effect that the content of A is overwritten by B and the two inputs are the same (data address) inside the function!

This is because Cython decreases the ref count for the temporary variable resulted from A.astype(...) before generates the wrap for B.astype(...).
Hence, the A.astype temp var is probably reused for B.astype, and they were pointing to the same data address.

For that reason, we have to go a longer route and wrap it as:
  A = A.astype(float, order='F', copy=False)
  B = B.astype(float, order='F', copy=False)
  f(A, B)

For future ref., here is a sample of the wrongly generated code that wraps the JacobianFactor constructor:
Jacobian(Key i1, Matrix A1, Key i2, Matrix A2, Vector b, noiseModel::Diagonal model)

Wrongly wrapped pyx code:
self.shared_CJacobianFactor_ = shared_ptr[CJacobianFactor](new CJacobianFactor(i1, <MatrixXd>(Map[MatrixXd](A1.astype(float, order='F',copy=False)), i2, <MatrixXd>(Map[MatrixXd](A2.astype(float, order='F', copy=False)), <VectorXd>(Map[VectorXd](b.astype(float, order='F', copy=False))), model.shared_CnoiseModel_Diagonal_))

The problematic Cython generated CPP code with a comment on the problematic line:
/////////////////////////////////////////
// WRONG VERSION
/////////////////////////////////////////
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_A1), __pyx_n_s_astype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyFloat_Type)));
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 2107, __pyx_L1_error)
  try {
    __pyx_t_14 = eigency::Map<Eigen::MatrixXd> (((PyArrayObject *)__pyx_t_13));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2107, __pyx_L1_error)
  }
///////////////////////////////////////////////
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;  	//<------- Problematic line!!! Killing this will result in the correct result!
///////////////////////////////////////////////
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_A2), __pyx_n_s_astype); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)(&PyFloat_Type)));
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 2107, __pyx_L1_error)
  try {
    __pyx_t_15 = eigency::Map<Eigen::MatrixXd> (((PyArrayObject *)__pyx_t_12));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2107, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_b), __pyx_n_s_astype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)(&PyFloat_Type)));
  __Pyx_GIVEREF(((PyObject *)(&PyFloat_Type)));
  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyFloat_Type)));
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_order, __pyx_n_s_F) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 2107, __pyx_L1_error)
  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 2107, __pyx_L1_error)
  try {
    __pyx_t_16 = eigency::Map<Eigen::VectorXd> (((PyArrayObject *)__pyx_t_13));
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2107, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  try {
    __pyx_t_17 = new gtsam::JacobianFactor(__pyx_v_i1, ((Eigen::MatrixXd)__pyx_t_14), __pyx_v_i2, ((Eigen::MatrixXd)__pyx_t_15), ((Eigen::VectorXd)__pyx_t_16), __pyx_v_model->shared_CnoiseModel_Diagonal_);
  } catch(...) {
    __Pyx_CppExn2PyErr();
    __PYX_ERR(0, 2107, __pyx_L1_error)
  }
  __pyx_v_self->shared_CJacobianFactor_ = boost::shared_ptr<gtsam::JacobianFactor> (__pyx_t_17);
2017-03-15 13:47:11 -04:00
Haldean Brown 5389877896 set attitude jacobian to zero in Pose3-to-Pose3 bearing 2017-03-15 10:36:10 -07:00
Haldean Brown 42e7e31340 Add new Pose3::bearing overload to Python wrapper 2017-03-13 10:31:37 -07:00
Haldean Brown 68d26ff279 Support bearing factors between Pose3 values
I am modelling a system in which there are two bodies, and one can
observe the other but cannot estimate the other's pose. This is
perfectly modeled by a BearingRangeFactor, but without this patch, you
cannot make a BearingRangeFactor between two Pose3 values. This adds
support for that by extending the Pose3 class to support calling
bearing() on another Pose3.
2017-03-13 09:39:32 -07:00
Luca Carlone fbb9d3bdda Merged in feature/heterogeneousSmartFactorNoise (pull request #271)
Feature/heterogeneoussmartfactornoise

Approved-by: Chris Beall
Approved-by: Jing Dong
2017-03-12 05:50:08 +00:00
Yao Chen bd67779f74 Merged in feature/variadic-emplace_back (pull request #274)
Feature/variadic emplace_back

Approved-by: Jing Dong
2017-03-12 05:19:15 +00:00
Duy-Nguyen Ta 0e278f81c6 remove Vectorize, simplify to just numpy.squeeze 2017-03-10 23:33:14 -05:00
Duy-Nguyen Ta 89bc31d703 fix comment 2017-03-10 23:28:26 -05:00
Duy-Nguyen Ta dc7792d350 unify/rename functions: matlab_code and cython_wrapper to generate_xxxxx_wrapper 2017-03-10 23:27:29 -05:00
Duy-Nguyen Ta b7efaf8c3f special ctor signature to be used with cyCreateFromShared
so that calling the default ctor by mistake on a class without the default ctor will respond nicely with an exception instead of a seg-fault
2017-03-08 15:22:16 -05:00
Duy-Nguyen Ta c9666a1b44 fix merge problem
Argument::isScalar() was moved to Qualified and should be checked via Argument::type
2017-03-08 15:15:37 -05:00
Duy-Nguyen Ta e2abfe256d remove requirements.txt
@dellaert: not needed for only 2 packages and an exception for eigency
2017-03-08 10:59:06 -05:00
Duy-Nguyen Ta 98e9ffdce4 Revert "[mEstimator] virtualize and implementing sqrtWeight instead of weight to speed up a bit"
This reverts commit 9187b47432.
2017-03-08 10:32:11 -05:00