PoseToPointFactor.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <gtsam/geometry/Point2.h>
11 #include <gtsam/geometry/Pose2.h>
12 #include <gtsam/geometry/Point3.h>
13 #include <gtsam/geometry/Pose3.h>
15 #include <ostream>
16 
17 namespace gtsam {
18 
23 template<typename POSE = Pose3, typename POINT = Point3>
24 class PoseToPointFactor : public NoiseModelFactorN<POSE, POINT> {
25  private:
28 
29  POINT measured_;
31  public:
32 
33  // Provide access to the Matrix& version of evaluateError:
34  using Base::evaluateError;
35 
36  // shorthand for a smart pointer to a factor
37  typedef std::shared_ptr<PoseToPointFactor> shared_ptr;
38 
41 
44  const SharedNoiseModel& model)
46 
47  virtual ~PoseToPointFactor() {}
48 
52  void print(const std::string& s, const KeyFormatter& keyFormatter =
53  DefaultKeyFormatter) const override {
54  std::cout << s << "PoseToPointFactor("
55  << keyFormatter(this->key1()) << ","
56  << keyFormatter(this->key2()) << ")\n"
57  << " measured: " << measured_.transpose() << std::endl;
58  this->noiseModel_->print(" noise model: ");
59  }
60 
63  double tol = 1e-9) const override {
64  const This* e = dynamic_cast<const This*>(&expected);
65  return e != nullptr && Base::equals(*e, tol) &&
66  traits<POINT>::Equals(this->measured_, e->measured_, tol);
67  }
68 
71  return std::static_pointer_cast<gtsam::NonlinearFactor>(
73  }
74 
85  const POSE& w_T_b, const POINT& w_P,
87  OptionalMatrixType H2) const override {
88  return w_T_b.transformTo(w_P, H1, H2) - measured_;
89  }
90 
92  const POINT& measured() const { return measured_; }
93 
94  private:
95 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
96 
97  friend class boost::serialization::access;
98  template <class ARCHIVE>
99  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
100  // NoiseModelFactor2 instead of NoiseModelFactorN for backward compatibility
101  ar& boost::serialization::make_nvp(
102  "NoiseModelFactor2",
103  boost::serialization::base_object<Base>(*this));
104  ar& BOOST_SERIALIZATION_NVP(measured_);
105  }
106 #endif
107 
108 }; // \class PoseToPointFactor
109 
110 } // namespace gtsam
gtsam::NonlinearFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: NonlinearFactor.h:78
Pose2.h
2D Pose
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::NoiseModelFactorN< POSE, POINT >::evaluateError
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
gtsam::PoseToPointFactor::shared_ptr
std::shared_ptr< PoseToPointFactor > shared_ptr
Definition: PoseToPointFactor.h:37
gtsam::Factor
Definition: Factor.h:70
Point3.h
3D Point
gtsam::NoiseModelFactor::noiseModel_
SharedNoiseModel noiseModel_
Definition: NonlinearFactor.h:205
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
Point2.h
2D Point
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::PoseToPointFactor::measured_
POINT measured_
Definition: PoseToPointFactor.h:29
gtsam::PoseToPointFactor::This
PoseToPointFactor This
Definition: PoseToPointFactor.h:26
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::PoseToPointFactor::clone
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: PoseToPointFactor.h:70
gtsam::PoseToPointFactor::equals
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Definition: PoseToPointFactor.h:62
gtsam::NoiseModelFactorN
Definition: NonlinearFactor.h:431
gtsam::PoseToPointFactor::evaluateError
Vector evaluateError(const POSE &w_T_b, const POINT &w_P, OptionalMatrixType H1, OptionalMatrixType H2) const override
Error = w_T_b.inverse()*w_P - measured_.
Definition: PoseToPointFactor.h:84
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
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
gtsam::NoiseModelFactorN< Pose3, Point3 >::key1
Key key1() const
Definition: NonlinearFactor.h:731
gtsam::PoseToPointFactor::~PoseToPointFactor
virtual ~PoseToPointFactor()
Definition: PoseToPointFactor.h:47
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
gtsam::PoseToPointFactor::Base
NoiseModelFactorN< POSE, POINT > Base
Definition: PoseToPointFactor.h:27
NonlinearFactor.h
Non-linear factor base classes.
gtsam::NoiseModelFactorN< Pose3, Point3 >::key2
Key key2() const
Definition: NonlinearFactor.h:735
gtsam
traits
Definition: SFMdata.h:40
gtsam::traits
Definition: Group.h:36
gtsam::PoseToPointFactor::PoseToPointFactor
PoseToPointFactor()
Definition: PoseToPointFactor.h:40
gtsam::NonlinearFactor
Definition: NonlinearFactor.h:68
gtsam::PoseToPointFactor::PoseToPointFactor
PoseToPointFactor(Key key1, Key key2, const POINT &measured, const SharedNoiseModel &model)
Definition: PoseToPointFactor.h:43
gtsam::PoseToPointFactor::print
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: PoseToPointFactor.h:52
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::OptionalMatrixType
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
gtsam::PoseToPointFactor
Definition: PoseToPointFactor.h:24
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::PoseToPointFactor::measured
const POINT & measured() const
Definition: PoseToPointFactor.h:92
Pose3.h
3D Pose


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:36