ISAM2.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 // \callgraph
20 
21 #pragma once
22 
29 
30 #include <vector>
31 
32 namespace gtsam {
33 
45 class GTSAM_EXPORT ISAM2 : public BayesTree<ISAM2Clique> {
46  protected:
49 
53 
62 
63  mutable VectorValues deltaNewton_; // Only used when using Dogleg - stores
64  // the Gauss-Newton update
65  mutable VectorValues RgProd_; // Only used when using Dogleg - stores R*g and
66  // is updated incrementally
67 
76  mutable KeySet deltaReplacedMask_; // TODO(dellaert): Make sure accessed in
77  // the right way
78 
82 
85 
88 
90  mutable boost::optional<double> doglegDelta_;
91 
95 
97 
99  public:
100  using This = ISAM2;
105 
107  explicit ISAM2(const ISAM2Params& params);
108 
111  ISAM2();
112 
114  virtual ~ISAM2() {}
115 
117  virtual bool equals(const ISAM2& other, double tol = 1e-9) const;
118 
151  virtual ISAM2Result update(
152  const NonlinearFactorGraph& newFactors = NonlinearFactorGraph(),
153  const Values& newTheta = Values(),
154  const FactorIndices& removeFactorIndices = FactorIndices(),
155  const boost::optional<FastMap<Key, int> >& constrainedKeys = boost::none,
156  const boost::optional<FastList<Key> >& noRelinKeys = boost::none,
157  const boost::optional<FastList<Key> >& extraReelimKeys = boost::none,
158  bool force_relinearize = false);
159 
178  virtual ISAM2Result update(const NonlinearFactorGraph& newFactors,
179  const Values& newTheta,
180  const ISAM2UpdateParams& updateParams);
181 
199  void marginalizeLeaves(
200  const FastList<Key>& leafKeys,
201  boost::optional<FactorIndices&> marginalFactorsIndices = boost::none,
202  boost::optional<FactorIndices&> deletedFactorsIndices = boost::none);
203 
205  const Values& getLinearizationPoint() const { return theta_; }
206 
208  bool valueExists(Key key) const { return theta_.exists(key); }
209 
215  Values calculateEstimate() const;
216 
223  template <class VALUE>
224  VALUE calculateEstimate(Key key) const {
225  const Vector& delta = getDelta()[key];
226  return traits<VALUE>::Retract(theta_.at<VALUE>(key), delta);
227  }
228 
237  const Value& calculateEstimate(Key key) const;
238 
240  Matrix marginalCovariance(Key key) const;
241 
244 
248  Values calculateBestEstimate() const;
249 
251  const VectorValues& getDelta() const;
252 
254  double error(const VectorValues& x) const;
255 
258  return nonlinearFactors_;
259  }
260 
262  const VariableIndex& getVariableIndex() const { return variableIndex_; }
263 
265  const KeySet& getFixedVariables() const { return fixedVariables_; }
266 
267  const ISAM2Params& params() const { return params_; }
268 
270  void printStats() const { getCliqueData().getStats().print(); }
271 
279  VectorValues gradientAtZero() const;
280 
282 
283  protected:
285  void recalculate(const ISAM2UpdateParams& updateParams,
286  const KeySet& relinKeys, ISAM2Result* result);
287 
288  // Do a batch step - reorder and relinearize all variables
289  void recalculateBatch(const ISAM2UpdateParams& updateParams,
290  KeySet* affectedKeysSet, ISAM2Result* result);
291 
292  // retrieve all factors that ONLY contain the affected variables
293  // (note that the remaining stuff is summarized in the cached factors)
294  GaussianFactorGraph relinearizeAffectedFactors(
295  const ISAM2UpdateParams& updateParams, const FastList<Key>& affectedKeys,
296  const KeySet& relinKeys);
297 
298  void recalculateIncremental(const ISAM2UpdateParams& updateParams,
299  const KeySet& relinKeys,
300  const FastList<Key>& affectedKeys,
301  KeySet* affectedKeysSet, Cliques* orphans,
302  ISAM2Result* result);
303 
309  void addVariables(const Values& newTheta,
311 
315  void removeVariables(const KeySet& unusedKeys);
316 
317  void updateDelta(bool forceFullSolve = false) const;
318 }; // ISAM2
319 
321 template <>
322 struct traits<ISAM2> : public Testable<ISAM2> {};
323 
324 } // namespace gtsam
boost::shared_ptr< Clique > sharedClique
Shared pointer to a clique.
Definition: BayesTree.h:72
bool exists(Key j) const
Definition: Values.cpp:104
def update(text)
Definition: relicense.py:46
Factor Graph consisting of non-linear factors.
VectorValues RgProd_
Definition: ISAM2.h:65
Specialized iSAM2 Clique.
FastVector< FactorIndex > FactorIndices
Define collection types:
Definition: Factor.h:32
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:43
VariableIndex variableIndex_
Definition: ISAM2.h:52
bool valueExists(Key key) const
Check whether variable with given key exists in linearization point.
Definition: ISAM2.h:208
ISAM2Params params_
Definition: ISAM2.h:87
KeySet fixedVariables_
Definition: ISAM2.h:94
void printStats() const
Definition: ISAM2.h:270
Eigen::VectorXd Vector
Definition: Vector.h:38
NonlinearFactorGraph nonlinearFactors_
Definition: ISAM2.h:81
Values result
const ValueType at(Key j) const
Definition: Values-inl.h:342
Class that stores detailed iSAM2 result.
boost::optional< double > doglegDelta_
Definition: ISAM2.h:90
virtual ~ISAM2()
Definition: ISAM2.h:114
GaussianFactorGraph linearFactors_
Definition: ISAM2.h:84
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Values theta_
Definition: ISAM2.h:48
Base::sharedClique sharedClique
Shared pointer to a clique.
Definition: ISAM2.h:103
static SmartStereoProjectionParams params
int update_count_
Definition: ISAM2.h:96
const ISAM2Params & params() const
Definition: ISAM2.h:267
KeySet deltaReplacedMask_
Definition: ISAM2.h:76
traits
Definition: chartTesting.h:28
std::vector< float > Values
Class that stores extra params for ISAM2::update()
const KeySet & getFixedVariables() const
Definition: ISAM2.h:265
VectorValues delta_
Definition: ISAM2.h:61
VALUE calculateEstimate(Key key) const
Definition: ISAM2.h:224
static double error
Definition: testRot3.cpp:39
VectorValues deltaNewton_
Definition: ISAM2.h:63
const G double tol
Definition: Group.h:83
const NonlinearFactorGraph & getFactorsUnsafe() const
Definition: ISAM2.h:257
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
const VariableIndex & getVariableIndex() const
Definition: ISAM2.h:262
Gaussian Bayes Tree, the result of eliminating a GaussianJunctionTree.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
Parameters for iSAM 2.
const Values & getLinearizationPoint() const
Access the current linearization point.
Definition: ISAM2.h:205


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:18