gtsam
Loading...
Searching...
No Matches
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
21
22#pragma once
23
24#include <gtsam/base/Matrix.h>
26#include <gtsam/base/std_optional_serialization.h>
28
29#include "gtsam/dllexport.h"
30
31namespace gtsam {
32
33namespace internal {
40struct GTSAM_EXPORT IncrementalRotation {
41 const Vector3& measuredOmega;
42 const double deltaT;
43 const std::optional<Pose3>& body_P_sensor;
44
51 Rot3 operator()(const Vector3& bias,
52 OptionalJacobian<3, 3> H_bias = {}) const;
53};
54
55} // namespace internal
56
74 const Vector& times, ConstMatrixView measuredOmegas,
75 const Vector3& biasHat = Vector3::Zero(),
76 const Rot3& body_R_sensor = Rot3());
77
95 const Vector& times, ConstMatrixView measuredOmegas,
96 const Vector3& biasHat = Vector3::Zero(),
97 const Rot3& body_R_sensor = Rot3());
98
101struct GTSAM_EXPORT PreintegratedRotationParams {
107 std::optional<Vector3> omegaCoriolis;
108 std::optional<Pose3> body_P_sensor;
109
110 PreintegratedRotationParams() : gyroscopeCovariance(I_3x3) {}
111
112 PreintegratedRotationParams(const Matrix3& gyroscope_covariance,
113 std::optional<Vector3> omega_coriolis = {},
114 std::optional<Pose3> body_P_sensor = {})
115 : gyroscopeCovariance(gyroscope_covariance),
116 omegaCoriolis(omega_coriolis),
117 body_P_sensor(body_P_sensor) {}
118
119 virtual ~PreintegratedRotationParams() {}
120
121 virtual void print(const std::string& s) const;
122 virtual bool equals(const PreintegratedRotationParams& other, double tol=1e-9) const;
123
124 void setGyroscopeCovariance(const Matrix3& cov) { gyroscopeCovariance = cov; }
125 void setOmegaCoriolis(const Vector3& omega) { omegaCoriolis = omega; }
126 void setBodyPSensor(const Pose3& pose) { body_P_sensor = pose; }
127
128 const Matrix3& getGyroscopeCovariance() const { return gyroscopeCovariance; }
129 std::optional<Vector3> getOmegaCoriolis() const { return omegaCoriolis; }
130 std::optional<Pose3> getBodyPSensor() const { return body_P_sensor; }
131
132 private:
133#if GTSAM_ENABLE_BOOST_SERIALIZATION
135 friend class boost::serialization::access;
136 template<class ARCHIVE>
137 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
138 ar & BOOST_SERIALIZATION_NVP(gyroscopeCovariance);
139 ar & BOOST_SERIALIZATION_NVP(body_P_sensor);
140
141 // Provide support for Eigen::Matrix in std::optional
142 bool omegaCoriolisFlag = omegaCoriolis.has_value();
143 ar & boost::serialization::make_nvp("omegaCoriolisFlag", omegaCoriolisFlag);
144 if (omegaCoriolisFlag) {
145 ar & BOOST_SERIALIZATION_NVP(*omegaCoriolis);
146 }
147 }
148#endif
149};
150
156class GTSAM_EXPORT PreintegratedRotation {
157 public:
158 typedef PreintegratedRotationParams Params;
159
160 protected:
162 std::shared_ptr<Params> p_;
163
164 double deltaTij_;
167
168 public:
171
174
176 explicit PreintegratedRotation(const std::shared_ptr<Params>& p) : p_(p) {
178 }
179
181 PreintegratedRotation(const std::shared_ptr<Params>& p,
182 double deltaTij, const Rot3& deltaRij,
183 const Matrix3& delRdelBiasOmega)
184 : p_(p), deltaTij_(deltaTij), deltaRij_(deltaRij), delRdelBiasOmega_(delRdelBiasOmega) {}
185
187
190
192 bool matchesParamsWith(const PreintegratedRotation& other) const {
193 return p_ == other.p_;
194 }
195
196
199 const std::shared_ptr<Params>& params() const { return p_; }
200 const double& deltaTij() const { return deltaTij_; }
201 const Rot3& deltaRij() const { return deltaRij_; }
202 const Matrix3& delRdelBiasOmega() const { return delRdelBiasOmega_; }
204
207 void print(const std::string& s) const;
208 bool equals(const PreintegratedRotation& other, double tol) const;
210
213
215 void resetIntegration();
216
225 void integrateGyroMeasurement(const Vector3& measuredOmega,
226 const Vector3& biasHat, double deltaT,
227 OptionalJacobian<3, 3> F = {});
228
235 Rot3 biascorrectedDeltaRij(const Vector3& biasOmegaIncr,
236 OptionalJacobian<3, 3> H = {}) const;
237
239
242
243#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V43
248 Vector3 integrateCoriolis(const Rot3& wRi,
249 OptionalJacobian<3, 3> H = {}) const;
250
252 inline Rot3 incrementalRotation(
253 const Vector3& measuredOmega, const Vector3& bias, double deltaT,
254 OptionalJacobian<3, 3> D_incrR_integratedOmega) const {
255 internal::IncrementalRotation f{measuredOmega, deltaT, p_->body_P_sensor};
256 Rot3 incrR = f(bias, D_incrR_integratedOmega);
257 // Backwards compatible "weird" Jacobian, no longer used.
258 if (D_incrR_integratedOmega) *D_incrR_integratedOmega /= -deltaT;
259 return incrR;
260 }
261
264 void integrateMeasurement(const Vector3& measuredOmega,
265 const Vector3& biasHat, double deltaT,
266 OptionalJacobian<3, 3> D_incrR_integratedOmega,
267 OptionalJacobian<3, 3> F);
268
269#endif
270
272
273 private:
274#if GTSAM_ENABLE_BOOST_SERIALIZATION
276 friend class boost::serialization::access;
277 template <class ARCHIVE>
278 void serialize(ARCHIVE& ar, const unsigned int /*version*/) { // NOLINT
279 ar& BOOST_SERIALIZATION_NVP(p_);
280 ar& BOOST_SERIALIZATION_NVP(deltaTij_);
281 ar& BOOST_SERIALIZATION_NVP(deltaRij_);
282 ar& BOOST_SERIALIZATION_NVP(delRdelBiasOmega_);
283 }
284#endif
285};
286
287template <>
288struct traits<PreintegratedRotation> : public Testable<PreintegratedRotation> {};
289
290}
typedef and functions to augment Eigen's MatrixXd
Macros for Matrix constants to avoid excessive template instantiation.
3D Pose manifold SO(3) x R^3 and group SE(3)
Global functions in a separate testing namespace.
Definition chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
Rot3 integrateSequentialRotations(const Vector &times, ConstMatrixView measuredOmegas, const Vector3 &biasHat, const Rot3 &body_R_sensor)
Integrate timed gyroscope samples using sequential trapezoidal rotation increments.
Definition PreintegratedRotation.cpp:145
Eigen::Ref< const Matrix, 0, Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > > ConstMatrixView
Dynamic-stride const Matrix view for accepting NumPy arrays without copies.
Definition Matrix.h:42
Rot3 integrateSingleSpeedConing(const Vector &times, ConstMatrixView measuredOmegas, const Vector3 &biasHat, const Rot3 &body_R_sensor)
Integrate timed gyroscope samples with a single-speed coning correction.
Definition PreintegratedRotation.cpp:164
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition OptionalJacobian.h:40
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition Rot3.h:65
Function object for incremental rotation.
Definition PreintegratedRotation.h:40
Rot3 operator()(const Vector3 &bias, OptionalJacobian< 3, 3 > H_bias={}) const
Integrate angular velocity, but corrected by bias.
Definition PreintegratedRotation.cpp:76
Parameters for pre-integration: Usage: Create just a single Params and pass a shared pointer to the c...
Definition PreintegratedRotation.h:101
Matrix3 gyroscopeCovariance
Continuous-time "Covariance" of gyroscope measurements The units for stddev are σ = rad/s/√Hz.
Definition PreintegratedRotation.h:104
std::optional< Vector3 > omegaCoriolis
Navigation-frame angular velocity in radians per second.
Definition PreintegratedRotation.h:107
std::optional< Pose3 > body_P_sensor
The pose of the sensor in the body frame.
Definition PreintegratedRotation.h:108
PreintegratedRotation is the base class for all PreintegratedMeasurements classes (in AHRSFactor,...
Definition PreintegratedRotation.h:156
Matrix3 delRdelBiasOmega_
Jacobian of preintegrated rotation w.r.t. angular rate bias.
Definition PreintegratedRotation.h:166
PreintegratedRotation(const std::shared_ptr< Params > &p, double deltaTij, const Rot3 &deltaRij, const Matrix3 &delRdelBiasOmega)
Explicit initialization of all class members.
Definition PreintegratedRotation.h:181
std::shared_ptr< Params > p_
Parameters.
Definition PreintegratedRotation.h:162
double deltaTij_
Time interval from i to j.
Definition PreintegratedRotation.h:164
bool matchesParamsWith(const PreintegratedRotation &other) const
check parameters equality: checks whether shared pointer points to same Params object.
Definition PreintegratedRotation.h:192
PreintegratedRotation()
Default constructor for serialization.
Definition PreintegratedRotation.h:173
Rot3 deltaRij_
Preintegrated relative orientation (in frame i).
Definition PreintegratedRotation.h:165
PreintegratedRotation(const std::shared_ptr< Params > &p)
Default constructor, resets integration to zero.
Definition PreintegratedRotation.h:176
void resetIntegration()
Re-initialize PreintegratedMeasurements.
Definition PreintegratedRotation.cpp:55