gtsam
Loading...
Searching...
No Matches
GPSFactor.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
18#pragma once
19
24
25namespace gtsam {
26
38class GTSAM_EXPORT GPSFactor: public NoiseModelFactorN<Pose3> {
39
40private:
41
42 typedef NoiseModelFactorN<Pose3> Base;
43
44 Point3 nT_;
45
46public:
47
48 // Provide access to the Matrix& version of evaluateError:
50
52 typedef std::shared_ptr<GPSFactor> shared_ptr;
53
55 typedef GPSFactor This;
56
58 GPSFactor(): nT_(0, 0, 0) {}
59
60 ~GPSFactor() override {}
61
69 GPSFactor(Key key, const Point3& gpsIn, const SharedNoiseModel& model) :
70 Base(model, key), nT_(gpsIn) {
71 }
72
74 gtsam::NonlinearFactor::shared_ptr clone() const override {
75 return std::static_pointer_cast<gtsam::NonlinearFactor>(
76 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
77 }
78
80 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
81 DefaultKeyFormatter) const override;
82
84 bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
85
87 Vector evaluateError(const Pose3& nTb, OptionalMatrixType H) const override;
88
90 inline const Point3 & measurementIn() const {
91 return nT_;
92 }
93
99 static std::pair<Pose3, Vector3> EstimateState(double t1, const Point3& NED1,
100 double t2, const Point3& NED2, double timestamp);
101
102private:
103
104#if GTSAM_ENABLE_BOOST_SERIALIZATION
106 friend class boost::serialization::access;
107 template<class ARCHIVE>
108 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
109 // NoiseModelFactor1 instead of NoiseModelFactorN for backward compatibility
110 ar
111 & boost::serialization::make_nvp("NoiseModelFactor1",
112 boost::serialization::base_object<Base>(*this));
113 ar & BOOST_SERIALIZATION_NVP(nT_);
114 }
115#endif
116};
117
125class GTSAM_EXPORT GPSFactorArm: public NoiseModelFactorN<Pose3> {
126
127private:
128
129 typedef NoiseModelFactorN<Pose3> Base;
130
131 Point3 nT_;
132 Point3 bL_;
134
135public:
136
137 // Provide access to the Matrix& version of evaluateError:
139
141 typedef std::shared_ptr<GPSFactorArm> shared_ptr;
142
145
147 GPSFactorArm():nT_(0, 0, 0), bL_(0, 0, 0) {}
148
149 ~GPSFactorArm() override {}
150
157 GPSFactorArm(Key key, const Point3& gpsIn, const Point3& leverArm, const SharedNoiseModel& model) :
158 Base(model, key), nT_(gpsIn), bL_(leverArm) {
159 }
160
162 gtsam::NonlinearFactor::shared_ptr clone() const override {
163 return std::static_pointer_cast<gtsam::NonlinearFactor>(
164 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
165 }
166
168 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
169 DefaultKeyFormatter) const override;
170
172 bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
173
175 Vector evaluateError(const Pose3& nTb, OptionalMatrixType H) const override;
176
178 inline const Point3 & measurementIn() const {
179 return nT_;
180 }
181
183 inline const Point3 & leverArm() const {
184 return bL_;
185 }
186
187private:
188
189#if GTSAM_ENABLE_BOOST_SERIALIZATION
191 friend class boost::serialization::access;
192 template<class ARCHIVE>
193 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
194 // NoiseModelFactor1 instead of NoiseModelFactorN for valid XML tag names
195 ar
196 & boost::serialization::make_nvp("NoiseModelFactor1",
197 boost::serialization::base_object<Base>(*this));
198 ar & BOOST_SERIALIZATION_NVP(nT_);
199 ar & BOOST_SERIALIZATION_NVP(bL_);
200 }
201#endif
202};
203
205template <>
206struct traits<GPSFactorArm> : public Testable<GPSFactorArm> {};
207
216class GTSAM_EXPORT GPSFactorArmCalib
217 : public NoiseModelFactorT<Vector3, Pose3, Point3> {
218
219private:
220
222
223 Point3 nT_;
224
225public:
226
227 // Provide access to the Matrix& version of evaluateError:
229
231 typedef std::shared_ptr<GPSFactorArmCalib> shared_ptr;
232
235
237 GPSFactorArmCalib() : nT_(0, 0, 0) {}
238
239 ~GPSFactorArmCalib() override {}
240
248 GPSFactorArmCalib(Key key1, Key key2, const Point3& gpsIn, const SharedNoiseModel& model) :
249 Base(model, key1, key2), nT_(gpsIn) {
250 }
251
253 gtsam::NonlinearFactor::shared_ptr clone() const override {
254 return std::static_pointer_cast<gtsam::NonlinearFactor>(
255 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
256 }
257
259 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
260 DefaultKeyFormatter) const override;
261
263 bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
264
266 Vector3 evaluateError(const Pose3& nTb, const Point3& bL,
268 OptionalMatrixType H2) const override;
269
271 inline const Point3 & measurementIn() const {
272 return nT_;
273 }
274
275private:
276
277#if GTSAM_ENABLE_BOOST_SERIALIZATION
279 friend class boost::serialization::access;
280 template<class ARCHIVE>
281 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
282 // NoiseModelFactor2 instead of NoiseModelFactorN for valid XML tag names
283 ar
284 & boost::serialization::make_nvp("NoiseModelFactor2",
285 boost::serialization::base_object<Base>(*this));
286 ar & BOOST_SERIALIZATION_NVP(nT_);
287 }
288#endif
289};
290
292template <>
293struct traits<GPSFactorArmCalib> : public Testable<GPSFactorArmCalib> {};
294
301class GTSAM_EXPORT GPSFactor2: public NoiseModelFactorN<NavState> {
302
303private:
304
305 typedef NoiseModelFactorN<NavState> Base;
306
307 Point3 nT_;
308
309public:
310
311 // Provide access to the Matrix& version of evaluateError:
313
315 typedef std::shared_ptr<GPSFactor2> shared_ptr;
316
319
321 GPSFactor2():nT_(0, 0, 0) {}
322
323 ~GPSFactor2() override {}
324
330 GPSFactor2(Key key, const Point3& gpsIn, const SharedNoiseModel& model) :
331 Base(model, key), nT_(gpsIn) {
332 }
333
335 gtsam::NonlinearFactor::shared_ptr clone() const override {
336 return std::static_pointer_cast<gtsam::NonlinearFactor>(
337 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
338 }
339
341 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
342 DefaultKeyFormatter) const override;
343
345 bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
346
348 Vector evaluateError(const NavState& nTb, OptionalMatrixType H) const override;
349
351 inline const Point3 & measurementIn() const {
352 return nT_;
353 }
354
355private:
356
357#if GTSAM_ENABLE_BOOST_SERIALIZATION
359 friend class boost::serialization::access;
360 template<class ARCHIVE>
361 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
362 // NoiseModelFactor1 instead of NoiseModelFactorN for backward compatibility
363 ar
364 & boost::serialization::make_nvp("NoiseModelFactor1",
365 boost::serialization::base_object<Base>(*this));
366 ar & BOOST_SERIALIZATION_NVP(nT_);
367 }
368#endif
369};
370
378class GTSAM_EXPORT GPSFactor2Arm: public NoiseModelFactorN<NavState> {
379
380private:
381
382 typedef NoiseModelFactorN<NavState> Base;
383
384 Point3 nT_;
385 Point3 bL_;
387
388public:
389
390 // Provide access to the Matrix& version of evaluateError:
392
394 typedef std::shared_ptr<GPSFactor2Arm> shared_ptr;
395
398
400 GPSFactor2Arm():nT_(0, 0, 0), bL_(0, 0, 0) {}
401
402 ~GPSFactor2Arm() override {}
403
410 GPSFactor2Arm(Key key, const Point3& gpsIn, const Point3& leverArm, const SharedNoiseModel& model) :
411 Base(model, key), nT_(gpsIn), bL_(leverArm) {
412 }
413
415 gtsam::NonlinearFactor::shared_ptr clone() const override {
416 return std::static_pointer_cast<gtsam::NonlinearFactor>(
417 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
418 }
419
421 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
422 DefaultKeyFormatter) const override;
423
425 bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
426
428 Vector evaluateError(const NavState& nTb, OptionalMatrixType H) const override;
429
431 inline const Point3 & measurementIn() const {
432 return nT_;
433 }
434
436 inline const Point3 & leverArm() const {
437 return bL_;
438 }
439
440private:
441
442#if GTSAM_ENABLE_BOOST_SERIALIZATION
444 friend class boost::serialization::access;
445 template<class ARCHIVE>
446 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
447 // NoiseModelFactor1 instead of NoiseModelFactorN for valid XML tag names
448 ar
449 & boost::serialization::make_nvp("NoiseModelFactor1",
450 boost::serialization::base_object<Base>(*this));
451 ar & BOOST_SERIALIZATION_NVP(nT_);
452 ar & BOOST_SERIALIZATION_NVP(bL_);
453 }
454#endif
455};
456
458template <>
459struct traits<GPSFactor2Arm> : public Testable<GPSFactor2Arm> {};
460
468class GTSAM_EXPORT GPSFactor2ArmCalib
469 : public NoiseModelFactorT<Vector3, NavState, Point3> {
470
471private:
472
474
475 Point3 nT_;
476
477public:
478
479 // Provide access to the Matrix& version of evaluateError:
481
483 typedef std::shared_ptr<GPSFactor2ArmCalib> shared_ptr;
484
487
489 GPSFactor2ArmCalib():nT_(0, 0, 0) {}
490
491 ~GPSFactor2ArmCalib() override {}
492
499 GPSFactor2ArmCalib(Key key1, Key key2, const Point3& gpsIn, const SharedNoiseModel& model) :
500 Base(model, key1, key2), nT_(gpsIn) {
501 }
502
504 gtsam::NonlinearFactor::shared_ptr clone() const override {
505 return std::static_pointer_cast<gtsam::NonlinearFactor>(
506 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
507 }
508
510 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
511 DefaultKeyFormatter) const override;
512
514 bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
515
517 Vector3 evaluateError(const NavState& nTb, const Point3& bL,
519 OptionalMatrixType H2) const override;
520
522 inline const Point3 & measurementIn() const {
523 return nT_;
524 }
525
526private:
527
528#if GTSAM_ENABLE_BOOST_SERIALIZATION
530 friend class boost::serialization::access;
531 template<class ARCHIVE>
532 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
533 // NoiseModelFactor2 instead of NoiseModelFactorN for valid XML tag names
534 ar
535 & boost::serialization::make_nvp("NoiseModelFactor2",
536 boost::serialization::base_object<Base>(*this));
537 ar & BOOST_SERIALIZATION_NVP(nT_);
538 }
539#endif
540};
541
543template <>
544struct traits<GPSFactor2ArmCalib> : public Testable<GPSFactor2ArmCalib> {};
545
546}
3D Pose manifold SO(3) x R^3 and group SE(3)
Navigation state composing of attitude, position, and velocity.
Base class for noise model factors with N variables.
Non-linear factor base classes.
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
NoiseModelFactorT< Vector, ValueTypes... > NoiseModelFactorN
Noise model factor with N value types and dynamic-sized error vector.
Definition NoiseModelFactorN.h:561
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition Point3.h:38
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Template to create a binary predicate.
Definition Testable.h:112
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
Prior on position in a Cartesian frame.
Definition GPSFactor.h:38
GPSFactor This
Typedef to this class.
Definition GPSFactor.h:55
GPSFactor()
default constructor - only use for serialization
Definition GPSFactor.h:58
std::shared_ptr< GPSFactor > shared_ptr
shorthand for a smart pointer to a factor
Definition GPSFactor.h:52
const Point3 & measurementIn() const
return the measurement, in the navigation frame
Definition GPSFactor.h:90
GPSFactor(Key key, const Point3 &gpsIn, const SharedNoiseModel &model)
Constructor from a measurement in a Cartesian frame.
Definition GPSFactor.h:69
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition GPSFactor.h:74
Version of GPSFactor (for Pose3) with lever arm between GPS and Body frame.
Definition GPSFactor.h:125
std::shared_ptr< GPSFactorArm > shared_ptr
shorthand for a smart pointer to a factor
Definition GPSFactor.h:141
GPSFactorArm This
Typedef to this class.
Definition GPSFactor.h:144
GPSFactorArm()
default constructor - only use for serialization
Definition GPSFactor.h:147
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition GPSFactor.h:162
GPSFactorArm(Key key, const Point3 &gpsIn, const Point3 &leverArm, const SharedNoiseModel &model)
Constructor from a measurement in a Cartesian frame.
Definition GPSFactor.h:157
const Point3 & measurementIn() const
return the measurement, in the navigation frame
Definition GPSFactor.h:178
const Point3 & leverArm() const
return the lever arm, a position in the body frame
Definition GPSFactor.h:183
Version of GPSFactorArm (for Pose3) with unknown lever arm between GPS and Body frame.
Definition GPSFactor.h:217
GPSFactorArmCalib()
default constructor - only use for serialization
Definition GPSFactor.h:237
std::shared_ptr< GPSFactorArmCalib > shared_ptr
shorthand for a smart pointer to a factor
Definition GPSFactor.h:231
GPSFactorArmCalib This
Typedef to this class.
Definition GPSFactor.h:234
const Point3 & measurementIn() const
return the measurement, in the navigation frame
Definition GPSFactor.h:271
GPSFactorArmCalib(Key key1, Key key2, const Point3 &gpsIn, const SharedNoiseModel &model)
Constructor from a measurement in a Cartesian frame.
Definition GPSFactor.h:248
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition GPSFactor.h:253
Version of GPSFactor for NavState, assuming zero lever arm between body frame and GPS.
Definition GPSFactor.h:301
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition GPSFactor.h:335
GPSFactor2 This
Typedef to this class.
Definition GPSFactor.h:318
GPSFactor2(Key key, const Point3 &gpsIn, const SharedNoiseModel &model)
Constructor from a measurement in a Cartesian frame.
Definition GPSFactor.h:330
std::shared_ptr< GPSFactor2 > shared_ptr
shorthand for a smart pointer to a factor
Definition GPSFactor.h:315
GPSFactor2()
default constructor - only use for serialization
Definition GPSFactor.h:321
const Point3 & measurementIn() const
return the measurement, in the navigation frame
Definition GPSFactor.h:351
Version of GPSFactor2 with lever arm between GPS and Body frame.
Definition GPSFactor.h:378
GPSFactor2Arm(Key key, const Point3 &gpsIn, const Point3 &leverArm, const SharedNoiseModel &model)
Constructor from a measurement in a Cartesian frame.
Definition GPSFactor.h:410
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition GPSFactor.h:415
const Point3 & leverArm() const
return the lever arm, a position in the body frame
Definition GPSFactor.h:436
GPSFactor2Arm()
default constructor - only use for serialization
Definition GPSFactor.h:400
std::shared_ptr< GPSFactor2Arm > shared_ptr
shorthand for a smart pointer to a factor
Definition GPSFactor.h:394
const Point3 & measurementIn() const
return the measurement, in the navigation frame
Definition GPSFactor.h:431
GPSFactor2Arm This
Typedef to this class.
Definition GPSFactor.h:397
Version of GPSFactor2Arm for an unknown lever arm between GPS and Body frame.
Definition GPSFactor.h:469
const Point3 & measurementIn() const
return the measurement, in the navigation frame
Definition GPSFactor.h:522
GPSFactor2ArmCalib()
default constructor - only use for serialization
Definition GPSFactor.h:489
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition GPSFactor.h:504
GPSFactor2ArmCalib This
Typedef to this class.
Definition GPSFactor.h:486
GPSFactor2ArmCalib(Key key1, Key key2, const Point3 &gpsIn, const SharedNoiseModel &model)
Constructor from a measurement in a Cartesian frame.
Definition GPSFactor.h:499
std::shared_ptr< GPSFactor2ArmCalib > shared_ptr
shorthand for a smart pointer to a factor
Definition GPSFactor.h:483
Navigation state: Pose (rotation, translation) + velocity Following Barrau20icra, this class belongs ...
Definition NavState.h:45
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition NoiseModelFactorN.h:307
Nonlinear factor base class.
Definition NonlinearFactor.h:70