gtsam 4.1.1
gtsam
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
32namespace gtsam {
33
34#ifdef GTSAM_TANGENT_PREINTEGRATION
35typedef TangentPreintegration PreintegrationType;
36#else
37typedef ManifoldPreintegration PreintegrationType;
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
65
69 : biasAccCovariance(I_3x3),
70 biasOmegaCovariance(I_3x3),
71 biasAccOmegaInt(I_6x6) {}
72
74 PreintegrationCombinedParams(const Vector3& n_gravity) :
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
101private:
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
114public:
116};
117
129
130public:
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 */
140 Eigen::Matrix<double, 15, 15> preintMeasCov_;
141
142 friend class CombinedImuFactor;
143
144 public:
147
150 preintMeasCov_.setZero();
151 }
152
159 const boost::shared_ptr<Params>& p,
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;
201 bool equals(const PreintegratedCombinedMeasurements& expected,
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
231public:
233};
234
254class GTSAM_EXPORT CombinedImuFactor: public NoiseModelFactor6<Pose3, Vector3, Pose3,
255 Vector3, imuBias::ConstantBias, imuBias::ConstantBias> {
256public:
257
258private:
259
260 typedef CombinedImuFactor This;
261 typedef NoiseModelFactor6<Pose3, Vector3, Pose3, Vector3,
263
265
266public:
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
301 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
320 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
337public:
339};
340// class CombinedImuFactor
341
342template <>
344 : public Testable<PreintegrationCombinedParams> {};
345
346template <>
348 : public Testable<PreintegratedCombinedMeasurements> {};
349
350template <>
351struct traits<CombinedImuFactor> : public Testable<CombinedImuFactor> {};
352
353} // namespace gtsam
354
356BOOST_CLASS_EXPORT_KEY(gtsam::PreintegrationCombinedParams)
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
This marks a GTSAM object to require alignment.
Definition: types.h:277
typedef and functions to augment Eigen's MatrixXd
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:112
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
Definition: Pose3.h:37
This is the base class for all factor types.
Definition: Factor.h:56
Parameters for pre-integration using PreintegratedCombinedMeasurements: Usage: Create just a single P...
Definition: CombinedImuFactor.h:61
Matrix6 biasAccOmegaInt
covariance of bias used for pre-integration
Definition: CombinedImuFactor.h:64
PreintegrationCombinedParams(const Vector3 &n_gravity)
See two named constructors below for good values of n_gravity in body frame.
Definition: CombinedImuFactor.h:74
PreintegrationCombinedParams()
Default constructor makes uninitialized params struct.
Definition: CombinedImuFactor.h:68
Matrix3 biasOmegaCovariance
continuous-time "Covariance" describing gyroscope bias random walk
Definition: CombinedImuFactor.h:63
Matrix3 biasAccCovariance
continuous-time "Covariance" describing accelerometer bias random walk
Definition: CombinedImuFactor.h:62
Definition: CombinedImuFactor.h:128
PreintegratedCombinedMeasurements(const PreintegrationType &base, const Eigen::Matrix< double, 15, 15 > &preintMeasCov)
Construct preintegrated directly from members: base class and preintMeasCov.
Definition: CombinedImuFactor.h:170
~PreintegratedCombinedMeasurements() override
Virtual destructor.
Definition: CombinedImuFactor.h:176
PreintegratedCombinedMeasurements()
Default constructor only for serialization and wrappers.
Definition: CombinedImuFactor.h:149
Params & p() const
const reference to params, shadows definition in base class
Definition: CombinedImuFactor.h:187
PreintegratedCombinedMeasurements(const boost::shared_ptr< Params > &p, const imuBias::ConstantBias &biasHat=imuBias::ConstantBias())
Default constructor, initializes the class with no measurements.
Definition: CombinedImuFactor.h:158
Definition: CombinedImuFactor.h:255
boost::shared_ptr< CombinedImuFactor > shared_ptr
Shorthand for a smart pointer to a factor.
Definition: CombinedImuFactor.h:272
CombinedImuFactor()
Default constructor - only use for serialization.
Definition: CombinedImuFactor.h:276
const PreintegratedCombinedMeasurements & preintegratedMeasurements() const
Access the preintegrated measurements.
Definition: CombinedImuFactor.h:313
Definition: ImuBias.h:30
IMU pre-integration on NavSatet manifold.
Definition: ManifoldPreintegration.h:33
Parameters for pre-integration: Usage: Create just a single Params and pass a shared pointer to the c...
Definition: PreintegrationParams.h:26
A convenient base class for creating your own NoiseModelFactor with 6 variables.
Definition: NonlinearFactor.h:687
Convenience functions for serializing data structures via boost.serialization.