BinaryMeasurement.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010-2020, 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 
12 #pragma once
13 
26 #include <gtsam/base/Testable.h>
27 #include <gtsam/inference/Factor.h>
28 #include <gtsam/inference/Key.h>
30 
31 #include <iostream>
32 #include <vector>
33 
34 namespace gtsam {
35 
36 template <class T> class BinaryMeasurement : public Factor {
37  // Check that T type is testable
39 
40 public:
41  // shorthand for a smart pointer to a measurement
42  using shared_ptr = typename std::shared_ptr<BinaryMeasurement>;
43 
44 private:
47 
48  public:
50  const SharedNoiseModel &model = nullptr)
51  : Factor(std::vector<Key>({key1, key2})),
53  noiseModel_(model) {}
54 
57 
58  Key key1() const { return keys_[0]; }
59  Key key2() const { return keys_[1]; }
60  const T &measured() const { return measured_; }
61  const SharedNoiseModel &noiseModel() const { return noiseModel_; }
62 
66 
67  void print(const std::string &s, const KeyFormatter &keyFormatter =
68  DefaultKeyFormatter) const override {
69  std::cout << s << "BinaryMeasurement(" << keyFormatter(this->key1()) << ","
70  << keyFormatter(this->key2()) << ")\n";
71  traits<T>::Print(measured_, " measured: ");
72  this->noiseModel_->print(" noise model: ");
73  }
74 
75  bool equals(const BinaryMeasurement &expected, double tol = 1e-9) const {
76  const BinaryMeasurement<T> *e =
77  dynamic_cast<const BinaryMeasurement<T> *>(&expected);
78  return e != nullptr && Factor::equals(*e) &&
80  noiseModel_->equals(*expected.noiseModel());
81  }
83 };
84 } // namespace gtsam
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Testable.h
Concept check for values that can be used in unit tests.
gtsam::BinaryMeasurement::noiseModel_
SharedNoiseModel noiseModel_
Noise model.
Definition: BinaryMeasurement.h:46
gtsam::BinaryMeasurement::equals
bool equals(const BinaryMeasurement &expected, double tol=1e-9) const
Definition: BinaryMeasurement.h:75
gtsam::Factor
Definition: Factor.h:70
gtsam::Factor::shared_ptr
std::shared_ptr< Factor > shared_ptr
A shared_ptr to this class.
Definition: Factor.h:76
Factor.h
The base class for all factors.
gtsam::BinaryMeasurement::GTSAM_CONCEPT_ASSERT
GTSAM_CONCEPT_ASSERT(IsTestable< T >)
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
Key.h
gtsam::BinaryMeasurement::noiseModel
const SharedNoiseModel & noiseModel() const
Definition: BinaryMeasurement.h:61
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
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
Eigen::Triplet< double >
gtsam::BinaryMeasurement::BinaryMeasurement
BinaryMeasurement(Key key1, Key key2, const T &measured, const SharedNoiseModel &model=nullptr)
Definition: BinaryMeasurement.h:49
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
gtsam::BinaryMeasurement::key1
Key key1() const
Definition: BinaryMeasurement.h:58
gtsam::BinaryMeasurement
Definition: BinaryMeasurement.h:36
gtsam::BinaryMeasurement::key2
Key key2() const
Definition: BinaryMeasurement.h:59
gtsam
traits
Definition: SFMdata.h:40
gtsam::Factor::keys_
KeyVector keys_
The keys involved in this factor.
Definition: Factor.h:88
NoiseModel.h
gtsam::traits
Definition: Group.h:36
gtsam::Factor::equals
bool equals(const This &other, double tol=1e-9) const
check equality
Definition: Factor.cpp:42
std
Definition: BFloat16.h:88
gtsam::Print
void Print(const CONTAINER &keys, const string &s, const KeyFormatter &keyFormatter)
Definition: Key.cpp:65
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::BinaryMeasurement::print
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition: BinaryMeasurement.h:67
gtsam::BinaryMeasurement::measured
const T & measured() const
Definition: BinaryMeasurement.h:60
gtsam::IsTestable
Definition: Testable.h:59
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::BinaryMeasurement::measured_
T measured_
The measurement.
Definition: BinaryMeasurement.h:45


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