gtsam 4.2
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
18#include <ostream>
19
22
23namespace gtsam {
24
30 class BiasedGPSFactor: public NoiseModelFactorN<Pose3, Point3> {
31
32 private:
33
34 typedef BiasedGPSFactor This;
36
37 Point3 measured_;
38
39 public:
40
41 // shorthand for a smart pointer to a factor
42 typedef boost::shared_ptr<BiasedGPSFactor> shared_ptr;
43
46
48 BiasedGPSFactor(Key posekey, Key biaskey, const Point3 measured,
49 const SharedNoiseModel& model) :
50 Base(model, posekey, biaskey), measured_(measured) {
51 }
52
53 ~BiasedGPSFactor() override {}
54
56
58 void print(const std::string& s, const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override {
59 std::cout << s << "BiasedGPSFactor("
60 << keyFormatter(this->key<1>()) << ","
61 << keyFormatter(this->key<2>()) << ")\n"
62 << " measured: " << measured_.transpose() << std::endl;
63 this->noiseModel_->print(" noise model: ");
64 }
65
67 bool equals(const NonlinearFactor& expected, double tol=1e-9) const override {
68 const This *e = dynamic_cast<const This*> (&expected);
69 return e != nullptr && Base::equals(*e, tol) && traits<Point3>::Equals(this->measured_, e->measured_, tol);
70 }
71
73
75 Vector evaluateError(const Pose3& pose, const Point3& bias,
76 boost::optional<Matrix&> H1 = boost::none, boost::optional<Matrix&> H2 =
77 boost::none) const override {
78
79 if (H1 || H2){
80 H1->resize(3,6); // jacobian wrt pose
81 (*H1) << Z_3x3, pose.rotation().matrix();
82 H2->resize(3,3); // jacobian wrt bias
83 (*H2) << I_3x3;
84 }
85 return pose.translation() + bias - measured_;
86 }
87
89 const Point3 measured() const {
90 return measured_;
91 }
92
93 private:
94
97 template<class ARCHIVE>
98 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
99 // NoiseModelFactor2 instead of NoiseModelFactorN for backward compatibility
100 ar & boost::serialization::make_nvp("NoiseModelFactor2",
101 boost::serialization::base_object<Base>(*this));
102 ar & BOOST_SERIALIZATION_NVP(measured_);
103 }
104 }; // \class BiasedGPSFactor
105
106}
3D Pose
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
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
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:36
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:724
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:37
const Point3 & translation(OptionalJacobian< 3, 6 > Hself=boost::none) const
get translation
Definition Pose3.cpp:308
const Rot3 & rotation(OptionalJacobian< 3, 6 > Hself=boost::none) const
get rotation
Definition Pose3.cpp:315
Matrix3 matrix() const
return 3*3 rotation matrix
Definition Rot3M.cpp:219
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
Nonlinear factor base class.
Definition NonlinearFactor.h:42
NoiseModelFactorN()
Definition NonlinearFactor.h:469
Key key() const
Definition NonlinearFactor.h:518
A class to model GPS measurements, including a bias term which models common-mode errors and that can...
Definition BiasedGPSFactor.h:30
BiasedGPSFactor()
default constructor - only use for serialization
Definition BiasedGPSFactor.h:45
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
equals
Definition BiasedGPSFactor.h:67
const Point3 measured() const
return the measured
Definition BiasedGPSFactor.h:89
BiasedGPSFactor(Key posekey, Key biaskey, const Point3 measured, const SharedNoiseModel &model)
Constructor.
Definition BiasedGPSFactor.h:48
boost::shared_ptr< BiasedGPSFactor > shared_ptr
The measurement.
Definition BiasedGPSFactor.h:42
Vector evaluateError(const Pose3 &pose, const Point3 &bias, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const override
implement functions needed to derive from Factor
Definition BiasedGPSFactor.h:75
friend class boost::serialization::access
Serialization function.
Definition BiasedGPSFactor.h:96
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
implement functions needed for Testable
Definition BiasedGPSFactor.h:58