gtsam
Loading...
Searching...
No Matches
CombinedImuFactorWithGravity.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
16
17#pragma once
18
20
21namespace gtsam {
22
38template <class PIM = PreintegratedCombinedMeasurements, class GRAVITY = Unit3>
40 : public NoiseModelFactorN<Pose3, Vector3, Pose3, Vector3,
41 imuBias::ConstantBias, imuBias::ConstantBias,
42 GRAVITY> {
43 private:
45 typedef NoiseModelFactorN<Pose3, Vector3, Pose3, Vector3,
47 GRAVITY>
48 Base;
49
50 PIM pim_;
51 double gravityMagnitude_;
52
53 public:
54 // Provide access to the Matrix& version of evaluateError:
56
58 typedef std::shared_ptr<This> shared_ptr;
59
61 CombinedImuFactorWithGravityT() : gravityMagnitude_(0.0) {}
62
79 CombinedImuFactorWithGravityT(Key pose_i, Key vel_i, Key pose_j, Key vel_j,
80 Key bias_i, Key bias_j, Key gravity,
82 std::optional<double> gravityMagnitude = {})
83 : Base(noiseModel::Gaussian::Covariance(
84 preintegratedMeasurements.residualCovariance()),
85 pose_i, vel_i, pose_j, vel_j, bias_i, bias_j, gravity),
86 pim_(preintegratedMeasurements),
87 gravityMagnitude_(internal::resolveGravityMagnitude<GRAVITY>(
88 "CombinedImuFactorWithGravityT", preintegratedMeasurements,
89 gravityMagnitude)) {}
90
91 ~CombinedImuFactorWithGravityT() override {}
92
94 gtsam::NonlinearFactor::shared_ptr clone() const override {
95 return std::make_shared<This>(*this);
96 }
97
100 void print(const std::string& s = "", const KeyFormatter& keyFormatter =
101 DefaultKeyFormatter) const override;
102 bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
104
106 const PIM& preintegratedMeasurements() const { return pim_; }
107
109 double gravityMagnitude() const { return gravityMagnitude_; }
110
112
114 Vector evaluateError(const Pose3& pose_i, const Vector3& vel_i,
115 const Pose3& pose_j, const Vector3& vel_j,
116 const imuBias::ConstantBias& bias_i,
117 const imuBias::ConstantBias& bias_j,
118 const GRAVITY& gravity, OptionalMatrixType H1,
121 OptionalMatrixType H6, OptionalMatrixType H7) const override;
122
123 private:
124#if GTSAM_ENABLE_BOOST_SERIALIZATION
126 friend class boost::serialization::access;
127 template <class ARCHIVE>
128 void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
129 // Archive name for the base follows the sibling factors' convention:
130 ar& boost::serialization::make_nvp(
131 "NoiseModelFactor7", boost::serialization::base_object<Base>(*this));
132 ar& BOOST_SERIALIZATION_NVP(pim_);
133 ar& BOOST_SERIALIZATION_NVP(gravityMagnitude_);
134 }
135#endif
136};
137// class CombinedImuFactorWithGravityT
138
143
148
149// operator<< for CombinedImuFactorWithGravityT
150template <class PIM, class GRAVITY>
151GTSAM_EXPORT std::ostream& operator<<(
152 std::ostream& os, const CombinedImuFactorWithGravityT<PIM, GRAVITY>& f);
153
154template <class PIM, class GRAVITY>
156 : public Testable<CombinedImuFactorWithGravityT<PIM, GRAVITY>> {};
157
158} // namespace gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
CombinedImuFactorWithGravityT< PreintegratedCombinedMeasurements, Unit3 > CombinedImuFactorWithGravityDirection
CombinedImuFactor variant optimizing the gravity direction (Unit3) with a fixed, known magnitude; see...
Definition CombinedImuFactorWithGravity.h:141
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
NoiseModelFactorT< Vector, ValueTypes... > NoiseModelFactorN
Noise model factor with N value types and dynamic-sized error vector.
Definition NoiseModelFactorN.h:561
CombinedImuFactorWithGravityT< PreintegratedCombinedMeasurements, Point3 > CombinedImuFactorWithGravityVector
CombinedImuFactor variant optimizing the free gravity vector (Point3); see ImuFactorWithGravityVector...
Definition CombinedImuFactorWithGravity.h:146
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
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
All noise models live in the noiseModel namespace.
Definition LossFunctions.cpp:33
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
CombinedImuFactorWithGravityT is CombinedImuFactorT with an additional GRAVITY variable,...
Definition CombinedImuFactorWithGravity.h:42
CombinedImuFactorWithGravityT(Key pose_i, Key vel_i, Key pose_j, Key vel_j, Key bias_i, Key bias_j, Key gravity, const PIM &preintegratedMeasurements, std::optional< double > gravityMagnitude={})
Constructor.
Definition CombinedImuFactorWithGravity.h:79
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition CombinedImuFactorWithGravity.h:94
CombinedImuFactorWithGravityT()
Default constructor - only use for serialization.
Definition CombinedImuFactorWithGravity.h:61
Vector evaluateError(const Pose3 &pose_i, const Vector3 &vel_i, const Pose3 &pose_j, const Vector3 &vel_j, const imuBias::ConstantBias &bias_i, const imuBias::ConstantBias &bias_j, const GRAVITY &gravity, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3, OptionalMatrixType H4, OptionalMatrixType H5, OptionalMatrixType H6, OptionalMatrixType H7) const override
implement functions needed to derive from Factor
Definition CombinedImuFactorWithGravity.cpp:66
std::shared_ptr< This > shared_ptr
Definition CombinedImuFactorWithGravity.h:58
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition CombinedImuFactorWithGravity.cpp:44
const PIM & preintegratedMeasurements() const
Definition CombinedImuFactorWithGravity.h:106
double gravityMagnitude() const
Definition CombinedImuFactorWithGravity.h:109
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Check if two factors are equal.
Definition CombinedImuFactorWithGravity.cpp:56
Definition ImuBias.h:34
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Nonlinear factor base class.
Definition NonlinearFactor.h:70
Gaussian implements the mathematical model |R*x|^2 = |y|^2 with R'*R=inv(Sigma) where y = whiten(x) =...
Definition NoiseModel.h:192