8 #ifndef BETWEENFACTORMAXMIX_H_ 9 #define BETWEENFACTORMAXMIX_H_ 11 #include <gtsam/linear/NoiseModel.h> 12 #include <Eigen/Eigen> 13 #include <gtsam/config.h> 15 #if GTSAM_VERSION_MAJOR > 4 || (GTSAM_VERSION_MAJOR==4 && GTSAM_VERSION_MINOR>=1) 17 gtsam::Matrix
inverse(
const gtsam::Matrix & matrix)
19 return matrix.inverse();
31 BetweenFactorMaxMix(gtsam::Key key1, gtsam::Key key2,
const VALUE& measured,
const gtsam::SharedNoiseModel&
model,
const gtsam::SharedNoiseModel& model2,
double w)
32 :
gtsam::NoiseModelFactor2<VALUE, VALUE>(model, key1, key2), weight(w), nullHypothesisModel(model2),
33 betweenFactor(key1, key2, measured, model) { };
36 boost::optional<gtsam::Matrix&> H1 = boost::none,
37 boost::optional<gtsam::Matrix&> H2 = boost::none)
const 41 gtsam::Vector error = betweenFactor.evaluateError(p1, p2, H1, H2);
46 double m1 = this->noiseModel_->distance(error);
47 gtsam::noiseModel::Gaussian::shared_ptr g1 = this->noiseModel_;
48 gtsam::Matrix info1(g1->R().transpose()*g1->R());
50 double l1 = nu1 *
exp(-0.5*m1);
52 #if GTSAM_VERSION_MAJOR > 4 || (GTSAM_VERSION_MAJOR==4 && GTSAM_VERSION_MINOR>=1) 53 double m2 = nullHypothesisModel->squaredMahalanobisDistance(error);
55 double m2 = nullHypothesisModel->distance(error);
57 gtsam::noiseModel::Gaussian::shared_ptr g2 = nullHypothesisModel;
58 gtsam::Matrix info2(g2->R().transpose()*g2->R());
60 double l2 = nu2 *
exp(-0.5*m2);
64 if (H1) *H1 = *H1 * weight;
65 if (H2) *H2 = *H2 * weight;
66 error *=
sqrt(weight);
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &x)
GLM_FUNC_DECL T determinant(matType< T, P > const &m)
gtsam::BetweenFactor< VALUE > betweenFactor
gtsam::Vector evaluateError(const VALUE &p1, const VALUE &p2, boost::optional< gtsam::Matrix &> H1=boost::none, boost::optional< gtsam::Matrix &> H2=boost::none) const
gtsam::SharedNoiseModel nullHypothesisModel
GLM_FUNC_DECL genType exp(genType const &x)
BetweenFactorMaxMix(gtsam::Key key1, gtsam::Key key2, const VALUE &measured, const gtsam::SharedNoiseModel &model, const gtsam::SharedNoiseModel &model2, double w)
GLM_FUNC_DECL matType< T, P > inverse(matType< T, P > const &m)