29template <
typename A1,
typename A2>
37template <
typename A1,
typename A2 = A1,
typename T =
double>
53 : Base(model, key1, key2), measured_(
measured) {}
56 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
57 return std::static_pointer_cast<gtsam::NonlinearFactor>(
58 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
62 const T&
measured()
const {
return measured_; }
73 void print(
const std::string& s =
"",
75 std::cout << s <<
"RangeFactor" << std::endl;
82 const This* p =
dynamic_cast<const This*
>(&f);
88#if GTSAM_ENABLE_BOOST_SERIALIZATION
89 friend class boost::serialization::access;
91 template <
class ARCHIVE>
92 void serialize(ARCHIVE& ar,
const unsigned int ) {
93 ar& boost::serialization::make_nvp(
94 "NoiseModelFactor2", boost::serialization::base_object<Base>(*
this));
95 ar& BOOST_SERIALIZATION_NVP(measured_);
101template <
typename A1,
typename A2,
typename T>
103 :
public Testable<RangeFactor<A1, A2, T> > {};
109template <
typename A1,
typename A2 = A1,
128 const A1& body_T_sensor)
129 : Base(model, key1, key2),
131 body_T_sensor_(body_T_sensor) {}
137 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
138 return std::static_pointer_cast<gtsam::NonlinearFactor>(
139 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
150 const A1 nav_T_sensor =
151 a1.compose(body_T_sensor_, H1 ? &HposeCompose :
nullptr);
152 const T predicted =
Range<A1, A2>()(nav_T_sensor, a2, H1, H2);
153 if (H1) *H1 *= HposeCompose;
166 const std::string& s =
"",
168 std::cout << s <<
"RangeFactorWithTransform" << std::endl;
169 this->body_T_sensor_.print(
" sensor pose in body frame: ");
176 const This* p =
dynamic_cast<const This*
>(&f);
183#if GTSAM_ENABLE_BOOST_SERIALIZATION
184 friend class boost::serialization::access;
186 template <
typename ARCHIVE>
187 void serialize(ARCHIVE& ar,
const unsigned int ) {
188 ar& boost::serialization::make_nvp(
189 "NoiseModelFactor2", boost::serialization::base_object<Base>(*
this));
190 ar& BOOST_SERIALIZATION_NVP(measured_);
191 ar& BOOST_SERIALIZATION_NVP(body_T_sensor_);
197template <
typename A1,
typename A2,
typename T>
199 :
public Testable<RangeFactorWithTransform<A1, A2, T> > {};
206template <
typename A1,
typename A2 = A1,
225 const A1& body_T_sensor)
228 body_T_sensor_(body_T_sensor) {}
234 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
235 return std::static_pointer_cast<gtsam::NonlinearFactor>(
236 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
248 const A1 nav_T_sensor =
249 a1.compose(body_T_sensor_, H1 ? &HposeCompose :
nullptr);
250 const T predictedRange =
Range<A1, A2>()(nav_T_sensor, a2, H1, H2);
251 if (H1) *H1 *= HposeCompose;
253 if constexpr (std::is_same_v<T, double>) {
254 *H3 = Matrix1::Identity();
257 *H3 = Matrix::Identity(dimension, dimension);
265 Matrix& H2, Matrix& H3)
const {
271 const std::string& s =
"",
273 std::cout << s <<
"RangeFactorWithTransformBias" << std::endl;
274 body_T_sensor_.print(
" sensor pose in body frame: ");
281 const This* p =
dynamic_cast<const This*
>(&f);
288#if GTSAM_ENABLE_BOOST_SERIALIZATION
289 friend class boost::serialization::access;
291 template <
typename ARCHIVE>
292 void serialize(ARCHIVE& ar,
const unsigned int ) {
293 ar& boost::serialization::make_nvp(
294 "NoiseModelFactor3", boost::serialization::base_object<Base>(*
this));
295 ar& BOOST_SERIALIZATION_NVP(measured_);
296 ar& BOOST_SERIALIZATION_NVP(body_T_sensor_);
302template <
typename A1,
typename A2,
typename T>
304 :
public Testable<RangeFactorWithTransformBias<A1, A2, T> > {};
Arbitrary-arity Jacobian factor with compile-time block dimensions.
Base class for noise model factors with N variables.
#define OptionalNone
These typedefs and aliases will help with making the evaluateError interface independent of boost TOD...
Definition NonlinearFactor.h:51
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
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
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
All noise models live in the noiseModel namespace.
Definition LossFunctions.cpp:33
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
Definition BearingRange.h:42
virtual void print(const std::string &s="Factor", const KeyFormatter &formatter=DefaultKeyFormatter) const
print
Definition Factor.cpp:29
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
Nonlinear factor base class.
Definition NonlinearFactor.h:70
Binary factor for a range measurement Works for any two types A1,A2 for which the functor Range<A1,...
Definition RangeFactor.h:39
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition RangeFactor.h:56
bool equals(const NonlinearFactor &f, double tol) const override
Check equality up to a tolerance.
Definition RangeFactor.h:81
const T & measured() const
Definition RangeFactor.h:62
ErrorVector evaluateError(const A1 &a1, const A2 &a2, OptionalMatrixType H1=OptionalNone, OptionalMatrixType H2=OptionalNone) const override
Evaluate the unwhitened range error and optional Jacobians.
Definition RangeFactor.h:65
void print(const std::string &s="", const KeyFormatter &kf=DefaultKeyFormatter) const override
print
Definition RangeFactor.h:73
RangeFactor(Key key1, Key key2, T measured, const SharedNoiseModel &model)
Construct from keys, a range measurement, and a noise model.
Definition RangeFactor.h:52
RangeFactor()=default
default constructor
Binary factor for a range measurement, with a transform applied.
Definition RangeFactor.h:112
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition RangeFactor.h:137
RangeFactorWithTransform()=default
Default constructor.
RangeFactorWithTransform(Key key1, Key key2, T measured, const SharedNoiseModel &model, const A1 &body_T_sensor)
Construct from keys, a range measurement, a noise model, and transform.
Definition RangeFactor.h:126
ErrorVector evaluateError(const A1 &a1, const A2 &a2, OptionalMatrixType H1=OptionalNone, OptionalMatrixType H2=OptionalNone) const override
Evaluate the unwhitened range error and optional Jacobians.
Definition RangeFactor.h:146
~RangeFactorWithTransform() override
Destroy this factor.
Definition RangeFactor.h:134
bool equals(const NonlinearFactor &f, double tol) const override
Check equality up to a tolerance.
Definition RangeFactor.h:175
const T & measured() const
Definition RangeFactor.h:143
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print contents
Definition RangeFactor.h:165
Ternary factor for a range measurement with a fixed sensor transform and an additive bias term.
Definition RangeFactor.h:209
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition RangeFactor.h:234
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Print contents.
Definition RangeFactor.h:270
ErrorVector evaluateError(const A1 &a1, const A2 &a2, const T &bias, OptionalMatrixType H1=OptionalNone, OptionalMatrixType H2=OptionalNone, OptionalMatrixType H3=OptionalNone) const override
Evaluate the unwhitened range error and optional Jacobians.
Definition RangeFactor.h:243
RangeFactorWithTransformBias()=default
Default constructor.
RangeFactorWithTransformBias(Key key1, Key key2, Key key3, T measured, const SharedNoiseModel &noiseModel, const A1 &body_T_sensor)
Construct from keys, a range measurement, a noise model, and transform.
Definition RangeFactor.h:223
~RangeFactorWithTransformBias() override=default
Destroy this factor.
Vector evaluateError(const A1 &a1, const A2 &a2, const T &bias, Matrix &H1, Matrix &H2, Matrix &H3) const
Matrix-reference overload for evaluateError.
Definition RangeFactor.h:264
const T & measured() const
Definition RangeFactor.h:240
bool equals(const NonlinearFactor &f, double tol) const override
Check equality up to a tolerance.
Definition RangeFactor.h:280