gtsam
Loading...
Searching...
No Matches
BatchFixedLagSmoother.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 <queue>
26
27namespace gtsam {
28
29class GTSAM_EXPORT BatchFixedLagSmoother : public FixedLagSmoother {
30
31public:
32
34 typedef std::shared_ptr<BatchFixedLagSmoother> shared_ptr;
35
45 BatchFixedLagSmoother(double smootherLag = 0.0, const LevenbergMarquardtParams& parameters = LevenbergMarquardtParams(), bool enforceConsistency = true) :
46 FixedLagSmoother(smootherLag), parameters_(parameters), enforceConsistency_(enforceConsistency) {
47 }
48
51
53 void print(const std::string& s = "BatchFixedLagSmoother:\n", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
54
56 bool equals(const FixedLagSmoother& rhs, double tol = 1e-9) const override;
57
76 Result update(const NonlinearFactorGraph& newFactors = NonlinearFactorGraph(),
77 const Values& newTheta = Values(),
78 const KeyTimestampMap& timestamps = KeyTimestampMap(),
79 const FactorIndices& factorsToRemove = FactorIndices()) override;
80
85 Values calculateEstimate() const override {
86 return theta_.retract(delta_);
87 }
88
90 Values calculateEstimate(const KeyVector& keys) const override {
91 return theta_.retract(delta_, keys);
92 }
93
100 template<class VALUE>
101 VALUE calculateEstimate(Key key) const {
102 const Vector delta = delta_.at(key);
103 return traits<VALUE>::Retract(theta_.at<VALUE>(key), delta);
104 }
105
108 return parameters_;
109 }
110
115
118 return factors_;
119 }
120
123 return theta_;
124 }
125
127 const Ordering& getOrdering() const {
128 return ordering_;
129 }
130
132 const VectorValues& getDelta() const {
133 return delta_;
134 }
135
137 Matrix marginalCovariance(Key key) const;
138
142 static GaussianFactorGraph CalculateMarginalFactors(
143 const GaussianFactorGraph& graph, const KeyVector& keys,
145
147 static NonlinearFactorGraph CalculateMarginalFactors(
148 const NonlinearFactorGraph& graph, const Values& theta, const KeyVector& keys,
150
151protected:
152
154 typedef std::map<Key, KeySet > FactorIndex;
155
158
163
166
169
172
175
178
180 std::queue<size_t> availableSlots_;
181
184
186 void insertFactors(const NonlinearFactorGraph& newFactors);
187
189 void removeFactors(const std::set<size_t>& deleteFactors);
190
192 void eraseKeys(const KeyVector& keys);
193
195 void reorder(const KeyVector& marginalizeKeys = KeyVector());
196
199
201 void marginalize(const KeyVector& marginalizableKeys);
202
203private:
205 static void PrintKeySet(const KeySet& keys, const std::string& label);
206 static void PrintSymbolicFactor(const NonlinearFactor::shared_ptr& factor);
207 static void PrintSymbolicFactor(const GaussianFactor::shared_ptr& factor);
208 static void PrintSymbolicGraph(const NonlinearFactorGraph& graph, const std::string& label);
209 static void PrintSymbolicGraph(const GaussianFactorGraph& graph, const std::string& label);
210}; // BatchFixedLagSmoother
211
212}
Base class for a fixed-lag smoother.
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
std::pair< std::shared_ptr< GaussianConditional >, std::shared_ptr< GaussianFactor > > EliminatePreferCholesky(const GaussianFactorGraph &factors, const Ordering &keys)
Densely partially eliminate with Cholesky factorization.
Definition HessianFactor.cpp:646
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Template to create a binary predicate.
Definition Testable.h:112
std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
Definition EliminateableFactorGraph.h:91
Definition Ordering.h:33
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
const Values & getLinearizationPoint() const
Access the current linearization point.
Definition BatchFixedLagSmoother.h:122
Values linearValues_
The set of values involved in current linear factors.
Definition BatchFixedLagSmoother.h:171
NonlinearFactorGraph factors_
The nonlinear factors.
Definition BatchFixedLagSmoother.h:165
Values theta_
The current linearization point.
Definition BatchFixedLagSmoother.h:168
VALUE calculateEstimate(Key key) const
Compute an estimate for a single variable using its incomplete linear delta computed during the last ...
Definition BatchFixedLagSmoother.h:101
void marginalize(const KeyVector &marginalizableKeys)
Marginalize out selected variables.
Definition BatchFixedLagSmoother.cpp:366
void insertFactors(const NonlinearFactorGraph &newFactors)
Augment the list of factors with a set of new factors.
Definition BatchFixedLagSmoother.cpp:167
Ordering ordering_
The current ordering.
Definition BatchFixedLagSmoother.h:174
const LevenbergMarquardtParams & params() const
read the current set of optimizer parameters
Definition BatchFixedLagSmoother.h:107
Values calculateEstimate() const override
Compute an estimate from the incomplete linear delta computed during the last update.
Definition BatchFixedLagSmoother.h:85
std::shared_ptr< BatchFixedLagSmoother > shared_ptr
Typedef for a shared pointer to an Incremental Fixed-Lag Smoother.
Definition BatchFixedLagSmoother.h:34
std::map< Key, KeySet > FactorIndex
A typedef defining an Key-Factor mapping.
Definition BatchFixedLagSmoother.h:154
void removeFactors(const std::set< size_t > &deleteFactors)
Remove factors from the list of factors by slot index.
Definition BatchFixedLagSmoother.cpp:188
bool enforceConsistency_
A flag indicating if the optimizer should enforce probabilistic consistency by maintaining the linear...
Definition BatchFixedLagSmoother.h:162
const Ordering & getOrdering() const
Access the current ordering.
Definition BatchFixedLagSmoother.h:127
LevenbergMarquardtParams & params()
update the current set of optimizer parameters
Definition BatchFixedLagSmoother.h:112
void eraseKeys(const KeyVector &keys)
Erase any keys associated with timestamps before the provided time.
Definition BatchFixedLagSmoother.cpp:209
LevenbergMarquardtParams parameters_
The L-M optimization parameters.
Definition BatchFixedLagSmoother.h:157
std::queue< size_t > availableSlots_
The set of available factor graph slots.
Definition BatchFixedLagSmoother.h:180
BatchFixedLagSmoother(double smootherLag=0.0, const LevenbergMarquardtParams &parameters=LevenbergMarquardtParams(), bool enforceConsistency=true)
Construct with parameters.
Definition BatchFixedLagSmoother.h:45
~BatchFixedLagSmoother() override
destructor
Definition BatchFixedLagSmoother.h:50
const NonlinearFactorGraph & getFactors() const
Access the current set of factors.
Definition BatchFixedLagSmoother.h:117
Values calculateEstimate(const KeyVector &keys) const override
Compute estimates for a set of variables only, one retract per key.
Definition BatchFixedLagSmoother.h:90
const VectorValues & getDelta() const
Access the current set of deltas to the linearization point.
Definition BatchFixedLagSmoother.h:132
FactorIndex factorIndex_
A cross-reference structure to allow efficient factor lookups by key.
Definition BatchFixedLagSmoother.h:183
VectorValues delta_
The current set of linear deltas.
Definition BatchFixedLagSmoother.h:177
Result optimize()
Optimize the current graph using a modified version of L-M.
Definition BatchFixedLagSmoother.cpp:241
void reorder(const KeyVector &marginalizeKeys=KeyVector())
Use colamd to update into an efficient ordering.
Definition BatchFixedLagSmoother.cpp:235
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
Meta information returned about the update.
Definition FixedLagSmoother.h:48
Parameters for Levenberg-Marquardt optimization.
Definition LevenbergMarquardtParams.h:36
Definition NonlinearFactorGraph.h:57
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65