gtsam
Loading...
Searching...
No Matches
KalmanFilter.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#pragma once
21
25
26#ifndef KALMANFILTER_DEFAULT_FACTORIZATION
27#define KALMANFILTER_DEFAULT_FACTORIZATION QR
28#endif
29
30namespace gtsam {
31
42class GTSAM_EXPORT KalmanFilter {
43 public:
48 enum Factorization { QR, CHOLESKY };
49
55 typedef GaussianDensity::shared_ptr State;
56
57 private:
58 const size_t n_;
59 const Matrix I_;
61 function_;
62
68 State solve(const GaussianFactorGraph& factorGraph) const;
69
76 State fuse(const State& p, GaussianFactor::shared_ptr newFactor) const;
77
78 public:
84 KalmanFilter(size_t n,
85 Factorization method = KALMANFILTER_DEFAULT_FACTORIZATION)
86 : n_(n),
87 I_(Matrix::Identity(n_, n_)),
88 function_(method == QR
91
104 State init(const Vector& x0, const SharedDiagonal& P0) const;
105
112 State init(const Vector& x0, const Matrix& P0) const;
113
118 void print(const std::string& s = "") const;
119
126 static Key step(const State& p) { return p->firstFrontalKey(); }
127
148 State predict(const State& p, const Matrix& F, const Matrix& B,
149 const Vector& u, const SharedDiagonal& modelQ) const;
150
165 State predictQ(const State& p, const Matrix& F, const Matrix& B,
166 const Vector& u, const Matrix& Q) const;
167
177 State predict2(const State& p, const Matrix& A0, const Matrix& A1,
178 const Vector& b, const SharedDiagonal& model = nullptr) const;
179
196 State update(const State& p, const Matrix& H, const Vector& z,
197 const SharedDiagonal& model) const;
198
207 State updateQ(const State& p, const Matrix& H, const Vector& z,
208 const Matrix& R) const;
209
214 size_t dim() const { return n_; }
215};
216
217} // namespace gtsam
Linear Factor Graph where all factors are Gaussians.
A Gaussian Density.
std::pair< std::shared_ptr< GaussianConditional >, std::shared_ptr< HessianFactor > > EliminateCholesky(const GaussianFactorGraph &factors, const Ordering &keys)
Densely partially eliminate with Cholesky factorization.
Definition HessianFactor.cpp:621
Global functions in a separate testing namespace.
Definition chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
std::pair< GaussianConditional::shared_ptr, JacobianFactor::shared_ptr > EliminateQR(const GaussianFactorGraph &factors, const Ordering &keys)
Multiply all factors and eliminate the given keys from the resulting factor using a QR variant that h...
Definition JacobianFactor.cpp:976
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
std::function< EliminationResult(const FactorGraphType &, const Ordering &)> Eliminate
Definition EliminateableFactorGraph.h:91
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
Factorization
Specifies the factorization variant to use.
Definition KalmanFilter.h:48
KalmanFilter(size_t n, Factorization method=KALMANFILTER_DEFAULT_FACTORIZATION)
Constructor.
Definition KalmanFilter.h:84
static Key step(const State &p)
Return the step index (starts at 0, incremented at each predict step).
Definition KalmanFilter.h:126
GaussianDensity::shared_ptr State
The Kalman filter state, represented as a shared pointer to a GaussianDensity.
Definition KalmanFilter.h:55
size_t dim() const
Return the dimensionality of the state.
Definition KalmanFilter.h:214