GTSAM  4.0.2
C++ library for smoothing and mapping (SAM)
PreintegratedRotation.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 
22 #pragma once
23 
24 #include <gtsam/geometry/Pose3.h>
25 #include <gtsam/base/Matrix.h>
26 #include <gtsam/base/std_optional_serialization.h>
27 
28 namespace gtsam {
29 
32 struct GTSAM_EXPORT PreintegratedRotationParams {
36  std::optional<Vector3> omegaCoriolis;
37  std::optional<Pose3> body_P_sensor;
38 
39  PreintegratedRotationParams() : gyroscopeCovariance(I_3x3) {}
40 
41  PreintegratedRotationParams(const Matrix3& gyroscope_covariance,
42  std::optional<Vector3> omega_coriolis)
43  : gyroscopeCovariance(gyroscope_covariance) {
44  if (omega_coriolis) {
45  omegaCoriolis = *omega_coriolis;
46  }
47  }
48 
49  virtual ~PreintegratedRotationParams() {}
50 
51  virtual void print(const std::string& s) const;
52  virtual bool equals(const PreintegratedRotationParams& other, double tol=1e-9) const;
53 
54  void setGyroscopeCovariance(const Matrix3& cov) { gyroscopeCovariance = cov; }
55  void setOmegaCoriolis(const Vector3& omega) { omegaCoriolis = omega; }
56  void setBodyPSensor(const Pose3& pose) { body_P_sensor = pose; }
57 
58  const Matrix3& getGyroscopeCovariance() const { return gyroscopeCovariance; }
59  std::optional<Vector3> getOmegaCoriolis() const { return omegaCoriolis; }
60  std::optional<Pose3> getBodyPSensor() const { return body_P_sensor; }
61 
62  private:
63 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
64 
65  friend class boost::serialization::access;
66  template<class ARCHIVE>
67  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
68  namespace bs = ::boost::serialization;
69  ar & BOOST_SERIALIZATION_NVP(gyroscopeCovariance);
70  ar & BOOST_SERIALIZATION_NVP(body_P_sensor);
71 
72  // Provide support for Eigen::Matrix in std::optional
73  bool omegaCoriolisFlag = omegaCoriolis.has_value();
74  ar & boost::serialization::make_nvp("omegaCoriolisFlag", omegaCoriolisFlag);
75  if (omegaCoriolisFlag) {
76  ar & BOOST_SERIALIZATION_NVP(*omegaCoriolis);
77  }
78  }
79 #endif
80 
81 #ifdef GTSAM_USE_QUATERNIONS
82  // Align if we are using Quaternions
83 public:
85 #endif
86 };
87 
93 class GTSAM_EXPORT PreintegratedRotation {
94  public:
96 
97  protected:
99  std::shared_ptr<Params> p_;
100 
101  double deltaTij_;
104 
107 
108  public:
111 
113  explicit PreintegratedRotation(const std::shared_ptr<Params>& p) : p_(p) {
114  resetIntegration();
115  }
116 
118  PreintegratedRotation(const std::shared_ptr<Params>& p,
119  double deltaTij, const Rot3& deltaRij,
120  const Matrix3& delRdelBiasOmega)
121  : p_(p), deltaTij_(deltaTij), deltaRij_(deltaRij), delRdelBiasOmega_(delRdelBiasOmega) {}
122 
124 
127 
129  void resetIntegration();
130 
132  bool matchesParamsWith(const PreintegratedRotation& other) const {
133  return p_ == other.p_;
134  }
136 
139  const std::shared_ptr<Params>& params() const {
140  return p_;
141  }
142  const double& deltaTij() const {
143  return deltaTij_;
144  }
145  const Rot3& deltaRij() const {
146  return deltaRij_;
147  }
148  const Matrix3& delRdelBiasOmega() const {
149  return delRdelBiasOmega_;
150  }
152 
155  void print(const std::string& s) const;
156  bool equals(const PreintegratedRotation& other, double tol) const;
158 
161 
165  Rot3 incrementalRotation(const Vector3& measuredOmega, const Vector3& biasHat, double deltaT,
166  OptionalJacobian<3, 3> D_incrR_integratedOmega) const;
167 
170  void integrateMeasurement(const Vector3& measuredOmega, const Vector3& biasHat, double deltaT,
171  OptionalJacobian<3, 3> D_incrR_integratedOmega = {},
172  OptionalJacobian<3, 3> F = {});
173 
175  Rot3 biascorrectedDeltaRij(const Vector3& biasOmegaIncr,
176  OptionalJacobian<3, 3> H = {}) const;
177 
179  Vector3 integrateCoriolis(const Rot3& rot_i) const;
180 
182 
183  private:
184 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
185 
186  friend class boost::serialization::access;
187  template <class ARCHIVE>
188  void serialize(ARCHIVE& ar, const unsigned int /*version*/) { // NOLINT
189  ar& BOOST_SERIALIZATION_NVP(p_);
190  ar& BOOST_SERIALIZATION_NVP(deltaTij_);
191  ar& BOOST_SERIALIZATION_NVP(deltaRij_);
192  ar& BOOST_SERIALIZATION_NVP(delRdelBiasOmega_);
193  }
194 #endif
195 
196 #ifdef GTSAM_USE_QUATERNIONS
197  // Align if we are using Quaternions
198  public:
200 #endif
201 };
202 
203 template <>
204 struct traits<PreintegratedRotation> : public Testable<PreintegratedRotation> {};
205 
206 }
bool matchesParamsWith(const PreintegratedRotation &other) const
check parameters equality: checks whether shared pointer points to same Params object.
Definition: PreintegratedRotation.h:132
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
PreintegratedRotation(const std::shared_ptr< Params > &p)
Default constructor, resets integration to zero.
Definition: PreintegratedRotation.h:113
Definition: Testable.h:152
Definition: Group.h:43
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition: Rot3.h:58
Definition: Testable.h:112
PreintegratedRotation(const std::shared_ptr< Params > &p, double deltaTij, const Rot3 &deltaRij, const Matrix3 &delRdelBiasOmega)
Explicit initialization of all class members.
Definition: PreintegratedRotation.h:118
PreintegratedRotation()
Default constructor for serialization.
Definition: PreintegratedRotation.h:106
Matrix3 delRdelBiasOmega_
Jacobian of preintegrated rotation w.r.t. angular rate bias.
Definition: PreintegratedRotation.h:103
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
std::optional< Vector3 > omegaCoriolis
Coriolis constant.
Definition: PreintegratedRotation.h:36
typedef and functions to augment Eigen&#39;s MatrixXd
Definition: chartTesting.h:28
Definition: OptionalJacobian.h:38
Definition: PreintegratedRotation.h:93
std::optional< Pose3 > body_P_sensor
The pose of the sensor in the body frame.
Definition: PreintegratedRotation.h:37
std::shared_ptr< Params > p_
Parameters.
Definition: PreintegratedRotation.h:99
Definition: PreintegratedRotation.h:32
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
Definition: types.h:284
Rot3 deltaRij_
Preintegrated relative orientation (in frame i)
Definition: PreintegratedRotation.h:102
Matrix3 gyroscopeCovariance
Definition: PreintegratedRotation.h:35
3D Pose
Definition: Pose3.h:37
double deltaTij_
Time interval from i to j.
Definition: PreintegratedRotation.h:101