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 
20 #include <gtsam/geometry/Pose3.h>
22 
23 namespace gtsam {
24 
30  class BiasedGPSFactor: public NoiseModelFactorN<Pose3, Point3> {
31 
32  private:
33 
36 
39  public:
40 
41  // Provide access to the Matrix& version of evaluateError:
42  using Base::evaluateError;
43 
44  // shorthand for a smart pointer to a factor
45  typedef std::shared_ptr<BiasedGPSFactor> shared_ptr;
46 
49 
51  BiasedGPSFactor(Key posekey, Key biaskey, const Point3 measured,
52  const SharedNoiseModel& model) :
53  Base(model, posekey, biaskey), measured_(measured) {
54  }
55 
56  ~BiasedGPSFactor() override {}
57 
61  void print(const std::string& s, const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override {
62  std::cout << s << "BiasedGPSFactor("
63  << keyFormatter(this->key<1>()) << ","
64  << keyFormatter(this->key<2>()) << ")\n"
65  << " measured: " << measured_.transpose() << std::endl;
66  this->noiseModel_->print(" noise model: ");
67  }
68 
70  bool equals(const NonlinearFactor& expected, double tol=1e-9) const override {
71  const This *e = dynamic_cast<const This*> (&expected);
72  return e != nullptr && Base::equals(*e, tol) && traits<Point3>::Equals(this->measured_, e->measured_, tol);
73  }
74 
79  OptionalMatrixType H1, OptionalMatrixType H2) const override {
80 
81  if (H1 || H2){
82  H1->resize(3,6); // jacobian wrt pose
83  (*H1) << Z_3x3, pose.rotation().matrix();
84  H2->resize(3,3); // jacobian wrt bias
85  (*H2) << I_3x3;
86  }
87  return pose.translation() + bias - measured_;
88  }
89 
91  const Point3 measured() const {
92  return measured_;
93  }
94 
95  private:
96 
97 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
98 
99  friend class boost::serialization::access;
100  template<class ARCHIVE>
101  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
102  // NoiseModelFactor2 instead of NoiseModelFactorN for backward compatibility
103  ar & boost::serialization::make_nvp("NoiseModelFactor2",
104  boost::serialization::base_object<Base>(*this));
105  ar & BOOST_SERIALIZATION_NVP(measured_);
106  }
107 #endif
108  }; // \class BiasedGPSFactor
109 
110 }
gtsam::BiasedGPSFactor::BiasedGPSFactor
BiasedGPSFactor()
Definition: BiasedGPSFactor.h:48
pose
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
gtsam::BiasedGPSFactor::measured
const Point3 measured() const
Definition: BiasedGPSFactor.h:91
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::NoiseModelFactorN< Pose3, Point3 >::evaluateError
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
biased_x_rotation::bias
const Vector3 bias(1, 2, 3)
gtsam::BiasedGPSFactor::shared_ptr
std::shared_ptr< BiasedGPSFactor > shared_ptr
Definition: BiasedGPSFactor.h:45
gtsam::Factor
Definition: Factor.h:70
gtsam::NoiseModelFactor::noiseModel_
SharedNoiseModel noiseModel_
Definition: NonlinearFactor.h:205
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
gtsam::BiasedGPSFactor
Definition: BiasedGPSFactor.h:30
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::KeyFormatter
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
gtsam::Pose3
Definition: Pose3.h:37
gtsam::BiasedGPSFactor::equals
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Definition: BiasedGPSFactor.h:70
gtsam::NoiseModelFactorN
Definition: NonlinearFactor.h:431
gtsam::BiasedGPSFactor::evaluateError
Vector evaluateError(const Pose3 &pose, const Point3 &bias, OptionalMatrixType H1, OptionalMatrixType H2) const override
Definition: BiasedGPSFactor.h:78
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
gtsam::BiasedGPSFactor::This
BiasedGPSFactor This
Definition: BiasedGPSFactor.h:34
gtsam::BiasedGPSFactor::~BiasedGPSFactor
~BiasedGPSFactor() override
Definition: BiasedGPSFactor.h:56
gtsam::NoiseModelFactor::equals
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
Definition: NonlinearFactor.cpp:80
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
NonlinearFactor.h
Non-linear factor base classes.
gtsam
traits
Definition: SFMdata.h:40
gtsam::traits
Definition: Group.h:36
gtsam::NonlinearFactor
Definition: NonlinearFactor.h:68
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
gtsam::OptionalMatrixType
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
gtsam::BiasedGPSFactor::measured_
Point3 measured_
Definition: BiasedGPSFactor.h:37
gtsam::BiasedGPSFactor::Base
NoiseModelFactorN< Pose3, Point3 > Base
Definition: BiasedGPSFactor.h:35
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
Pose3.h
3D Pose
gtsam::BiasedGPSFactor::print
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: BiasedGPSFactor.h:61
gtsam::BiasedGPSFactor::BiasedGPSFactor
BiasedGPSFactor(Key posekey, Key biaskey, const Point3 measured, const SharedNoiseModel &model)
Definition: BiasedGPSFactor.h:51


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:55