gtsam
Loading...
Searching...
No Matches
PoseToPointFactor.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
19#pragma once
20
27#include <ostream>
28
29namespace gtsam {
30
35template<typename POSE = Pose3, typename POINT = Point3>
37 : public NoiseModelFactorT<typename traits<POINT>::TangentVector, POSE,
38 POINT> {
39 private:
40 typedef PoseToPointFactor This;
42 Base;
43 using ErrorVector = typename traits<POINT>::TangentVector;
44
45 POINT measured_;
46
47 public:
48
49 // Provide access to the Matrix& version of evaluateError:
51
52 // shorthand for a smart pointer to a factor
53 typedef std::shared_ptr<PoseToPointFactor> shared_ptr;
54
57
59 PoseToPointFactor(Key key1, Key key2, const POINT& measured,
60 const SharedNoiseModel& model)
61 : Base(model, key1, key2), measured_(measured) {}
62
63 virtual ~PoseToPointFactor() {}
64
66
68 void print(const std::string& s, const KeyFormatter& keyFormatter =
69 DefaultKeyFormatter) const override {
70 std::cout << s << "PoseToPointFactor("
71 << keyFormatter(this->key1()) << ","
72 << keyFormatter(this->key2()) << ")\n"
73 << " measured: " << measured_.transpose() << std::endl;
74 this->noiseModel_->print(" noise model: ");
75 }
76
78 bool equals(const NonlinearFactor& expected,
79 double tol = 1e-9) const override {
80 const This* e = dynamic_cast<const This*>(&expected);
81 return e != nullptr && Base::equals(*e, tol) &&
82 traits<POINT>::Equals(this->measured_, e->measured_, tol);
83 }
84
86 gtsam::NonlinearFactor::shared_ptr clone() const override {
87 return std::static_pointer_cast<gtsam::NonlinearFactor>(
88 gtsam::NonlinearFactor::shared_ptr(new This(*this)));
89 }
90
92
100 ErrorVector evaluateError(
101 const POSE& w_T_b, const POINT& w_P,
103 OptionalMatrixType H2) const override {
104 return w_T_b.transformTo(w_P, H1, H2) - measured_;
105 }
106
108 const POINT& measured() const { return measured_; }
109
110 private:
111#if GTSAM_ENABLE_BOOST_SERIALIZATION
113 friend class boost::serialization::access;
114 template <class ARCHIVE>
115 void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
116 // NoiseModelFactor2 instead of NoiseModelFactorN for backward compatibility
117 ar& boost::serialization::make_nvp(
118 "NoiseModelFactor2",
119 boost::serialization::base_object<Base>(*this));
120 ar& BOOST_SERIALIZATION_NVP(measured_);
121 }
122#endif
123
124}; // \class PoseToPointFactor
125
126} // namespace gtsam
3D Point
3D Pose manifold SO(3) x R^3 and group SE(3)
2D Point
2D Pose
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
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
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
virtual OutputVec evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const =0
Override evaluateError to finish implementing an n-way factor.
Nonlinear factor base class.
Definition NonlinearFactor.h:70
A class for a measurement between a pose and a point.
Definition PoseToPointFactor.h:38
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition PoseToPointFactor.h:86
const POINT & measured() const
return the measured
Definition PoseToPointFactor.h:108
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
equals
Definition PoseToPointFactor.h:78
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
implement functions needed for Testable
Definition PoseToPointFactor.h:68
ErrorVector evaluateError(const POSE &w_T_b, const POINT &w_P, OptionalMatrixType H1, OptionalMatrixType H2) const override
implement functions needed to derive from Factor
Definition PoseToPointFactor.h:100
PoseToPointFactor(Key key1, Key key2, const POINT &measured, const SharedNoiseModel &model)
Constructor.
Definition PoseToPointFactor.h:59
PoseToPointFactor()
default constructor - only use for serialization
Definition PoseToPointFactor.h:56