Loading...
Searching...
No Matches
BinaryMeasurement.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010-2020, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/base/Testable.h>
#include <gtsam/inference/Factor.h>
#include <gtsam/inference/Key.h>
#include <gtsam/linear/NoiseModel.h>
#include <iostream>
#include <vector>
namespace gtsam {
template <class T> class BinaryMeasurement : public Factor {
// Check that T type is testable
BOOST_CONCEPT_ASSERT((IsTestable<T>));
public:
// shorthand for a smart pointer to a measurement
using shared_ptr = typename boost::shared_ptr<BinaryMeasurement>;
private:
T measured_;
SharedNoiseModel noiseModel_;
public:
BinaryMeasurement(Key key1, Key key2, const T &measured,
const SharedNoiseModel &model = nullptr)
: Factor(std::vector<Key>({key1, key2})),
measured_(measured),
noiseModel_(model) {}
virtual ~BinaryMeasurement() {}
Key key1() const { return keys_[0]; }
Key key2() const { return keys_[1]; }
const T &measured() const { return measured_; }
const SharedNoiseModel &noiseModel() const { return noiseModel_; }
void print(const std::string &s, const KeyFormatter &keyFormatter =
DefaultKeyFormatter) const override {
std::cout << s << "BinaryMeasurement(" << keyFormatter(this->key1()) << ","
<< keyFormatter(this->key2()) << ")\n";
traits<T>::Print(measured_, " measured: ");
this->noiseModel_->print(" noise model: ");
}
bool equals(const BinaryMeasurement &expected, double tol = 1e-9) const {
const BinaryMeasurement<T> *e =
dynamic_cast<const BinaryMeasurement<T> *>(&expected);
return e != nullptr && Factor::equals(*e) &&
traits<T>::Equals(this->measured_, e->measured_, tol) &&
noiseModel_->equals(*expected.noiseModel());
}
};
} // namespace gtsam
Testable.h
Concept check for values that can be used in unit tests.
Factor.h
The base class for all factors.
Key.h
NoiseModel.h
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
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::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:724
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:100
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::IsTestable
A testable concept check that should be placed in applicable unit tests and in generic algorithms.
Definition Testable.h:58
gtsam::equals
Template to create a binary predicate.
Definition Testable.h:111
gtsam::Factor::keys_
KeyVector keys_
The keys involved in this factor.
Definition Factor.h:85
gtsam::Factor::Factor
Factor()
Default constructor for I/O.
Definition Factor.h:91
gtsam::Factor::equals
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
gtsam::BinaryMeasurement
Definition BinaryMeasurement.h:36
gtsam::BinaryMeasurement::print
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition BinaryMeasurement.h:70
gtsam::BinaryMeasurement::~BinaryMeasurement
virtual ~BinaryMeasurement()
Destructor.
Definition BinaryMeasurement.h:56