Remove template parameter D, get from Base::Dim instead
parent
4b2eb2f7aa
commit
51482ea358
|
@ -63,7 +63,7 @@ enum LinearizationMode {
|
||||||
/**
|
/**
|
||||||
* SmartStereoProjectionFactor: triangulates point
|
* SmartStereoProjectionFactor: triangulates point
|
||||||
*/
|
*/
|
||||||
template<class CALIBRATION, size_t D>
|
template<class CALIBRATION>
|
||||||
class SmartStereoProjectionFactor: public SmartFactorBase<StereoCamera> {
|
class SmartStereoProjectionFactor: public SmartFactorBase<StereoCamera> {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ protected:
|
||||||
// and the factor is disregarded if the error is large
|
// and the factor is disregarded if the error is large
|
||||||
|
|
||||||
/// shorthand for this class
|
/// shorthand for this class
|
||||||
typedef SmartStereoProjectionFactor<CALIBRATION, D> This;
|
typedef SmartStereoProjectionFactor<CALIBRATION> This;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ZDim = 3
|
ZDim = 3
|
||||||
|
@ -347,7 +347,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// linearize returns a Hessianfactor that is an approximation of error(p)
|
/// linearize returns a Hessianfactor that is an approximation of error(p)
|
||||||
boost::shared_ptr<RegularHessianFactor<D> > createHessianFactor(
|
boost::shared_ptr<RegularHessianFactor<Base::Dim> > createHessianFactor(
|
||||||
const Cameras& cameras, const double lambda = 0.0) const {
|
const Cameras& cameras, const double lambda = 0.0) const {
|
||||||
|
|
||||||
bool isDebug = false;
|
bool isDebug = false;
|
||||||
|
@ -374,10 +374,10 @@ public:
|
||||||
if (isDebug)
|
if (isDebug)
|
||||||
std::cout << "In linearize: exception" << std::endl;
|
std::cout << "In linearize: exception" << std::endl;
|
||||||
BOOST_FOREACH(Matrix& m, Gs)
|
BOOST_FOREACH(Matrix& m, Gs)
|
||||||
m = zeros(D, D);
|
m = zeros(Base::Dim, Base::Dim);
|
||||||
BOOST_FOREACH(Vector& v, gs)
|
BOOST_FOREACH(Vector& v, gs)
|
||||||
v = zero(D);
|
v = zero(Base::Dim);
|
||||||
return boost::make_shared<RegularHessianFactor<D> >(this->keys_, Gs, gs,
|
return boost::make_shared<RegularHessianFactor<Base::Dim> >(this->keys_, Gs, gs,
|
||||||
0.0);
|
0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ public:
|
||||||
<< "something wrong in SmartProjectionHessianFactor: selective relinearization should be disabled"
|
<< "something wrong in SmartProjectionHessianFactor: selective relinearization should be disabled"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
return boost::make_shared<RegularHessianFactor<D> >(this->keys_,
|
return boost::make_shared<RegularHessianFactor<Base::Dim> >(this->keys_,
|
||||||
this->state_->Gs, this->state_->gs, this->state_->f);
|
this->state_->Gs, this->state_->gs, this->state_->f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ public:
|
||||||
// Schur complement trick
|
// Schur complement trick
|
||||||
// Frank says: should be possible to do this more efficiently?
|
// Frank says: should be possible to do this more efficiently?
|
||||||
// And we care, as in grouped factors this is called repeatedly
|
// And we care, as in grouped factors this is called repeatedly
|
||||||
Matrix H(D * numKeys, D * numKeys);
|
Matrix H(Base::Dim * numKeys, Base::Dim * numKeys);
|
||||||
Vector gs_vector;
|
Vector gs_vector;
|
||||||
|
|
||||||
Matrix3 P = Cameras::PointCov(E, lambda);
|
Matrix3 P = Cameras::PointCov(E, lambda);
|
||||||
|
@ -436,11 +436,11 @@ public:
|
||||||
// Populate Gs and gs
|
// Populate Gs and gs
|
||||||
int GsCount2 = 0;
|
int GsCount2 = 0;
|
||||||
for (DenseIndex i1 = 0; i1 < (DenseIndex) numKeys; i1++) { // for each camera
|
for (DenseIndex i1 = 0; i1 < (DenseIndex) numKeys; i1++) { // for each camera
|
||||||
DenseIndex i1D = i1 * D;
|
DenseIndex i1D = i1 * Base::Dim;
|
||||||
gs.at(i1) = gs_vector.segment<D>(i1D);
|
gs.at(i1) = gs_vector.segment<Base::Dim>(i1D);
|
||||||
for (DenseIndex i2 = 0; i2 < (DenseIndex) numKeys; i2++) {
|
for (DenseIndex i2 = 0; i2 < (DenseIndex) numKeys; i2++) {
|
||||||
if (i2 >= i1) {
|
if (i2 >= i1) {
|
||||||
Gs.at(GsCount2) = H.block<D, D>(i1D, i2 * D);
|
Gs.at(GsCount2) = H.block<Base::Dim, Base::Dim>(i1D, i2 * Base::Dim);
|
||||||
GsCount2++;
|
GsCount2++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,29 +452,29 @@ public:
|
||||||
this->state_->gs = gs;
|
this->state_->gs = gs;
|
||||||
this->state_->f = f;
|
this->state_->f = f;
|
||||||
}
|
}
|
||||||
return boost::make_shared<RegularHessianFactor<D> >(this->keys_, Gs, gs, f);
|
return boost::make_shared<RegularHessianFactor<Base::Dim> >(this->keys_, Gs, gs, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // create factor
|
// // create factor
|
||||||
// boost::shared_ptr<ImplicitSchurFactor<D> > createImplicitSchurFactor(
|
// boost::shared_ptr<ImplicitSchurFactor<Base::Dim> > createImplicitSchurFactor(
|
||||||
// const Cameras& cameras, double lambda) const {
|
// const Cameras& cameras, double lambda) const {
|
||||||
// if (triangulateForLinearize(cameras))
|
// if (triangulateForLinearize(cameras))
|
||||||
// return Base::createImplicitSchurFactor(cameras, point_, lambda);
|
// return Base::createImplicitSchurFactor(cameras, point_, lambda);
|
||||||
// else
|
// else
|
||||||
// return boost::shared_ptr<ImplicitSchurFactor<D> >();
|
// return boost::shared_ptr<ImplicitSchurFactor<Base::Dim> >();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /// create factor
|
// /// create factor
|
||||||
// boost::shared_ptr<JacobianFactorQ<D> > createJacobianQFactor(
|
// boost::shared_ptr<JacobianFactorQ<Base::Dim> > createJacobianQFactor(
|
||||||
// const Cameras& cameras, double lambda) const {
|
// const Cameras& cameras, double lambda) const {
|
||||||
// if (triangulateForLinearize(cameras))
|
// if (triangulateForLinearize(cameras))
|
||||||
// return Base::createJacobianQFactor(cameras, point_, lambda);
|
// return Base::createJacobianQFactor(cameras, point_, lambda);
|
||||||
// else
|
// else
|
||||||
// return boost::make_shared< JacobianFactorQ<D> >(this->keys_);
|
// return boost::make_shared< JacobianFactorQ<Base::Dim> >(this->keys_);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /// Create a factor, takes values
|
// /// Create a factor, takes values
|
||||||
// boost::shared_ptr<JacobianFactorQ<D> > createJacobianQFactor(
|
// boost::shared_ptr<JacobianFactorQ<Base::Dim> > createJacobianQFactor(
|
||||||
// const Values& values, double lambda) const {
|
// const Values& values, double lambda) const {
|
||||||
// Cameras cameras;
|
// Cameras cameras;
|
||||||
// // TODO triangulate twice ??
|
// // TODO triangulate twice ??
|
||||||
|
@ -482,7 +482,7 @@ public:
|
||||||
// if (nonDegenerate)
|
// if (nonDegenerate)
|
||||||
// return createJacobianQFactor(cameras, lambda);
|
// return createJacobianQFactor(cameras, lambda);
|
||||||
// else
|
// else
|
||||||
// return boost::make_shared< JacobianFactorQ<D> >(this->keys_);
|
// return boost::make_shared< JacobianFactorQ<Base::Dim> >(this->keys_);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
/// different (faster) way to compute Jacobian factor
|
/// different (faster) way to compute Jacobian factor
|
||||||
|
@ -491,7 +491,7 @@ public:
|
||||||
if (triangulateForLinearize(cameras))
|
if (triangulateForLinearize(cameras))
|
||||||
return Base::createJacobianSVDFactor(cameras, point_, lambda);
|
return Base::createJacobianSVDFactor(cameras, point_, lambda);
|
||||||
else
|
else
|
||||||
return boost::make_shared<JacobianFactorSVD<D, ZDim> >(this->keys_);
|
return boost::make_shared<JacobianFactorSVD<Base::Dim, ZDim> >(this->keys_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if nonDegenerate
|
/// Returns true if nonDegenerate
|
||||||
|
@ -717,9 +717,9 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// traits
|
/// traits
|
||||||
template<class CALIBRATION, size_t D>
|
template<class CALIBRATION>
|
||||||
struct traits<SmartStereoProjectionFactor<CALIBRATION, D> > : public Testable<
|
struct traits<SmartStereoProjectionFactor<CALIBRATION> > : public Testable<
|
||||||
SmartStereoProjectionFactor<CALIBRATION, D> > {
|
SmartStereoProjectionFactor<CALIBRATION> > {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // \ namespace gtsam
|
} // \ namespace gtsam
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace gtsam {
|
||||||
* @addtogroup SLAM
|
* @addtogroup SLAM
|
||||||
*/
|
*/
|
||||||
template<class CALIBRATION>
|
template<class CALIBRATION>
|
||||||
class SmartStereoProjectionPoseFactor: public SmartStereoProjectionFactor<CALIBRATION, 6> {
|
class SmartStereoProjectionPoseFactor: public SmartStereoProjectionFactor<CALIBRATION> {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
LinearizationMode linearizeTo_; ///< How to linearize the factor (HESSIAN, JACOBIAN_SVD, JACOBIAN_Q)
|
LinearizationMode linearizeTo_; ///< How to linearize the factor (HESSIAN, JACOBIAN_SVD, JACOBIAN_Q)
|
||||||
|
@ -51,7 +51,7 @@ public:
|
||||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||||
|
|
||||||
/// shorthand for base class type
|
/// shorthand for base class type
|
||||||
typedef SmartStereoProjectionFactor<CALIBRATION, 6> Base;
|
typedef SmartStereoProjectionFactor<CALIBRATION> Base;
|
||||||
|
|
||||||
/// shorthand for this class
|
/// shorthand for this class
|
||||||
typedef SmartStereoProjectionPoseFactor<CALIBRATION> This;
|
typedef SmartStereoProjectionPoseFactor<CALIBRATION> This;
|
||||||
|
|
Loading…
Reference in New Issue