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 */
29 #include <gtsam/base/Matrix.h>
31 
32 namespace gtsam {
33 
34 #ifdef GTSAM_TANGENT_PREINTEGRATION
35 typedef TangentPreintegration PreintegrationType;
36 #else
38 #endif
39 
40 /*
41  * If you are using the factor, please cite:
42  * L. Carlone, Z. Kira, C. Beall, V. Indelman, F. Dellaert, Eliminating
43  * conditionally independent sets in factor graphs: a unifying perspective based
44  * on smart factors, Int. Conf. on Robotics and Automation (ICRA), 2014.
45  *
46  * REFERENCES:
47  * [1] G.S. Chirikjian, "Stochastic Models, Information Theory, and Lie Groups",
48  * Volume 2, 2008.
49  * [2] T. Lupton and S.Sukkarieh, "Visual-Inertial-Aided Navigation for
50  * High-Dynamic Motion in Built Environments Without Initial Conditions",
51  * TRO, 28(1):61-76, 2012.
52  * [3] L. Carlone, S. Williams, R. Roberts, "Preintegrated IMU factor:
53  * Computation of the Jacobian Matrices", Tech. Report, 2013.
54  * [4] C. Forster, L. Carlone, F. Dellaert, D. Scaramuzza, IMU Preintegration on
55  * Manifold for Efficient Visual-Inertial Maximum-a-Posteriori Estimation,
56  * Robotics: Science and Systems (RSS), 2015.
57  */
58 
64  Matrix6 biasAccOmegaInt;
65 
69  : biasAccCovariance(I_3x3),
70  biasOmegaCovariance(I_3x3),
71  biasAccOmegaInt(I_6x6) {}
72 
75  PreintegrationParams(n_gravity), biasAccCovariance(I_3x3),
76  biasOmegaCovariance(I_3x3), biasAccOmegaInt(I_6x6) {
77 
78  }
79 
80  // Default Params for a Z-down navigation frame, such as NED: gravity points along positive Z-axis
81  static boost::shared_ptr<PreintegrationCombinedParams> MakeSharedD(double g = 9.81) {
82  return boost::shared_ptr<PreintegrationCombinedParams>(new PreintegrationCombinedParams(Vector3(0, 0, g)));
83  }
84 
85  // Default Params for a Z-up navigation frame, such as ENU: gravity points along negative Z-axis
86  static boost::shared_ptr<PreintegrationCombinedParams> MakeSharedU(double g = 9.81) {
87  return boost::shared_ptr<PreintegrationCombinedParams>(new PreintegrationCombinedParams(Vector3(0, 0, -g)));
88  }
89 
90  void print(const std::string& s="") const override;
91  bool equals(const PreintegratedRotationParams& other, double tol) const override;
92 
93  void setBiasAccCovariance(const Matrix3& cov) { biasAccCovariance=cov; }
94  void setBiasOmegaCovariance(const Matrix3& cov) { biasOmegaCovariance=cov; }
95  void setBiasAccOmegaInt(const Matrix6& cov) { biasAccOmegaInt=cov; }
96 
97  const Matrix3& getBiasAccCovariance() const { return biasAccCovariance; }
98  const Matrix3& getBiasOmegaCovariance() const { return biasOmegaCovariance; }
99  const Matrix6& getBiasAccOmegaInt() const { return biasAccOmegaInt; }
100 
101 private:
102 
104  friend class boost::serialization::access;
105  template <class ARCHIVE>
106  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
107  namespace bs = ::boost::serialization;
108  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(PreintegrationParams);
109  ar & BOOST_SERIALIZATION_NVP(biasAccCovariance);
110  ar & BOOST_SERIALIZATION_NVP(biasOmegaCovariance);
111  ar & BOOST_SERIALIZATION_NVP(biasAccOmegaInt);
112  }
113 
114 public:
116 };
117 
128 class GTSAM_EXPORT PreintegratedCombinedMeasurements : public PreintegrationType {
129 
130 public:
132 
133  protected:
134  /* Covariance matrix of the preintegrated measurements
135  * COVARIANCE OF: [PreintROTATION PreintPOSITION PreintVELOCITY BiasAcc BiasOmega]
136  * (first-order propagation from *measurementCovariance*).
137  * PreintegratedCombinedMeasurements also include the biases and keep the correlation
138  * between the preintegrated measurements and the biases
139  */
141 
142  friend class CombinedImuFactor;
143 
144  public:
147 
150  preintMeasCov_.setZero();
151  }
152 
159  const boost::shared_ptr<Params>& p,
160  const imuBias::ConstantBias& biasHat = imuBias::ConstantBias())
161  : PreintegrationType(p, biasHat) {
162  preintMeasCov_.setZero();
163  }
164 
170  PreintegratedCombinedMeasurements(const PreintegrationType& base, const Eigen::Matrix<double, 15, 15>& preintMeasCov)
171  : PreintegrationType(base),
172  preintMeasCov_(preintMeasCov) {
173  }
174 
177 
179 
182 
184  void resetIntegration() override;
185 
187  Params& p() const { return *boost::static_pointer_cast<Params>(this->p_); }
189 
193  Matrix preintMeasCov() const { return preintMeasCov_; }
195 
199  void print(const std::string& s = "Preintegrated Measurements:") const override;
202  double tol = 1e-9) const;
204 
205 
208 
216  void integrateMeasurement(const Vector3& measuredAcc,
217  const Vector3& measuredOmega, const double dt) override;
218 
220 
221  private:
223  friend class boost::serialization::access;
224  template <class ARCHIVE>
225  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
226  namespace bs = ::boost::serialization;
227  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(PreintegrationType);
228  ar& BOOST_SERIALIZATION_NVP(preintMeasCov_);
229  }
230 
231 public:
233 };
234 
254 class GTSAM_EXPORT CombinedImuFactor: public NoiseModelFactor6<Pose3, Vector3, Pose3,
255  Vector3, imuBias::ConstantBias, imuBias::ConstantBias> {
256 public:
257 
258 private:
259 
261  typedef NoiseModelFactor6<Pose3, Vector3, Pose3, Vector3,
263 
265 
266 public:
267 
269 #if !defined(_MSC_VER) && __GNUC__ == 4 && __GNUC_MINOR__ > 5
270  typedef typename boost::shared_ptr<CombinedImuFactor> shared_ptr;
271 #else
272  typedef boost::shared_ptr<CombinedImuFactor> shared_ptr;
273 #endif
274 
277 
289  Key pose_i, Key vel_i, Key pose_j, Key vel_j, Key bias_i, Key bias_j,
290  const PreintegratedCombinedMeasurements& preintegratedMeasurements);
291 
292  ~CombinedImuFactor() override {}
293 
295  gtsam::NonlinearFactor::shared_ptr clone() const override;
296 
299  GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
302  const CombinedImuFactor&);
304  void print(const std::string& s = "", const KeyFormatter& keyFormatter =
305  DefaultKeyFormatter) const override;
306 
308  bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
310 
314  return _PIM_;
315  }
316 
319  Vector evaluateError(const Pose3& pose_i, const Vector3& vel_i,
321  const Pose3& pose_j, const Vector3& vel_j,
322  const imuBias::ConstantBias& bias_i, const imuBias::ConstantBias& bias_j,
323  boost::optional<Matrix&> H1 = boost::none, boost::optional<Matrix&> H2 =
324  boost::none, boost::optional<Matrix&> H3 = boost::none,
325  boost::optional<Matrix&> H4 = boost::none, boost::optional<Matrix&> H5 =
326  boost::none, boost::optional<Matrix&> H6 = boost::none) const override;
327 
328  private:
330  friend class boost::serialization::access;
331  template <class ARCHIVE>
332  void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
333  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(NoiseModelFactor6);
334  ar& BOOST_SERIALIZATION_NVP(_PIM_);
335  }
336 
337 public:
339 };
340 // class CombinedImuFactor
341 
342 template <>
344  : public Testable<PreintegrationCombinedParams> {};
345 
346 template <>
348  : public Testable<PreintegratedCombinedMeasurements> {};
349 
350 template <>
351 struct traits<CombinedImuFactor> : public Testable<CombinedImuFactor> {};
352 
353 } // namespace gtsam
354 
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
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
static boost::shared_ptr< PreintegrationCombinedParams > MakeSharedU(double g=9.81)
Matrix6 biasAccOmegaInt
covariance of bias used for pre-integration
Matrix expected
Definition: testMatrix.cpp:974
const Matrix6 & getBiasAccOmegaInt() const
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:43
PreintegratedCombinedMeasurements()
Default constructor only for serialization and wrappers.
void setBiasAccCovariance(const Matrix3 &cov)
const Matrix3 & getBiasOmegaCovariance() const
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
NoiseModelFactor6< Pose3, Vector3, Pose3, Vector3, imuBias::ConstantBias, imuBias::ConstantBias > Base
void g(const string &key, int i)
Definition: testBTree.cpp:43
void setBiasAccOmegaInt(const Matrix6 &cov)
const Matrix3 & getBiasAccCovariance() const
const double dt
void setBiasOmegaCovariance(const Matrix3 &cov)
Eigen::VectorXd Vector
Definition: Vector.h:38
ManifoldPreintegration PreintegrationType
~PreintegratedCombinedMeasurements() override
Virtual destructor.
boost::shared_ptr< This > shared_ptr
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
boost::shared_ptr< CombinedImuFactor > shared_ptr
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
static const Vector3 measuredAcc
PreintegrationCombinedParams(const Vector3 &n_gravity)
See two named constructors below for good values of n_gravity in body frame.
void serialize(ARCHIVE &ar, const unsigned int)
traits
Definition: chartTesting.h:28
Matrix3 biasOmegaCovariance
continuous-time "Covariance" describing gyroscope bias random walk
PreintegratedCombinedMeasurements _PIM_
static const Vector3 measuredOmega(w, 0, 0)
boost::shared_ptr< Factor > shared_ptr
A shared_ptr to this class.
Definition: Factor.h:60
Non-linear factor base classes.
ofstream os("timeSchurFactors.csv")
Eigen::Matrix< double, 15, 15 > preintMeasCov_
BOOST_CLASS_EXPORT_KEY(gtsam::PreintegrationCombinedParams)
Add Boost serialization export key (declaration) for derived class.
void serialize(ARCHIVE &ar, const unsigned int)
PreintegratedCombinedMeasurements(const boost::shared_ptr< Params > &p, const imuBias::ConstantBias &biasHat=imuBias::ConstantBias())
float * p
Params & p() const
const reference to params, shadows definition in base class
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
Definition: types.h:269
void serialize(ARCHIVE &ar, const unsigned int)
Annotation indicating that a class derives from another given type.
Definition: attr.h:42
const G double tol
Definition: Group.h:83
PreintegratedCombinedMeasurements(const PreintegrationType &base, const Eigen::Matrix< double, 15, 15 > &preintMeasCov)
static boost::shared_ptr< PreintegrationCombinedParams > MakeSharedD(double g=9.81)
const PreintegratedCombinedMeasurements & preintegratedMeasurements() const
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
Matrix3 biasAccCovariance
continuous-time "Covariance" describing accelerometer bias random walk


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:48