gtsam
Loading...
Searching...
No Matches
FixedLagSmoother.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
23#include <gtsam/dllexport.h>
24#include <gtsam/inference/Key.h>
27
28#include <map>
29#include <vector>
30
31namespace gtsam {
32
33class GTSAM_EXPORT FixedLagSmoother {
34
35public:
36
38 typedef std::shared_ptr<FixedLagSmoother> shared_ptr;
39
41 typedef std::map<Key, double> KeyTimestampMap;
42 typedef std::multimap<double, Key> TimestampKeyMap;
43
47 // TODO: Think of some more things to put here
48 struct Result {
49 size_t iterations;
53 double error;
61
63 size_t getIterations() const { return iterations; }
64 size_t getIntermediateSteps() const { return intermediateSteps; }
65 size_t getNonlinearVariables() const { return nonlinearVariables; }
66 size_t getLinearVariables() const { return linearVariables; }
67 double getError() const { return error; }
68 FactorIndices getMarginalFactorIndices() const { return marginalFactorIndices; }
69 FactorIndices getDeletedFactorIndices() const { return deletedFactorIndices; }
70 KeySet getKeysOfDeletedNodes() const { return keysOfDeletedNodes; }
71 KeySet getExpiredPendingKeys() const { return expiredPendingKeys; }
72 GTSAM_EXPORT void print() const;
73 };
74
77
79 virtual ~FixedLagSmoother() { }
80
82 virtual void print(
83 const std::string& s = "FixedLagSmoother:\n",
84 const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
85
87 virtual bool equals(const FixedLagSmoother& rhs, double tol = 1e-9) const;
88
90 double smootherLag() const {
91 return smootherLag_;
92 }
93
95 double& smootherLag() {
96 return smootherLag_;
97 }
98
103
106 return keyTimestampMap_;
107 }
108
111 const Values& newTheta = Values(),
113 const FactorIndices& factorsToRemove = FactorIndices()) = 0;
114
119 virtual Values calculateEstimate() const = 0;
120
127 virtual Values calculateEstimate(const KeyVector& keys) const {
128 return calculateEstimate().extract(keys);
129 }
130
131
132protected:
133
136
138 TimestampKeyMap timestampKeyMap_;
139 KeyTimestampMap keyTimestampMap_;
140
142 void updateKeyTimestampMap(const KeyTimestampMap& newTimestamps);
143
145 void eraseKeyTimestampMap(const KeyVector& keys);
146
148 double getCurrentTimestamp() const;
149
151 KeyVector findKeysBefore(double timestamp) const;
152
154 KeyVector findKeysAfter(double timestamp) const;
155
156}; // FixedLagSmoother
157
160typedef FixedLagSmootherKeyTimestampMap::value_type FixedLagSmootherKeyTimestampMapValue;
161typedef FixedLagSmoother::Result FixedLagSmootherResult;
162
163}
A non-templated config holding any types of Manifold-group elements.
Factor Graph consisting of non-linear factors.
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
FixedLagSmoother::KeyTimestampMap FixedLagSmootherKeyTimestampMap
Typedef for matlab wrapping.
Definition FixedLagSmoother.h:159
Template to create a binary predicate.
Definition Testable.h:112
Definition FixedLagSmoother.h:33
double smootherLag_
The length of the smoother lag.
Definition FixedLagSmoother.h:135
double smootherLag() const
read the current smoother lag
Definition FixedLagSmoother.h:90
TimestampKeyMap timestampKeyMap_
The current timestamp associated with each tracked key.
Definition FixedLagSmoother.h:138
double & smootherLag()
write to the current smoother lag
Definition FixedLagSmoother.h:95
virtual ~FixedLagSmoother()
destructor
Definition FixedLagSmoother.h:79
std::map< Key, double > KeyTimestampMap
Typedef for a Key-Timestamp map/database.
Definition FixedLagSmoother.h:41
void setSmootherLag(double smootherLag)
Write to the current smoother lag.
Definition FixedLagSmoother.h:100
virtual Result update(const NonlinearFactorGraph &newFactors=NonlinearFactorGraph(), const Values &newTheta=Values(), const KeyTimestampMap &timestamps=KeyTimestampMap(), const FactorIndices &factorsToRemove=FactorIndices())=0
Add new factors, updating the solution and relinearizing as needed.
std::shared_ptr< FixedLagSmoother > shared_ptr
Typedef for a shared pointer to an Incremental Fixed-Lag Smoother.
Definition FixedLagSmoother.h:38
FixedLagSmoother(double smootherLag=0.0)
default constructor
Definition FixedLagSmoother.h:76
KeyVector findKeysBefore(double timestamp) const
Find all of the keys associated with timestamps before the provided time.
Definition FixedLagSmoother.cpp:119
virtual Values calculateEstimate() const =0
Compute an estimate from the incomplete linear delta computed during the last update.
virtual Values calculateEstimate(const KeyVector &keys) const
Compute estimates for a set of variables only, as a Values holding those keys, whatever their types.
Definition FixedLagSmoother.h:127
void updateKeyTimestampMap(const KeyTimestampMap &newTimestamps)
Update the Timestamps associated with the keys.
Definition FixedLagSmoother.cpp:49
void eraseKeyTimestampMap(const KeyVector &keys)
Erase keys from the Key-Timestamps database.
Definition FixedLagSmoother.cpp:79
double getCurrentTimestamp() const
Find the most recent timestamp of the system.
Definition FixedLagSmoother.cpp:110
const KeyTimestampMap & timestamps() const
Access the current set of timestamps associated with each variable.
Definition FixedLagSmoother.h:105
KeyVector findKeysAfter(double timestamp) const
Find all of the keys associated with timestamps before the provided time.
Definition FixedLagSmoother.cpp:129
Meta information returned about the update.
Definition FixedLagSmoother.h:48
size_t iterations
The number of optimizer iterations performed.
Definition FixedLagSmoother.h:49
FactorIndices marginalFactorIndices
Indices added during the marginalizeLeaves step.
Definition FixedLagSmoother.h:54
size_t intermediateSteps
The number of intermediate steps performed within the optimization. For L-M, this is the number of la...
Definition FixedLagSmoother.h:50
size_t nonlinearVariables
The number of variables that can be relinearized.
Definition FixedLagSmoother.h:51
size_t getIterations() const
Getter methods.
Definition FixedLagSmoother.h:63
double error
The final factor graph error.
Definition FixedLagSmoother.h:53
FactorIndices deletedFactorIndices
Indices removed during the marginalizeLeaves step.
Definition FixedLagSmoother.h:55
KeySet expiredPendingKeys
Keys of values that left the lag window before any factor referenced them, and were removed without m...
Definition FixedLagSmoother.h:57
KeySet keysOfDeletedNodes
Keys of nodes removed during the marginalizeLeaves step.
Definition FixedLagSmoother.h:56
size_t linearVariables
The number of variables that must keep a constant linearization point.
Definition FixedLagSmoother.h:52
Definition NonlinearFactorGraph.h:57
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65