CombinedImuFactor.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 
23 #pragma once
24 
25 /* GTSAM includes */
27 
28 namespace gtsam {
29 
30 #ifdef GTSAM_TANGENT_PREINTEGRATION
31 typedef TangentPreintegration PreintegrationType;
32 #else
34 #endif
35 
36 /*
37  * If you are using the factor, please cite:
38  * L. Carlone, Z. Kira, C. Beall, V. Indelman, F. Dellaert, Eliminating
39  * conditionally independent sets in factor graphs: a unifying perspective based
40  * on smart factors, Int. Conf. on Robotics and Automation (ICRA), 2014.
41  *
42  * REFERENCES:
43  * [1] G.S. Chirikjian, "Stochastic Models, Information Theory, and Lie Groups",
44  * Volume 2, 2008.
45  * [2] T. Lupton and S.Sukkarieh, "Visual-Inertial-Aided Navigation for
46  * High-Dynamic Motion in Built Environments Without Initial Conditions",
47  * TRO, 28(1):61-76, 2012.
48  * [3] L. Carlone, S. Williams, R. Roberts, "Preintegrated IMU factor:
49  * Computation of the Jacobian Matrices", Tech. Report, 2013.
50  * Available in this repo as "PreintegratedIMUJacobians.pdf".
51  * [4] C. Forster, L. Carlone, F. Dellaert, D. Scaramuzza, IMU Preintegration on
52  * Manifold for Efficient Visual-Inertial Maximum-a-Posteriori Estimation,
53  * Robotics: Science and Systems (RSS), 2015.
54  */
55 
67  : public PreintegrationType {
68  public:
70 
71  protected:
72  /* Covariance matrix of the preintegrated measurements
73  * COVARIANCE OF: [PreintROTATION PreintPOSITION PreintVELOCITY BiasAcc
74  * BiasOmega] (first-order propagation from *measurementCovariance*).
75  * PreintegratedCombinedMeasurements also include the biases and keep the
76  * correlation between the preintegrated measurements and the biases
77  */
79 
80  friend class CombinedImuFactor;
81 
82  public:
85 
88 
96  const std::shared_ptr<Params>& p,
98  const Eigen::Matrix<double, 15, 15>& preintMeasCov =
100  : PreintegrationType(p, biasHat), preintMeasCov_(preintMeasCov) {}
101 
109  const PreintegrationType& base,
110  const Eigen::Matrix<double, 15, 15>& preintMeasCov)
111  : PreintegrationType(base), preintMeasCov_(preintMeasCov) {}
112 
115 
117 
120 
122  void resetIntegration() override;
123 
130  void resetIntegration(const gtsam::Matrix6& Q_init);
131 
133  Params& p() const { return *std::static_pointer_cast<Params>(this->p_); }
135 
139  Matrix preintMeasCov() const { return preintMeasCov_; }
141 
145  void print(
146  const std::string& s = "Preintegrated Measurements:") const override;
149  double tol = 1e-9) const;
151 
154 
165  void integrateMeasurement(const Vector3& measuredAcc,
166  const Vector3& measuredOmega,
167  const double dt) override;
168 
170 
171  private:
172 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
173  friend class boost::serialization::access;
175  template <class ARCHIVE>
176  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
177  namespace bs = ::boost::serialization;
178  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(PreintegrationType);
179  ar& BOOST_SERIALIZATION_NVP(preintMeasCov_);
180  }
181 #endif
182 
183  public:
185 };
186 
205 class GTSAM_EXPORT CombinedImuFactor
206  : public NoiseModelFactorN<Pose3, Vector3, Pose3, Vector3,
207  imuBias::ConstantBias, imuBias::ConstantBias> {
208  public:
209  private:
211  typedef NoiseModelFactorN<Pose3, Vector3, Pose3, Vector3,
212  imuBias::ConstantBias, imuBias::ConstantBias>
214 
216 
217  public:
218  // Provide access to Matrix& version of evaluateError:
219  using Base::evaluateError;
220 
222 #if !defined(_MSC_VER) && __GNUC__ == 4 && __GNUC_MINOR__ > 5
223  typedef typename std::shared_ptr<CombinedImuFactor> shared_ptr;
224 #else
225  typedef std::shared_ptr<CombinedImuFactor> shared_ptr;
226 #endif
227 
230 
242  Key pose_i, Key vel_i, Key pose_j, Key vel_j, Key bias_i, Key bias_j,
243  const PreintegratedCombinedMeasurements& preintegratedMeasurements);
244 
245  ~CombinedImuFactor() override {}
246 
248  gtsam::NonlinearFactor::shared_ptr clone() const override;
249 
252  GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
255  const CombinedImuFactor&);
257  void print(const std::string& s = "", const KeyFormatter& keyFormatter =
258  DefaultKeyFormatter) const override;
259 
261  bool equals(const NonlinearFactor& expected,
262  double tol = 1e-9) const override;
264 
268  return _PIM_;
269  }
270 
273  Vector evaluateError(const Pose3& pose_i, const Vector3& vel_i,
275  const Pose3& pose_j, const Vector3& vel_j,
276  const imuBias::ConstantBias& bias_i,
277  const imuBias::ConstantBias& bias_j,
281  OptionalMatrixType H6) const override;
282 
283  private:
284 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
285 
286  friend class boost::serialization::access;
287  template <class ARCHIVE>
288  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
289  // NoiseModelFactor6 instead of NoiseModelFactorN for backward compatibility
290  ar& boost::serialization::make_nvp(
291  "NoiseModelFactor6", boost::serialization::base_object<Base>(*this));
292  ar& BOOST_SERIALIZATION_NVP(_PIM_);
293  }
294 #endif
295 
296  public:
298 };
299 // class CombinedImuFactor
300 
301 template <>
303  : public Testable<PreintegrationCombinedParams> {};
304 
305 template <>
307  : public Testable<PreintegratedCombinedMeasurements> {};
308 
309 template <>
310 struct traits<CombinedImuFactor> : public Testable<CombinedImuFactor> {};
311 
312 } // namespace gtsam
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
PreintegrationCombinedParams Params
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
std::ostream & operator<<(std::ostream &os, const Dih6 &m)
Definition: testGroup.cpp:109
Eigen::Vector3d Vector3
Definition: Vector.h:43
std::shared_ptr< CombinedImuFactor > shared_ptr
std::string serialize(const T &input)
serializes to a string
Matrix expected
Definition: testMatrix.cpp:971
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
Params & p() const
const reference to params, shadows definition in base class
PreintegratedCombinedMeasurements()
Default constructor only for serialization and wrappers.
const PreintegratedCombinedMeasurements & preintegratedMeasurements() const
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
const double dt
Matrix * OptionalMatrixType
Eigen::VectorXd Vector
Definition: Vector.h:38
ManifoldPreintegration PreintegrationType
~PreintegratedCombinedMeasurements() override
Virtual destructor.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
static const Vector3 measuredAcc
std::shared_ptr< Factor > shared_ptr
A shared_ptr to this class.
Definition: Factor.h:75
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
traits
Definition: chartTesting.h:28
PreintegratedCombinedMeasurements _PIM_
static const Vector3 measuredOmega(w, 0, 0)
ofstream os("timeSchurFactors.csv")
Eigen::Matrix< double, 15, 15 > preintMeasCov_
std::shared_ptr< This > shared_ptr
float * p
NoiseModelFactorN< Pose3, Vector3, Pose3, Vector3, imuBias::ConstantBias, imuBias::ConstantBias > Base
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
Definition: types.h:284
const G double tol
Definition: Group.h:86
Annotation indicating that a class derives from another given type.
Definition: attr.h:61
PreintegratedCombinedMeasurements(const PreintegrationType &base, const Eigen::Matrix< double, 15, 15 > &preintMeasCov)
PreintegratedCombinedMeasurements(const std::shared_ptr< Params > &p, const imuBias::ConstantBias &biasHat=imuBias::ConstantBias(), const Eigen::Matrix< double, 15, 15 > &preintMeasCov=Eigen::Matrix< double, 15, 15 >::Zero())
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:02