gtsam
Loading...
Searching...
No Matches
IncrementalFixedLagSmoother.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
20// \callgraph
21#pragma once
22
25#include "gtsam/dllexport.h"
26
27#include <functional>
28
29namespace gtsam {
30
37
38public:
39
41 typedef std::shared_ptr<IncrementalFixedLagSmoother> shared_ptr;
42
45 const ISAM2Params& parameters = DefaultISAM2Params()) :
46 FixedLagSmoother(smootherLag), isam_(parameters) {
47 }
48
52
54 void print(const std::string& s = "IncrementalFixedLagSmoother:\n",
55 const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
56
58 bool equals(const FixedLagSmoother& rhs, double tol = 1e-9) const override;
59
89 Result update(const NonlinearFactorGraph& newFactors = NonlinearFactorGraph(),
90 const Values& newTheta = Values(), //
91 const KeyTimestampMap& timestamps = KeyTimestampMap(),
92 const FactorIndices& factorsToRemove = FactorIndices()) override;
93
98 Values calculateEstimate() const override {
99 return isam_.calculateEstimate();
100 }
101
103 Values calculateEstimate(const KeyVector& keys) const override {
104 return isam_.calculateEstimate(keys);
105 }
106
113 template<class VALUE>
114 VALUE calculateEstimate(Key key) const {
115 return isam_.calculateEstimate<VALUE>(key);
116 }
117
119 const ISAM2Params& params() const {
120 return isam_.params();
121 }
122
125 return isam_.getFactorsUnsafe();
126 }
127
130 return isam_.getLinearizationPoint();
131 }
132
134 const VectorValues& getDelta() const {
135 return isam_.getDelta();
136 }
137
139 Matrix marginalCovariance(Key key) const {
140 return isam_.marginalCovariance(key);
141 }
142
144 const ISAM2Result& getISAM2Result() const{ return isamResult_; }
145
147 const ISAM2& getISAM2() const { return isam_; }
148
149protected:
150
154 params.findUnusedFactorSlots = true;
155 return params;
156 }
157
161
164
166 void eraseKeysBefore(double timestamp);
167
170 const KeyVector& marginalizableKeys,
171 const std::function<bool(Key)>& isActive,
172 std::optional<FastMap<Key, int> >& constrainedKeys) const;
173
174private:
176 static void PrintKeySet(const KeySet& keys, const std::string& label =
177 "Keys:");
178 static void PrintSymbolicFactor(const GaussianFactor::shared_ptr& factor);
179 static void PrintSymbolicGraph(const GaussianFactorGraph& graph,
180 const std::string& label = "Factor Graph:");
181 static void PrintSymbolicTree(const gtsam::ISAM2& isam,
182 const std::string& label = "Bayes Tree:");
183 static void PrintSymbolicTreeHelper(
184 const gtsam::ISAM2Clique::shared_ptr& clique, const std::string indent =
185 "");
186
187};
188// IncrementalFixedLagSmoother
189
190}
Base class for a fixed-lag smoother.
Incremental update functionality (ISAM2) for BayesTree, with fluid relinearization.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:91
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
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
FastVector< FactorIndex > FactorIndices
Define collection types:
Definition Factor.h:37
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
FastMap is a thin wrapper around std::map that uses the boost fast_pool_allocator instead of the defa...
Definition FastMap.h:40
Template to create a binary predicate.
Definition Testable.h:112
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition GaussianFactor.h:42
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition GaussianFactorGraph.h:77
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:73
Definition FixedLagSmoother.h:33
double smootherLag() const
read the current smoother lag
Definition FixedLagSmoother.h:90
FixedLagSmoother(double smootherLag=0.0)
default constructor
Definition FixedLagSmoother.h:76
ISAM2 isam_
An iSAM2 object used to perform inference.
Definition IncrementalFixedLagSmoother.h:160
void createOrderingConstraints(const KeyVector &marginalizableKeys, const std::function< bool(Key)> &isActive, std::optional< FastMap< Key, int > > &constrainedKeys) const
Fill in an iSAM2 ConstrainedKeys structure such that the provided keys are eliminated before all othe...
Definition IncrementalFixedLagSmoother.cpp:268
~IncrementalFixedLagSmoother() override
destructor
Definition IncrementalFixedLagSmoother.h:50
const ISAM2 & getISAM2() const
Get the iSAM2 object which is used for the inference internally.
Definition IncrementalFixedLagSmoother.h:147
const VectorValues & getDelta() const
Access the current set of deltas to the linearization point.
Definition IncrementalFixedLagSmoother.h:134
void eraseKeysBefore(double timestamp)
Erase any keys associated with timestamps before the provided time.
Definition IncrementalFixedLagSmoother.cpp:258
VALUE calculateEstimate(Key key) const
Compute an estimate for a single variable using its incomplete linear delta computed during the last ...
Definition IncrementalFixedLagSmoother.h:114
Values calculateEstimate() const override
Compute an estimate from the incomplete linear delta computed during the last update.
Definition IncrementalFixedLagSmoother.h:98
Matrix marginalCovariance(Key key) const
Calculate marginal covariance on given variable.
Definition IncrementalFixedLagSmoother.h:139
const Values & getLinearizationPoint() const
Access the current linearization point.
Definition IncrementalFixedLagSmoother.h:129
const NonlinearFactorGraph & getFactors() const
Access the current set of factors.
Definition IncrementalFixedLagSmoother.h:124
std::shared_ptr< IncrementalFixedLagSmoother > shared_ptr
Typedef for a shared pointer to an Incremental Fixed-Lag Smoother.
Definition IncrementalFixedLagSmoother.h:41
ISAM2Result isamResult_
Store results of latest isam2 update.
Definition IncrementalFixedLagSmoother.h:163
static ISAM2Params DefaultISAM2Params()
Create default parameters.
Definition IncrementalFixedLagSmoother.h:152
Values calculateEstimate(const KeyVector &keys) const override
Compute estimates for a set of variables only, one retract per key.
Definition IncrementalFixedLagSmoother.h:103
const ISAM2Params & params() const
return the current set of iSAM2 parameters
Definition IncrementalFixedLagSmoother.h:119
const ISAM2Result & getISAM2Result() const
Get results of latest isam2 update.
Definition IncrementalFixedLagSmoother.h:144
IncrementalFixedLagSmoother(double smootherLag=0.0, const ISAM2Params &parameters=DefaultISAM2Params())
default constructor
Definition IncrementalFixedLagSmoother.h:44
Implementation of the full ISAM2 algorithm for incremental nonlinear optimization.
Definition ISAM2.h:45
Definition ISAM2Params.h:199
This struct is returned from ISAM2::update() and contains information about the update that is useful...
Definition ISAM2Result.h:39
Definition NonlinearFactorGraph.h:57
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65