58 template <
typename R,
typename T>
65 std::function<R(T, OptionalMatrixType)>
func_;
84 :
Base(model, key), measured_(z), noiseModel_(model), func_(
func) {}
103 const std::string &
s =
"",
106 std::cout <<
s << (
s !=
"" ?
" " :
"") <<
"FunctorizedFactor(" 107 << keyFormatter(this->
key1()) <<
")" << std::endl;
109 std::cout <<
" noise model sigmas: " << noiseModel_->sigmas().transpose()
122 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 124 friend class boost::serialization::access;
125 template <
class ARCHIVE>
126 void serialize(ARCHIVE &ar,
const unsigned int ) {
128 ar &boost::serialization::make_nvp(
129 "NoiseModelFactor1", boost::serialization::base_object<Base>(*
this));
130 ar &BOOST_SERIALIZATION_NVP(measured_);
131 ar &BOOST_SERIALIZATION_NVP(func_);
137 template <
typename R,
typename T>
139 :
public Testable<FunctorizedFactor<R, T>> {};
147 template <
typename T,
typename R,
typename FUNC>
163 template <
typename R,
typename T1,
typename T2>
170 using FunctionType = std::function<R(T1, T2, OptionalMatrixType, OptionalMatrixType)>;
190 :
Base(model, key1, key2),
204 const T1 ¶ms1,
const T2 ¶ms2,
206 R x =
func_(params1, params2, H1, H2);
214 const std::string &
s =
"",
217 std::cout <<
s << (
s !=
"" ?
" " :
"") <<
"FunctorizedFactor2(" 218 << keyFormatter(this->
key1()) <<
", " 219 << keyFormatter(this->
key2()) <<
")" << std::endl;
221 std::cout <<
" noise model sigmas: " << noiseModel_->sigmas().transpose()
234 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 236 friend class boost::serialization::access;
237 template <
class ARCHIVE>
238 void serialize(ARCHIVE &ar,
const unsigned int ) {
240 ar &boost::serialization::make_nvp(
241 "NoiseModelFactor2", boost::serialization::base_object<Base>(*
this));
242 ar &BOOST_SERIALIZATION_NVP(measured_);
243 ar &BOOST_SERIALIZATION_NVP(func_);
249 template <
typename R,
typename T1,
typename T2>
251 :
public Testable<FunctorizedFactor2<R, T1, T2>> {};
259 template <
typename T1,
typename T2,
typename R,
typename FUNC>
R measured_
value that is compared with functor return value
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
R measured_
value that is compared with functor return value
bool equals(const NonlinearFactor &other, double tol=1e-9) const override
NonlinearFactor::shared_ptr clone() const override
Concept check for values that can be used in unit tests.
FunctorizedFactor2(Key key1, Key key2, const R &z, const SharedNoiseModel &model, const FunctionType func)
std::string serialize(const T &input)
serializes to a string
noiseModel::Diagonal::shared_ptr model
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
std::function< R(T1, T2, OptionalMatrixType, OptionalMatrixType)> FunctionType
Rot2 R(Rot2::fromAngle(0.1))
FunctionType func_
functor instance
FunctorizedFactor(Key key, const R &z, const SharedNoiseModel &model, const std::function< R(T, OptionalMatrixType)> func)
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
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
static const KeyFormatter DefaultKeyFormatter
FunctorizedFactor2< R, T1, T2 > MakeFunctorizedFactor2(Key key1, Key key2, const R &z, const SharedNoiseModel &model, const FUNC func)
static const SmartProjectionParams params
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Matrix * OptionalMatrixType
bool equals(const NonlinearFactor &other, double tol=1e-9) const override
Vector evaluateError(const T1 ¶ms1, const T2 ¶ms2, OptionalMatrixType H1, OptionalMatrixType H2) const override
std::function< R(T, OptionalMatrixType)> func_
functor instance
Array< double, 1, 3 > e(1./3., 0.5, 2.)
FunctorizedFactor< R, T > MakeFunctorizedFactor(Key key, const R &z, const SharedNoiseModel &model, const FUNC func)
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
double error(const Values &c) const override
Non-linear factor base classes.
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
Vector evaluateError(const T ¶ms, OptionalMatrixType H) const override
std::shared_ptr< This > shared_ptr
SharedNoiseModel noiseModel_
noise model
~FunctorizedFactor() override
NonlinearFactor::shared_ptr clone() 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
std::uint64_t Key
Integer nonlinear key type.
void Print(const CONTAINER &keys, const string &s, const KeyFormatter &keyFormatter)
noiseModel::Base::shared_ptr SharedNoiseModel
SharedNoiseModel noiseModel_
noise model
~FunctorizedFactor2() override