Go to the documentation of this file.
65 typedef typename std::shared_ptr<BetweenFactorEM>
shared_ptr;
74 const double prior_inlier,
const double prior_outlier,
75 const bool flag_bump_up_near_zero_probs =
false) :
79 flag_bump_up_near_zero_probs) {
90 std::cout <<
s <<
"BetweenFactorEM(" << keyFormatter(
key1_) <<
","
91 << keyFormatter(
key2_) <<
")\n";
95 std::cout <<
"(prior_inlier, prior_outlier_) = (" <<
prior_inlier_ <<
","
102 const This *
t =
dynamic_cast<const This*
>(&
f);
132 return std::shared_ptr<JacobianFactor>();
136 std::vector<Matrix>
A(this->
size());
157 T hx =
p1.between(
p2, H1, H2);
164 double p_inlier = p_inlier_outlier[0];
165 double p_outlier = p_inlier_outlier[1];
175 err_wh_eq.resize(err_wh_inlier.rows() * 2);
176 err_wh_eq <<
sqrt(p_inlier) * err_wh_inlier.array(),
sqrt(p_outlier)
177 * err_wh_outlier.array();
190 (*H)[0].resize(H1_aug.rows(), H1_aug.cols());
191 (*H)[1].resize(H2_aug.rows(), H2_aug.cols());
253 *
exp(-0.5 * err_wh_inlier.dot(err_wh_inlier));
255 *
exp(-0.5 * err_wh_outlier.dot(err_wh_outlier));
258 std::cout <<
"in calcIndicatorProb. err_unwh: " << err[0] <<
", "
259 << err[1] <<
", " << err[2] << std::endl;
260 std::cout <<
"in calcIndicatorProb. err_wh_inlier: " << err_wh_inlier[0]
261 <<
", " << err_wh_inlier[1] <<
", " << err_wh_inlier[2] << std::endl;
262 std::cout <<
"in calcIndicatorProb. err_wh_inlier.dot(err_wh_inlier): "
263 << err_wh_inlier.dot(err_wh_inlier) << std::endl;
264 std::cout <<
"in calcIndicatorProb. err_wh_outlier.dot(err_wh_outlier): "
265 << err_wh_outlier.dot(err_wh_outlier) << std::endl;
268 <<
"in calcIndicatorProb. p_inlier, p_outlier before normalization: "
269 << p_inlier <<
", " << p_outlier << std::endl;
272 double sumP = p_inlier + p_outlier;
279 if (p_inlier < minP || p_outlier < minP) {
282 if (p_outlier < minP)
284 sumP = p_inlier + p_outlier;
290 return (
Vector(2) << p_inlier, p_outlier).finished();
301 T hx =
p1.between(
p2, H1, H2);
350 Keys.push_back(
key1_);
351 Keys.push_back(
key2_);
377 p1.between(
p2, H1, H2);
380 H.resize(H1.rows(), H1.rows() + H2.rows());
384 joint_cov.resize(cov1.rows() + cov2.rows(), cov1.cols() + cov2.cols());
385 joint_cov << cov1, cov12, cov12.transpose(), cov2;
387 Matrix cov_state =
H * joint_cov *
H.transpose();
395 covRinlier + cov_state);
400 covRoutlier + cov_state);
412 size_t dim()
const override {
418 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
420 friend class boost::serialization::access;
421 template<
class ARCHIVE>
422 void serialize(ARCHIVE & ar,
const unsigned int ) {
424 & boost::serialization::make_nvp(
"NonlinearFactor",
425 boost::serialization::base_object<Base>(*
this));
433 template<
class VALUE>
const Symbol key1('v', 1)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
void updateNoiseModels(const Values &values, const NonlinearFactorGraph &graph)
const EIGEN_DEVICE_FUNC InverseReturnType inverse() const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Concept check for values that can be used in unit tests.
const VALUE & measured() const
std::shared_ptr< GaussianFactor > linearize(const Values &x) const override
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Vector unwhitenedError(const Values &x) const
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
virtual bool active(const Values &) const
Matrix get_model_outlier_cov() const
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
bool get_flag_bump_up_near_zero_probs() const
Matrix get_model_inlier_cov() const
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
#define GTSAM_CONCEPT_LIE_TYPE(T)
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
const Symbol key2('v', 2)
~BetweenFactorEM() override
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Matrix stack(size_t nrMatrices,...)
static constexpr bool debug
std::shared_ptr< This > shared_ptr
shared_ptr to this class
static shared_ptr Create(size_t dim)
Vector whitenedError(const Values &x, std::vector< Matrix > &H) const
noiseModel::Gaussian::shared_ptr SharedGaussian
Vector calcIndicatorProb(const Values &x) const
BetweenFactorEM(Key key1, Key key2, const VALUE &measured, const SharedGaussian &model_inlier, const SharedGaussian &model_outlier, const double prior_inlier, const double prior_outlier, const bool flag_bump_up_near_zero_probs=false)
double error(const Values &x) const override
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Non-linear factor base classes.
std::vector< Matrix > * OptionalMatrixVecType
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
SharedGaussian model_inlier_
Base class and basic functions for Lie types.
A class for computing marginals in a NonlinearFactorGraph.
size_t dim() const override
#define GTSAM_CONCEPT_TESTABLE_TYPE(T)
Vector whitenedError(const Values &x, OptionalMatrixVecType H=nullptr) const
void updateNoiseModels_givenCovs(const Values &values, const Matrix &cov1, const Matrix &cov2, const Matrix &cov12)
bool flag_bump_up_near_zero_probs_
BetweenFactorEM< VALUE > This
SharedGaussian get_model_outlier() const
A factor with a quadratic error function - a Gaussian.
SharedGaussian model_outlier_
SharedGaussian get_model_inlier() const
NonlinearFactorGraph graph
Marginals marginals(graph, result)
std::uint64_t Key
Integer nonlinear key type.
void set_flag_bump_up_near_zero_probs(bool flag)
std::shared_ptr< BetweenFactorEM > shared_ptr
Jet< T, N > sqrt(const Jet< T, N > &f)
static shared_ptr Covariance(const Matrix &covariance, bool smart=true)
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:55