gtsam  4.0.0
gtsam
EssentialMatrixConstraint.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010-2014, 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 
19 #pragma once
20 
22 #include <gtsam/geometry/EssentialMatrix.h>
23 
24 namespace gtsam {
25 
30 class GTSAM_EXPORT EssentialMatrixConstraint: public NoiseModelFactor2<Pose3, Pose3> {
31 
32 private:
33 
36 
37  EssentialMatrix measuredE_;
39 public:
40 
41  // shorthand for a smart pointer to a factor
42  typedef boost::shared_ptr<EssentialMatrixConstraint> shared_ptr;
43 
46  }
47 
56  const EssentialMatrix& measuredE, const SharedNoiseModel& model) :
57  Base(model, key1, key2), measuredE_(measuredE) {
58  }
59 
60  virtual ~EssentialMatrixConstraint() {
61  }
62 
64  virtual gtsam::NonlinearFactor::shared_ptr clone() const {
65  return boost::static_pointer_cast<gtsam::NonlinearFactor>(
66  gtsam::NonlinearFactor::shared_ptr(new This(*this)));
67  }
68 
72  virtual void print(const std::string& s = "",
73  const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
74 
76  virtual bool equals(const NonlinearFactor& expected, double tol = 1e-9) const;
77 
81  virtual Vector evaluateError(const Pose3& p1, const Pose3& p2,
82  boost::optional<Matrix&> Hp1 = boost::none, //
83  boost::optional<Matrix&> Hp2 = boost::none) const;
84 
86  const EssentialMatrix& measured() const {
87  return measuredE_;
88  }
89 
91  std::size_t size() const {
92  return 2;
93  }
94 
95 private:
96 
98  friend class boost::serialization::access;
99  template<class ARCHIVE>
100  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
101  ar
102  & boost::serialization::make_nvp("NoiseModelFactor2",
103  boost::serialization::base_object<Base>(*this));
104  ar & BOOST_SERIALIZATION_NVP(measuredE_);
105  }
106 
107 public:
108  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
109 };
110 // \class EssentialMatrixConstraint
111 
112 }
This is the base class for all factor types.
Definition: Factor.h:54
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:345
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Template to create a binary predicate.
Definition: Testable.h:110
EssentialMatrixConstraint(Key key1, Key key2, const EssentialMatrix &measuredE, const SharedNoiseModel &model)
Constructor.
Definition: EssentialMatrixConstraint.h:55
virtual gtsam::NonlinearFactor::shared_ptr clone() const
Definition: EssentialMatrixConstraint.h:64
Definition: EssentialMatrixConstraint.h:30
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
Nonlinear factor base class.
Definition: NonlinearFactor.h:50
boost::shared_ptr< EssentialMatrixConstraint > shared_ptr
The measurement is an essential matrix.
Definition: EssentialMatrixConstraint.h:42
EssentialMatrixConstraint()
default constructor - only use for serialization
Definition: EssentialMatrixConstraint.h:45
Non-linear factor base classes.
const EssentialMatrix & measured() const
return the measured
Definition: EssentialMatrixConstraint.h:86
An essential matrix is like a Pose3, except with translation up to scale It is named after the 3*3 ma...
Definition: EssentialMatrix.h:26
std::size_t size() const
number of variables attached to this factor
Definition: EssentialMatrixConstraint.h:91
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:1072
Definition: Pose3.h:37