gtsam  4.0.0
gtsam
PreintegrationBase.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 
28 
29 #include <iosfwd>
30 #include <string>
31 #include <utility>
32 
33 namespace gtsam {
34 
35 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4
36 struct PoseVelocityBias {
38  Pose3 pose;
39  Vector3 velocity;
40  imuBias::ConstantBias bias;
41  PoseVelocityBias(const Pose3& _pose, const Vector3& _velocity,
42  const imuBias::ConstantBias _bias) :
43  pose(_pose), velocity(_velocity), bias(_bias) {
44  }
45  PoseVelocityBias(const NavState& navState, const imuBias::ConstantBias _bias) :
46  pose(navState.pose()), velocity(navState.velocity()), bias(_bias) {
47  }
48  NavState navState() const {
49  return NavState(pose, velocity);
50  }
51 };
52 #endif
53 
60 class GTSAM_EXPORT PreintegrationBase {
61  public:
64 
65  protected:
68 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4
69  mutable
70 #endif
71  boost::shared_ptr<Params> p_;
72 
75 
77  double deltaTij_;
78 
81 
83  virtual ~PreintegrationBase() {}
84 
85  public:
88 
94  PreintegrationBase(const boost::shared_ptr<Params>& p,
95  const imuBias::ConstantBias& biasHat = imuBias::ConstantBias());
96 
98 
102  virtual void resetIntegration() = 0;
103 
107  void resetIntegrationAndSetBias(const Bias& biasHat);
108 
110  bool matchesParamsWith(const PreintegrationBase& other) const {
111  return p_.get() == other.p_.get();
112  }
113 
115  const boost::shared_ptr<Params>& params() const {
116  return p_;
117  }
118 
120  const Params& p() const {
121  return *boost::static_pointer_cast<Params>(p_);
122  }
123 
124 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4
125  void set_body_P_sensor(const Pose3& body_P_sensor) {
126  p_->body_P_sensor = body_P_sensor;
127  }
128 #endif
129 
133  const imuBias::ConstantBias& biasHat() const { return biasHat_; }
134  double deltaTij() const { return deltaTij_; }
135 
136  virtual Vector3 deltaPij() const = 0;
137  virtual Vector3 deltaVij() const = 0;
138  virtual Rot3 deltaRij() const = 0;
139  virtual NavState deltaXij() const = 0;
140 
141  // Exposed for MATLAB
142  Vector6 biasHatVector() const { return biasHat_.vector(); }
144 
147  GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os, const PreintegrationBase& pim);
148  virtual void print(const std::string& s) const;
150 
153 
159  std::pair<Vector3, Vector3> correctMeasurementsBySensorPose(
160  const Vector3& unbiasedAcc, const Vector3& unbiasedOmega,
161  OptionalJacobian<3, 3> correctedAcc_H_unbiasedAcc = boost::none,
162  OptionalJacobian<3, 3> correctedAcc_H_unbiasedOmega = boost::none,
163  OptionalJacobian<3, 3> correctedOmega_H_unbiasedOmega = boost::none) const;
164 
170  virtual void update(const Vector3& measuredAcc, const Vector3& measuredOmega,
171  const double dt, Matrix9* A, Matrix93* B, Matrix93* C) = 0;
172 
174  virtual void integrateMeasurement(const Vector3& measuredAcc,
175  const Vector3& measuredOmega, const double dt);
176 
179  virtual Vector9 biasCorrectedDelta(const imuBias::ConstantBias& bias_i,
180  OptionalJacobian<9, 6> H = boost::none) const = 0;
181 
183  NavState predict(const NavState& state_i, const imuBias::ConstantBias& bias_i,
184  OptionalJacobian<9, 9> H1 = boost::none,
185  OptionalJacobian<9, 6> H2 = boost::none) const;
186 
188  Vector9 computeError(const NavState& state_i, const NavState& state_j,
189  const imuBias::ConstantBias& bias_i,
190  OptionalJacobian<9, 9> H1, OptionalJacobian<9, 9> H2,
191  OptionalJacobian<9, 6> H3) const;
192 
197  Vector9 computeErrorAndJacobians(const Pose3& pose_i, const Vector3& vel_i,
198  const Pose3& pose_j, const Vector3& vel_j,
199  const imuBias::ConstantBias& bias_i, OptionalJacobian<9, 6> H1 =
200  boost::none, OptionalJacobian<9, 3> H2 = boost::none,
201  OptionalJacobian<9, 6> H3 = boost::none, OptionalJacobian<9, 3> H4 =
202  boost::none, OptionalJacobian<9, 6> H5 = boost::none) const;
203 
204 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V4
205 
209  PoseVelocityBias predict(const Pose3& pose_i, const Vector3& vel_i,
210  const imuBias::ConstantBias& bias_i, const Vector3& n_gravity,
211  const Vector3& omegaCoriolis, const bool use2ndOrderCoriolis = false) const;
212 
214 #endif
215 
216  public:
217  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
218 };
219 
220 }
bool matchesParamsWith(const PreintegrationBase &other) const
check parameters equality: checks whether shared pointer points to same Params object.
Definition: PreintegrationBase.h:110
const boost::shared_ptr< Params > & params() const
shared pointer to params
Definition: PreintegrationBase.h:115
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
PreintegrationBase is the base class for PreintegratedMeasurements (in ImuFactor) and CombinedPreinte...
Definition: PreintegrationBase.h:60
Bias biasHat_
Acceleration and gyro bias used for preintegration.
Definition: PreintegrationBase.h:74
PreintegrationBase()
Default constructor for serialization.
Definition: PreintegrationBase.h:80
boost::shared_ptr< Params > p_
Parameters.
Definition: PreintegrationBase.h:71
virtual ~PreintegrationBase()
Virtual destructor for serialization.
Definition: PreintegrationBase.h:83
Definition: ImuBias.h:30
double deltaTij_
Time interval from i to j.
Definition: PreintegrationBase.h:77
Vector6 vector() const
return the accelerometer and gyro biases in a single vector
Definition: ImuBias.h:52
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Navigation state composing of attitude, position, and velocity.
Definition: Pose3.h:37
const Params & p() const
const reference to params
Definition: PreintegrationBase.h:120
Parameters for pre-integration: Usage: Create just a single Params and pass a shared pointer to the c...
Definition: PreintegrationParams.h:26