nonlinear/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 
20 // \callgraph
21 #pragma once
22 
25 #include <queue>
26 
27 namespace gtsam {
28 
29 class GTSAM_EXPORT BatchFixedLagSmoother : public FixedLagSmoother {
30 
31 public:
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 
50  ~BatchFixedLagSmoother() override {}
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 
60  const Values& newTheta = Values(),
61  const KeyTimestampMap& timestamps = KeyTimestampMap(),
62  const FactorIndices& factorsToRemove = FactorIndices()) override;
63 
68  Values calculateEstimate() const override {
69  return theta_.retract(delta_);
70  }
71 
78  template<class VALUE>
80  const Vector delta = delta_.at(key);
81  return traits<VALUE>::Retract(theta_.at<VALUE>(key), delta);
82  }
83 
86  return parameters_;
87  }
88 
91  return parameters_;
92  }
93 
96  return factors_;
97  }
98 
100  const Values& getLinearizationPoint() const {
101  return theta_;
102  }
103 
105  const Ordering& getOrdering() const {
106  return ordering_;
107  }
108 
110  const VectorValues& getDelta() const {
111  return delta_;
112  }
113 
115  Matrix marginalCovariance(Key key) const;
116 
120  static GaussianFactorGraph CalculateMarginalFactors(
121  const GaussianFactorGraph& graph, const KeyVector& keys,
122  const GaussianFactorGraph::Eliminate& eliminateFunction = EliminatePreferCholesky);
123 
125  static NonlinearFactorGraph CalculateMarginalFactors(
126  const NonlinearFactorGraph& graph, const Values& theta, const KeyVector& keys,
127  const GaussianFactorGraph::Eliminate& eliminateFunction = EliminatePreferCholesky);
128 
129 protected:
130 
132  typedef std::map<Key, std::set<Key> > FactorIndex;
133 
136 
141 
144 
147 
150 
153 
156 
158  std::queue<size_t> availableSlots_;
159 
162 
164  void insertFactors(const NonlinearFactorGraph& newFactors);
165 
167  void removeFactors(const std::set<size_t>& deleteFactors);
168 
170  void eraseKeys(const KeyVector& keys);
171 
173  void reorder(const KeyVector& marginalizeKeys = KeyVector());
174 
176  Result optimize();
177 
179  void marginalize(const KeyVector& marginalizableKeys);
180 
181 private:
183  static void PrintKeySet(const std::set<Key>& keys, const std::string& label);
184  static void PrintKeySet(const gtsam::KeySet& keys, const std::string& label);
185  static void PrintSymbolicFactor(const NonlinearFactor::shared_ptr& factor);
186  static void PrintSymbolicFactor(const GaussianFactor::shared_ptr& factor);
187  static void PrintSymbolicGraph(const NonlinearFactorGraph& graph, const std::string& label);
188  static void PrintSymbolicGraph(const GaussianFactorGraph& graph, const std::string& label);
189 }; // BatchFixedLagSmoother
190 
191 }
gtsam::NonlinearFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: NonlinearFactor.h:79
relicense.update
def update(text)
Definition: relicense.py:46
gtsam::Result
Result from elimination.
Definition: HybridGaussianFactorGraph.cpp:64
gtsam::BatchFixedLagSmoother::parameters_
LevenbergMarquardtParams parameters_
Definition: nonlinear/BatchFixedLagSmoother.h:135
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam::BatchFixedLagSmoother::delta_
VectorValues delta_
Definition: nonlinear/BatchFixedLagSmoother.h:155
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
gtsam::optimize
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Definition: triangulation.cpp:177
LevenbergMarquardtOptimizer.h
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
gtsam::BatchFixedLagSmoother::params
const LevenbergMarquardtParams & params() const
Definition: nonlinear/BatchFixedLagSmoother.h:85
gtsam::BatchFixedLagSmoother::availableSlots_
std::queue< size_t > availableSlots_
Definition: nonlinear/BatchFixedLagSmoother.h:158
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
gtsam::FastSet< Key >
gtsam::BatchFixedLagSmoother::calculateEstimate
VALUE calculateEstimate(Key key) const
Definition: nonlinear/BatchFixedLagSmoother.h:79
gtsam::BatchFixedLagSmoother::theta_
Values theta_
Definition: nonlinear/BatchFixedLagSmoother.h:146
gtsam::BatchFixedLagSmoother::params
LevenbergMarquardtParams & params()
Definition: nonlinear/BatchFixedLagSmoother.h:90
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:39
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
gtsam::BatchFixedLagSmoother::factorIndex_
FactorIndex factorIndex_
Definition: nonlinear/BatchFixedLagSmoother.h:161
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
pruning_fixture::factor
DecisionTreeFactor factor(D &C &B &A, "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 " "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0")
gtsam::EliminatePreferCholesky
std::pair< std::shared_ptr< GaussianConditional >, std::shared_ptr< GaussianFactor > > EliminatePreferCholesky(const GaussianFactorGraph &factors, const Ordering &keys)
Definition: HessianFactor.cpp:539
Eigen::internal::VALUE
@ VALUE
Definition: SpecialFunctionsImpl.h:729
gtsam::GaussianFactorGraph
Definition: GaussianFactorGraph.h:73
gtsam::BatchFixedLagSmoother::getOrdering
const Ordering & getOrdering() const
Definition: nonlinear/BatchFixedLagSmoother.h:105
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:145
gtsam::Values::retract
Values retract(const VectorValues &delta) const
Definition: Values.cpp:99
gtsam::FixedLagSmoother
Definition: nonlinear/FixedLagSmoother.h:33
gtsam::BatchFixedLagSmoother::getLinearizationPoint
const Values & getLinearizationPoint() const
Definition: nonlinear/BatchFixedLagSmoother.h:100
gtsam.examples.PlanarManipulatorExample.delta
def delta(g0, g1)
Definition: PlanarManipulatorExample.py:45
gtsam::VectorValues
Definition: VectorValues.h:74
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
parameters
static ConjugateGradientParameters parameters
Definition: testIterative.cpp:33
gtsam::FixedLagSmoother::Result
Definition: nonlinear/FixedLagSmoother.h:48
gtsam::NonlinearFactorGraph
Definition: NonlinearFactorGraph.h:55
gtsam::GaussianFactor::shared_ptr
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition: GaussianFactor.h:42
gtsam::BatchFixedLagSmoother
Definition: nonlinear/BatchFixedLagSmoother.h:29
gtsam::BatchFixedLagSmoother::getFactors
const NonlinearFactorGraph & getFactors() const
Definition: nonlinear/BatchFixedLagSmoother.h:95
gtsam::BatchFixedLagSmoother::enforceConsistency_
bool enforceConsistency_
Definition: nonlinear/BatchFixedLagSmoother.h:140
gtsam::BatchFixedLagSmoother::ordering_
Ordering ordering_
Definition: nonlinear/BatchFixedLagSmoother.h:152
gtsam::BatchFixedLagSmoother::linearValues_
Values linearValues_
Definition: nonlinear/BatchFixedLagSmoother.h:149
gtsam::equals
Definition: Testable.h:112
key
const gtsam::Symbol key('X', 0)
FixedLagSmoother.h
Base class for a fixed-lag smoother. This mimics the basic interface to iSAM2.
Values
std::vector< float > Values
Definition: sparse_setter.cpp:45
gtsam
traits
Definition: SFMdata.h:40
gtsam::BatchFixedLagSmoother::~BatchFixedLagSmoother
~BatchFixedLagSmoother() override
Definition: nonlinear/BatchFixedLagSmoother.h:50
gtsam::traits
Definition: Group.h:36
gtsam::Values
Definition: Values.h:65
gtsam::BatchFixedLagSmoother::FactorIndex
std::map< Key, std::set< Key > > FactorIndex
Definition: nonlinear/BatchFixedLagSmoother.h:132
gtsam::BatchFixedLagSmoother::getDelta
const VectorValues & getDelta() const
Definition: nonlinear/BatchFixedLagSmoother.h:110
gtsam::EliminateableFactorGraph< GaussianFactorGraph >::Eliminate
std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
The function type that does a single dense elimination step on a subgraph.
Definition: EliminateableFactorGraph.h:88
gtsam::LevenbergMarquardtParams
Definition: LevenbergMarquardtParams.h:35
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::BatchFixedLagSmoother::calculateEstimate
Values calculateEstimate() const override
Definition: nonlinear/BatchFixedLagSmoother.h:68
gtsam::BatchFixedLagSmoother::shared_ptr
std::shared_ptr< BatchFixedLagSmoother > shared_ptr
Typedef for a shared pointer to an Incremental Fixed-Lag Smoother.
Definition: nonlinear/BatchFixedLagSmoother.h:34
gtsam::BatchFixedLagSmoother::factors_
NonlinearFactorGraph factors_
Definition: nonlinear/BatchFixedLagSmoother.h:143
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::PrintKeySet
void PrintKeySet(const KeySet &keys, const string &s, const KeyFormatter &keyFormatter)
Utility function to print sets of keys with optional prefix.
Definition: Key.cpp:88
gtsam::Ordering
Definition: inference/Ordering.h:33
gtsam::BatchFixedLagSmoother::BatchFixedLagSmoother
BatchFixedLagSmoother(double smootherLag=0.0, const LevenbergMarquardtParams &parameters=LevenbergMarquardtParams(), bool enforceConsistency=true)
Definition: nonlinear/BatchFixedLagSmoother.h:45
gtsam::FactorIndices
FastVector< FactorIndex > FactorIndices
Define collection types:
Definition: Factor.h:37


gtsam
Author(s):
autogenerated on Wed Apr 16 2025 03:01:59