gtsam  4.0.0
gtsam
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 
27 namespace gtsam {
28 
31 struct GTSAM_EXPORT PreintegratedRotationParams {
33  boost::optional<Vector3> omegaCoriolis;
34  boost::optional<Pose3> body_P_sensor;
35 
36  PreintegratedRotationParams() : gyroscopeCovariance(I_3x3) {}
37 
38  virtual ~PreintegratedRotationParams() {}
39 
40  virtual void print(const std::string& s) const;
41  virtual bool equals(const PreintegratedRotationParams& other, double tol=1e-9) const;
42 
43  void setGyroscopeCovariance(const Matrix3& cov) { gyroscopeCovariance = cov; }
44  void setOmegaCoriolis(const Vector3& omega) { omegaCoriolis.reset(omega); }
45  void setBodyPSensor(const Pose3& pose) { body_P_sensor.reset(pose); }
46 
47  const Matrix3& getGyroscopeCovariance() const { return gyroscopeCovariance; }
48  boost::optional<Vector3> getOmegaCoriolis() const { return omegaCoriolis; }
49  boost::optional<Pose3> getBodyPSensor() const { return body_P_sensor; }
50 
51  private:
53  friend class boost::serialization::access;
54  template<class ARCHIVE>
55  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
56  namespace bs = ::boost::serialization;
57  ar & bs::make_nvp("gyroscopeCovariance", bs::make_array(gyroscopeCovariance.data(), gyroscopeCovariance.size()));
58  ar & BOOST_SERIALIZATION_NVP(omegaCoriolis);
59  ar & BOOST_SERIALIZATION_NVP(body_P_sensor);
60  }
61 
62 #ifdef GTSAM_USE_QUATERNIONS
63  // Align if we are using Quaternions
64 public:
65  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
66 #endif
67 };
68 
74 class GTSAM_EXPORT PreintegratedRotation {
75  public:
77 
78  protected:
80  boost::shared_ptr<Params> p_;
81 
82  double deltaTij_;
85 
88 
89  public:
92 
94  explicit PreintegratedRotation(const boost::shared_ptr<Params>& p) : p_(p) {
95  resetIntegration();
96  }
97 
99  PreintegratedRotation(const boost::shared_ptr<Params>& p,
100  double deltaTij, const Rot3& deltaRij,
101  const Matrix3& delRdelBiasOmega)
102  : p_(p), deltaTij_(deltaTij), deltaRij_(deltaRij), delRdelBiasOmega_(delRdelBiasOmega) {}
103 
105 
108 
110  void resetIntegration();
111 
113  bool matchesParamsWith(const PreintegratedRotation& other) const {
114  return p_ == other.p_;
115  }
117 
120  const boost::shared_ptr<Params>& params() const {
121  return p_;
122  }
123  const double& deltaTij() const {
124  return deltaTij_;
125  }
126  const Rot3& deltaRij() const {
127  return deltaRij_;
128  }
129  const Matrix3& delRdelBiasOmega() const {
130  return delRdelBiasOmega_;
131  }
133 
136  void print(const std::string& s) const;
137  bool equals(const PreintegratedRotation& other, double tol) const;
139 
142 
146  Rot3 incrementalRotation(const Vector3& measuredOmega, const Vector3& biasHat, double deltaT,
147  OptionalJacobian<3, 3> D_incrR_integratedOmega) const;
148 
151  void integrateMeasurement(const Vector3& measuredOmega, const Vector3& biasHat, double deltaT,
152  OptionalJacobian<3, 3> D_incrR_integratedOmega = boost::none,
153  OptionalJacobian<3, 3> F = boost::none);
154 
156  Rot3 biascorrectedDeltaRij(const Vector3& biasOmegaIncr,
157  OptionalJacobian<3, 3> H = boost::none) const;
158 
160  Vector3 integrateCoriolis(const Rot3& rot_i) const;
161 
163 
164  private:
166  friend class boost::serialization::access;
167  template <class ARCHIVE>
168  void serialize(ARCHIVE& ar, const unsigned int /*version*/) { // NOLINT
169  ar& BOOST_SERIALIZATION_NVP(p_);
170  ar& BOOST_SERIALIZATION_NVP(deltaTij_);
171  ar& BOOST_SERIALIZATION_NVP(deltaRij_);
172  ar& BOOST_SERIALIZATION_NVP(delRdelBiasOmega_);
173  }
174 
175 #ifdef GTSAM_USE_QUATERNIONS
176  // Align if we are using Quaternions
177  public:
178  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
179 #endif
180 };
181 
182 template <>
183 struct traits<PreintegratedRotation> : public Testable<PreintegratedRotation> {};
184 
185 }
double deltaTij_
Time interval from i to j.
Definition: PreintegratedRotation.h:82
PreintegratedRotation is the base class for all PreintegratedMeasurements classes (in AHRSFactor,...
Definition: PreintegratedRotation.h:74
bool matchesParamsWith(const PreintegratedRotation &other) const
check parameters equality: checks whether shared pointer points to same Params object.
Definition: PreintegratedRotation.h:113
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
Parameters for pre-integration: Usage: Create just a single Params and pass a shared pointer to the c...
Definition: PreintegratedRotation.h:31
PreintegratedRotation()
Default constructor for serialization.
Definition: PreintegratedRotation.h:87
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
Rot3 deltaRij_
Preintegrated relative orientation (in frame i)
Definition: PreintegratedRotation.h:83
Definition: Rot3.h:56
PreintegratedRotation(const boost::shared_ptr< Params > &p, double deltaTij, const Rot3 &deltaRij, const Matrix3 &delRdelBiasOmega)
Explicit initialization of all class members.
Definition: PreintegratedRotation.h:99
boost::shared_ptr< Params > p_
Parameters.
Definition: PreintegratedRotation.h:80
Matrix3 gyroscopeCovariance
continuous-time "Covariance" of gyroscope measurements
Definition: PreintegratedRotation.h:32
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
Matrix3 delRdelBiasOmega_
Jacobian of preintegrated rotation w.r.t. angular rate bias.
Definition: PreintegratedRotation.h:84
3D Pose
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
PreintegratedRotation(const boost::shared_ptr< Params > &p)
Default constructor, resets integration to zero.
Definition: PreintegratedRotation.h:94
typedef and functions to augment Eigen's MatrixXd
boost::optional< Vector3 > omegaCoriolis
Coriolis constant.
Definition: PreintegratedRotation.h:33
boost::optional< Pose3 > body_P_sensor
The pose of the sensor in the body frame.
Definition: PreintegratedRotation.h:34