29 #include <boost/serialization/base_object.hpp> 30 #include <boost/assign/list_of.hpp> 34 using boost::assign::cref_list_of;
64 template<
typename CONTAINER>
94 virtual size_t dim()
const = 0;
109 virtual boost::shared_ptr<GaussianFactor>
110 linearize(
const Values& c)
const = 0;
120 throw std::runtime_error(
"NonlinearFactor::clone(): Attempting to clone factor with no clone() implemented!");
129 shared_ptr rekey(
const std::map<Key,Key>& rekey_mapping)
const;
135 shared_ptr rekey(
const KeyVector& new_keys)
const;
177 template<
typename CONTAINER>
179 Base(keys), noiseModel_(noiseModel) {}
191 void print(
const std::string&
s =
"",
195 bool equals(
const NonlinearFactor&
f,
double tol = 1
e-9)
const override;
198 size_t dim()
const override {
199 return noiseModel_->dim();
214 boost::optional<std::vector<Matrix>&>
H = boost::none)
const = 0;
230 double weight(
const Values& c)
const;
245 boost::shared_ptr<GaussianFactor> linearize(
const Values& x)
const override;
255 friend class boost::serialization::access;
256 template<
class ARCHIVE>
258 ar & boost::serialization::make_nvp(
"NonlinearFactor",
259 boost::serialization::base_object<Base>(*
this));
260 ar & BOOST_SERIALIZATION_NVP(noiseModel_);
276 template<
class VALUE>
298 inline Key key()
const {
return keys_[0]; }
306 : Base(noiseModel, cref_list_of<1>(key1)) {}
318 boost::optional<std::vector<Matrix> &>
H = boost::none)
const override {
319 if (this->active(x)) {
320 const X &
x1 = x.
at<X>(keys_[0]);
322 return evaluateError(x1, (*
H)[0]);
324 return evaluateError(x1);
327 return Vector::Zero(this->
dim());
341 evaluateError(
const X &
x,
342 boost::optional<Matrix &>
H = boost::none)
const = 0;
348 friend class boost::serialization::access;
349 template<
class ARCHIVE>
351 ar & boost::serialization::make_nvp(
"NoiseModelFactor",
352 boost::serialization::base_object<Base>(*
this));
360 template<
class VALUE1,
class VALUE2>
388 Base(noiseModel, cref_list_of<2>(j1)(j2)) {}
399 if(this->active(x)) {
400 const X1&
x1 = x.
at<X1>(keys_[0]);
401 const X2&
x2 = x.
at<X2>(keys_[1]);
403 return evaluateError(x1, x2, (*
H)[0], (*
H)[1]);
405 return evaluateError(x1, x2);
408 return Vector::Zero(this->
dim());
418 evaluateError(
const X1&,
const X2&, boost::optional<Matrix&> H1 =
419 boost::none, boost::optional<Matrix&> H2 = boost::none)
const = 0;
424 friend class boost::serialization::access;
425 template<
class ARCHIVE>
427 ar & boost::serialization::make_nvp(
"NoiseModelFactor",
428 boost::serialization::base_object<Base>(*
this));
435 template<
class VALUE1,
class VALUE2,
class VALUE3>
465 Base(noiseModel, cref_list_of<3>(j1)(j2)(j3)) {}
477 if(this->active(x)) {
479 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]), (*
H)[0], (*
H)[1], (*
H)[2]);
481 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]));
483 return Vector::Zero(this->
dim());
493 evaluateError(
const X1&,
const X2&,
const X3&,
494 boost::optional<Matrix&> H1 = boost::none,
495 boost::optional<Matrix&> H2 = boost::none,
496 boost::optional<Matrix&> H3 = boost::none)
const = 0;
501 friend class boost::serialization::access;
502 template<
class ARCHIVE>
504 ar & boost::serialization::make_nvp(
"NoiseModelFactor",
505 boost::serialization::base_object<Base>(*
this));
512 template<
class VALUE1,
class VALUE2,
class VALUE3,
class VALUE4>
544 Base(noiseModel, cref_list_of<4>(j1)(j2)(j3)(j4)) {}
557 if(this->active(x)) {
559 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]), x.
at<X4>(keys_[3]), (*
H)[0], (*
H)[1], (*
H)[2], (*
H)[3]);
561 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]), x.
at<X4>(keys_[3]));
563 return Vector::Zero(this->
dim());
573 evaluateError(
const X1&,
const X2&,
const X3&,
const X4&,
574 boost::optional<Matrix&> H1 = boost::none,
575 boost::optional<Matrix&> H2 = boost::none,
576 boost::optional<Matrix&> H3 = boost::none,
577 boost::optional<Matrix&> H4 = boost::none)
const = 0;
582 friend class boost::serialization::access;
583 template<
class ARCHIVE>
585 ar & boost::serialization::make_nvp(
"NoiseModelFactor",
586 boost::serialization::base_object<Base>(*
this));
593 template<
class VALUE1,
class VALUE2,
class VALUE3,
class VALUE4,
class VALUE5>
627 Base(noiseModel, cref_list_of<5>(j1)(j2)(j3)(j4)(j5)) {}
641 if(this->active(x)) {
643 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]), x.
at<X4>(keys_[3]), x.
at<X5>(keys_[4]), (*
H)[0], (*
H)[1], (*
H)[2], (*
H)[3], (*
H)[4]);
645 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]), x.
at<X4>(keys_[3]), x.
at<X5>(keys_[4]));
647 return Vector::Zero(this->
dim());
657 evaluateError(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
658 boost::optional<Matrix&> H1 = boost::none,
659 boost::optional<Matrix&> H2 = boost::none,
660 boost::optional<Matrix&> H3 = boost::none,
661 boost::optional<Matrix&> H4 = boost::none,
662 boost::optional<Matrix&> H5 = boost::none)
const = 0;
667 friend class boost::serialization::access;
668 template<
class ARCHIVE>
670 ar & boost::serialization::make_nvp(
"NoiseModelFactor",
671 boost::serialization::base_object<Base>(*
this));
678 template<
class VALUE1,
class VALUE2,
class VALUE3,
class VALUE4,
class VALUE5,
class VALUE6>
714 Base(noiseModel, cref_list_of<6>(j1)(j2)(j3)(j4)(j5)(j6)) {}
729 if(this->active(x)) {
731 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]), x.
at<X4>(keys_[3]), x.
at<X5>(keys_[4]), x.
at<X6>(keys_[5]), (*
H)[0], (*
H)[1], (*
H)[2], (*
H)[3], (*
H)[4], (*
H)[5]);
733 return evaluateError(x.
at<X1>(keys_[0]), x.
at<X2>(keys_[1]), x.
at<X3>(keys_[2]), x.
at<X4>(keys_[3]), x.
at<X5>(keys_[4]), x.
at<X6>(keys_[5]));
735 return Vector::Zero(this->
dim());
745 evaluateError(
const X1&,
const X2&,
const X3&,
const X4&,
const X5&,
const X6&,
746 boost::optional<Matrix&> H1 = boost::none,
747 boost::optional<Matrix&> H2 = boost::none,
748 boost::optional<Matrix&> H3 = boost::none,
749 boost::optional<Matrix&> H4 = boost::none,
750 boost::optional<Matrix&> H5 = boost::none,
751 boost::optional<Matrix&> H6 = boost::none)
const = 0;
756 friend class boost::serialization::access;
757 template<
class ARCHIVE>
759 ar & boost::serialization::make_nvp(
"NoiseModelFactor",
760 boost::serialization::base_object<Base>(*
this));
void print(const Matrix &A, const string &s, ostream &stream)
void serialize(ARCHIVE &ar, const unsigned int)
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
NoiseModelFactor1(const SharedNoiseModel &noiseModel, Key key1)
size_t dim() const override
NoiseModelFactor5(const SharedNoiseModel &noiseModel, Key j1, Key j2, Key j3, Key j4, Key j5)
A non-templated config holding any types of Manifold-group elements.
NoiseModelFactor4< VALUE1, VALUE2, VALUE3, VALUE4 > This
void serialize(ARCHIVE &ar, const unsigned int)
void serialize(ARCHIVE &ar, const unsigned int)
~NoiseModelFactor4() override
~NoiseModelFactor2() override
NoiseModelFactor5< VALUE1, VALUE2, VALUE3, VALUE4, VALUE5 > This
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
NoiseModelFactor3(const SharedNoiseModel &noiseModel, Key j1, Key j2, Key j3)
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
NoiseModelFactor6(const SharedNoiseModel &noiseModel, Key j1, Key j2, Key j3, Key j4, Key j5, Key j6)
NoiseModelFactor2< VALUE1, VALUE2 > This
static const KeyFormatter DefaultKeyFormatter
NoiseModelFactor1< VALUE > This
const SharedNoiseModel & noiseModel() const
access to the noise model
void serialize(ARCHIVE &ar, const unsigned int)
virtual bool active(const Values &) const
~NoiseModelFactor3() override
~NoiseModelFactor() override
NoiseModelFactor6< VALUE1, VALUE2, VALUE3, VALUE4, VALUE5, VALUE6 > This
const Symbol key1('v', 1)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
const ValueType at(Key j) const
NoiseModelFactor(const SharedNoiseModel &noiseModel, const CONTAINER &keys)
NoiseModelFactor3< VALUE1, VALUE2, VALUE3 > This
virtual ~NonlinearFactor()
boost::shared_ptr< This > shared_ptr
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
~NoiseModelFactor5() override
boost::shared_ptr< This > shared_ptr
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
~NoiseModelFactor1() override
const mpreal dim(const mpreal &a, const mpreal &b, mp_rnd_t r=mpreal::get_default_rnd())
void serialize(ARCHIVE &ar, const unsigned int)
NoiseModelFactor2(const SharedNoiseModel &noiseModel, Key j1, Key j2)
SharedNoiseModel noiseModel_
~NoiseModelFactor6() override
Special class for optional Jacobian arguments.
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
virtual shared_ptr clone() const
NoiseModelFactor4(const SharedNoiseModel &noiseModel, Key j1, Key j2, Key j3, Key j4)
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
NoiseModelFactor(const SharedNoiseModel &noiseModel)
NonlinearFactor(const CONTAINER &keys)
void serialize(ARCHIVE &ar, const unsigned int)
std::uint64_t Key
Integer nonlinear key type.
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
noiseModel::Base::shared_ptr SharedNoiseModel
void serialize(ARCHIVE &ar, const unsigned int)
The base class for all factors.