gtsam
Loading...
Searching...
No Matches
BiasedGPSFactor.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
16#pragma once
17
22
23#include <ostream>
24
25namespace gtsam {
26
33 : public NoiseModelFactorT<Vector3, Pose3, Point3> {
34
35 private:
36
37 typedef BiasedGPSFactor This;
39
40 Point3 measured_;
41
42 public:
43
44 // Provide access to the Matrix& version of evaluateError:
46
47 // shorthand for a smart pointer to a factor
48 typedef std::shared_ptr<BiasedGPSFactor> shared_ptr;
49
52
54 BiasedGPSFactor(Key posekey, Key biaskey, const Point3 measured,
55 const SharedNoiseModel& model) :
56 Base(model, posekey, biaskey), measured_(measured) {
57 }
58
59 ~BiasedGPSFactor() override {}
60
62
64 void print(const std::string& s, const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override {
65 std::cout << s << "BiasedGPSFactor("
66 << keyFormatter(this->key<1>()) << ","
67 << keyFormatter(this->key<2>()) << ")\n"
68 << " measured: " << measured_.transpose() << std::endl;
69 this->noiseModel_->print(" noise model: ");
70 }
71
73 bool equals(const NonlinearFactor& expected, double tol=1e-9) const override {
74 const This *e = dynamic_cast<const This*> (&expected);
75 return e != nullptr && Base::equals(*e, tol) && traits<Point3>::Equals(this->measured_, e->measured_, tol);
76 }
77
79
81 Vector3 evaluateError(const Pose3& pose, const Point3& bias,
83 OptionalMatrixType H2) const override {
84
85 if (H1 || H2){
86 H1->resize(3,6); // jacobian wrt pose
87 (*H1) << Z_3x3, pose.rotation().matrix();
88 H2->resize(3,3); // jacobian wrt bias
89 *H2 = I_3x3;
90 }
91 return pose.translation() + bias - measured_;
92 }
93
95 const Point3 measured() const {
96 return measured_;
97 }
98
99 private:
100
101#if GTSAM_ENABLE_BOOST_SERIALIZATION
103 friend class boost::serialization::access;
104 template<class ARCHIVE>
105 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
106 // NoiseModelFactor2 instead of NoiseModelFactorN for backward compatibility
107 ar & boost::serialization::make_nvp("NoiseModelFactor2",
108 boost::serialization::base_object<Base>(*this));
109 ar & BOOST_SERIALIZATION_NVP(measured_);
110 }
111#endif
112 }; // \class BiasedGPSFactor
113
114}
Macros for Matrix constants to avoid excessive template instantiation.
3D Pose manifold SO(3) x R^3 and group SE(3)
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
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
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
const Rot3 & rotation(ComponentJacobian H={}) const
Rotation component.
Definition ExtendedPose3-inl.h:76
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
const Point3 & translation(OptionalJacobian< 3, 6 > Hself={}) const
get translation
Definition Pose3.cpp:158
Matrix3 matrix() const
return 3*3 rotation matrix
Definition Rot3M.cpp:261
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector3 evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition NoiseModelFactorN.h:307
Nonlinear factor base class.
Definition NonlinearFactor.h:70
A class to model GPS measurements, including a bias term which models common-mode errors and that can...
Definition BiasedGPSFactor.h:33
BiasedGPSFactor()
default constructor - only use for serialization
Definition BiasedGPSFactor.h:51
Vector3 evaluateError(const Pose3 &pose, const Point3 &bias, OptionalMatrixType H1, OptionalMatrixType H2) const override
implement functions needed to derive from Factor
Definition BiasedGPSFactor.h:81
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
equals
Definition BiasedGPSFactor.h:73
const Point3 measured() const
return the measured
Definition BiasedGPSFactor.h:95
BiasedGPSFactor(Key posekey, Key biaskey, const Point3 measured, const SharedNoiseModel &model)
Constructor.
Definition BiasedGPSFactor.h:54
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
implement functions needed for Testable
Definition BiasedGPSFactor.h:64