58 template <
typename R,
typename T>
65 std::function<R(T, OptionalMatrixType)> func_;
84 :
Base(model, key), measured_(z), noiseModel_(model), func_(func) {}
89 NonlinearFactor::shared_ptr
clone()
const override {
95 R x = func_(params, H);
103 const std::string &s =
"",
104 const KeyFormatter &keyFormatter = DefaultKeyFormatter)
const override {
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),
198 NonlinearFactor::shared_ptr
clone()
const override {
203 Vector evaluateError(
204 const T1 ¶ms1,
const T2 ¶ms2,
206 R x = func_(params1, params2, H1, H2);
214 const std::string &s =
"",
215 const KeyFormatter &keyFormatter = DefaultKeyFormatter)
const override {
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>
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition: FunctorizedFactor.h:213
Definition: NonlinearFactor.h:431
double error(const Values &c) const override
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition: FunctorizedFactor.h:102
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
bool equals(const NonlinearFactor &other, double tol=1e-9) const override
Definition: FunctorizedFactor.h:113
NonlinearFactor::shared_ptr clone() const override
Definition: FunctorizedFactor.h:89
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)
Definition: FunctorizedFactor.h:188
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
Definition: Testable.h:152
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition: NonlinearFactor.h:582
Definition: NonlinearFactor.h:68
FunctorizedFactor(Key key, const R &z, const SharedNoiseModel &model, const std::function< R(T, OptionalMatrixType)> func)
Definition: FunctorizedFactor.h:82
Definition: FunctorizedFactor.h:59
FunctorizedFactor2< R, T1, T2 > MakeFunctorizedFactor2(Key key1, Key key2, const R &z, const SharedNoiseModel &model, const FUNC func)
Definition: FunctorizedFactor.h:260
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
bool equals(const NonlinearFactor &other, double tol=1e-9) const override
Definition: FunctorizedFactor.h:225
FunctorizedFactor2()
Definition: FunctorizedFactor.h:179
FunctorizedFactor< R, T > MakeFunctorizedFactor(Key key, const R &z, const SharedNoiseModel &model, const FUNC func)
Definition: FunctorizedFactor.h:148
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
Definition: chartTesting.h:28
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: FunctorizedFactor.h:164
Non-linear factor base classes.
FunctorizedFactor()
Definition: FunctorizedFactor.h:73
NonlinearFactor::shared_ptr clone() const override
Definition: FunctorizedFactor.h:198
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741