58 typedef typename boost::shared_ptr<GaussMarkov1stOrderFactor> shared_ptr;
65 const SharedGaussian& model) :
66 Base(calcDiscreteNoiseModel(model, delta_t),
key1, key2), dt_(delta_t), tau_(tau) {
74 void print(
const std::string& s,
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
75 std::cout << s <<
"GaussMarkov1stOrderFactor("
76 << keyFormatter(this->
key1()) <<
","
77 << keyFormatter(this->key2()) <<
")\n";
78 this->noiseModel_->print(
" noise model");
83 const This *e =
dynamic_cast<const This*
> (&expected);
91 boost::optional<Matrix&> H1 = boost::none,
92 boost::optional<Matrix&> H2 = boost::none)
const override {
97 Vector alpha(tau_.size());
98 Vector alpha_v1(tau_.size());
99 for(
int i=0; i<tau_.size(); i++){
100 alpha(i) = exp(- 1/tau_(i)*dt_ );
101 alpha_v1(i) = alpha(i) * v1(i);
104 Vector hx(v2 - alpha_v1);
106 if(H1) *H1 = -1 * alpha.asDiagonal();
107 if(H2) *H2 = Matrix::Identity(v2.size(),v2.size());
116 template<
class ARCHIVE>
117 void serialize(ARCHIVE & ar,
const unsigned int ) {
118 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
119 ar & BOOST_SERIALIZATION_NVP(dt_);
120 ar & BOOST_SERIALIZATION_NVP(tau_);
123 SharedGaussian calcDiscreteNoiseModel(
const SharedGaussian& model,
double delta_t){
128 noiseModel::Gaussian::shared_ptr gaussian_model = boost::dynamic_pointer_cast<noiseModel::Gaussian>(model);
137 public Testable<GaussMarkov1stOrderFactor<VALUE> > {
Concept check for values that can be used in unit tests.
Base class and basic functions for Lie types.
A factor with a quadratic error function - a Gaussian.
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
This is the base class for all factor types.
Definition: Factor.h:56
static shared_ptr SqrtInformation(const Matrix &R, bool smart=true)
A Gaussian noise model created by specifying a square root information matrix.
Definition: NoiseModel.cpp:85
Nonlinear factor base class.
Definition: NonlinearFactor.h:43
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
Check if two factors are equal.
Definition: NonlinearFactor.cpp:71
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:369
Key key1() const
methods to retrieve both keys
Definition: NonlinearFactor.h:401
Definition: GaussMarkov1stOrderFactor.h:45
GaussMarkov1stOrderFactor()
default constructor - only use for serialization
Definition: GaussMarkov1stOrderFactor.h:61
GaussMarkov1stOrderFactor(const Key &key1, const Key &key2, double delta_t, Vector tau, const SharedGaussian &model)
Constructor.
Definition: GaussMarkov1stOrderFactor.h:64
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
implement functions needed for Testable
Definition: GaussMarkov1stOrderFactor.h:74
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
equals
Definition: GaussMarkov1stOrderFactor.h:82
friend class boost::serialization::access
Serialization function.
Definition: GaussMarkov1stOrderFactor.h:115
Vector evaluateError(const VALUE &p1, const VALUE &p2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const override
implement functions needed to derive from Factor
Definition: GaussMarkov1stOrderFactor.h:90