41template <
class PIM = Pre
integratedImuMeasurements,
class GRAVITY = Unit3>
44 imuBias::ConstantBias, GRAVITY> {
52 double gravityMagnitude_;
85 preintegratedMeasurements.residualCovariance()),
86 pose_i, vel_i, pose_j, vel_j, bias, gravity),
87 pim_(preintegratedMeasurements),
88 gravityMagnitude_(internal::resolveGravityMagnitude<GRAVITY>(
89 "ImuFactorWithGravityT", preintegratedMeasurements,
92 ~ImuFactorWithGravityT()
override {
96 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
97 return std::make_shared<This>(*
this);
114 return gravityMagnitude_;
121 const Pose3& pose_j,
const Vector3& vel_j,
129 template <
typename MethodPIMArg = PIM,
130 typename =
typename std::enable_if<
131 std::is_same<MethodPIMArg, PreintegratedImuMeasurementsT<TangentPreintegration>>::value
139 throw std::domain_error(
"ImuFactorWithGravityT::Merge: IMU bias keys must be the same");
142 throw std::domain_error(
"ImuFactorWithGravityT::Merge: gravity keys must be the same");
145 std::abs(f01->gravityMagnitude() - f12->gravityMagnitude()) > 1e-9)
146 throw std::domain_error(
147 "ImuFactorWithGravityT::Merge: gravity magnitudes must be the same");
150 throw std::domain_error(
151 "ImuFactorWithGravityT::Merge: intermediate pose, velocity keys need to match up");
154 f12->preintegratedMeasurements());
156 return std::make_shared<This>(
165 ? std::optional<double>(f01->gravityMagnitude())
170#if GTSAM_ENABLE_BOOST_SERIALIZATION
172 friend class boost::serialization::access;
173 template<
class ARCHIVE>
174 void serialize(ARCHIVE & ar,
const unsigned int ) {
176 ar & boost::serialization::make_nvp(
"NoiseModelFactor6",
177 boost::serialization::base_object<Base>(*
this));
178 ar & BOOST_SERIALIZATION_NVP(pim_);
179 ar & BOOST_SERIALIZATION_NVP(gravityMagnitude_);
211template <
class PIM,
class GRAVITY>
212GTSAM_EXPORT std::ostream& operator<<(std::ostream& os,
215template <
class PIM,
class GRAVITY>
217 :
public Testable<ImuFactorWithGravityT<PIM, GRAVITY>> {};
233template <
class PIM = Pre
integratedImuMeasurements,
class GRAVITY = Unit3>
236 imuBias::ConstantBias, GRAVITY> {
245 double gravityMagnitude_;
273 preintegratedMeasurements.residualCovariance()),
274 state_i, state_j, bias, gravity),
275 pim_(preintegratedMeasurements),
276 gravityMagnitude_(internal::resolveGravityMagnitude<GRAVITY>(
277 "ImuFactor2WithGravityT", preintegratedMeasurements,
278 gravityMagnitude)) {}
280 ~ImuFactor2WithGravityT()
override {
284 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
285 return std::make_shared<This>(*
this);
302 return gravityMagnitude_;
315#if GTSAM_ENABLE_BOOST_SERIALIZATION
317 friend class boost::serialization::access;
318 template<
class ARCHIVE>
319 void serialize(ARCHIVE & ar,
const unsigned int ) {
321 ar & boost::serialization::make_nvp(
"NoiseModelFactor4",
322 boost::serialization::base_object<Base>(*
this));
323 ar & BOOST_SERIALIZATION_NVP(pim_);
324 ar & BOOST_SERIALIZATION_NVP(gravityMagnitude_);
345template <
class PIM,
class GRAVITY>
346GTSAM_EXPORT std::ostream& operator<<(std::ostream& os,
349template <
class PIM,
class GRAVITY>
351 :
public Testable<ImuFactor2WithGravityT<PIM, GRAVITY>> {};
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
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
ImuFactor2WithGravityT< PreintegratedImuMeasurements, Unit3 > ImuFactor2WithGravityDirection
ImuFactor2 variant with the gravity direction as an optimized Unit3 variable and a fixed,...
Definition ImuFactorWithGravity.h:334
ImuFactor2WithGravityT< PreintegratedImuMeasurements, Point3 > ImuFactor2WithGravityVector
ImuFactor2 variant with the gravity vector as a free Point3 variable, ie.
Definition ImuFactorWithGravity.h:341
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
ImuFactorWithGravityT< PreintegratedImuMeasurements, Point3 > ImuFactorWithGravityVector
ImuFactor variant with the gravity vector as a free Point3 variable, ie.
Definition ImuFactorWithGravity.h:207
ImuFactorWithGravityT< PreintegratedImuMeasurements, Unit3 > ImuFactorWithGravityDirection
ImuFactor variant with the gravity direction as an optimized Unit3 variable and a fixed,...
Definition ImuFactorWithGravity.h:195
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
static MethodPIMArg Merge(const MethodPIMArg &pim01, const MethodPIMArg &pim12)
Merge two pre-integrated measurement classes.
Definition ImuFactor.h:364
ImuFactorWithGravityT is a 6-ways factor: in addition to the previous and current states (pose and ve...
Definition ImuFactorWithGravity.h:44
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition ImuFactorWithGravity.cpp:43
Vector evaluateError(const Pose3 &pose_i, const Vector3 &vel_i, const Pose3 &pose_j, const Vector3 &vel_j, const imuBias::ConstantBias &bias_i, const GRAVITY &gravity, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3, OptionalMatrixType H4, OptionalMatrixType H5, OptionalMatrixType H6) const override
implement functions needed to derive from Factor
Definition ImuFactorWithGravity.cpp:65
static ImuFactorWithGravityT< MethodPIMArg, GRAVITY >::shared_ptr Merge(const typename ImuFactorWithGravityT< MethodPIMArg, GRAVITY >::shared_ptr &f01, const typename ImuFactorWithGravityT< MethodPIMArg, GRAVITY >::shared_ptr &f12)
Merge two factors sharing bias and gravity keys, with consecutive states.
Definition ImuFactorWithGravity.h:134
ImuFactorWithGravityT(Key pose_i, Key vel_i, Key pose_j, Key vel_j, Key bias, Key gravity, const PIM &preintegratedMeasurements, std::optional< double > gravityMagnitude={})
Constructor.
Definition ImuFactorWithGravity.h:81
const PIM & preintegratedMeasurements() const
Definition ImuFactorWithGravity.h:108
double gravityMagnitude() const
Definition ImuFactorWithGravity.h:113
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Check if two factors are equal.
Definition ImuFactorWithGravity.cpp:55
std::shared_ptr< This > shared_ptr
Definition ImuFactorWithGravity.h:60
ImuFactorWithGravityT()
Default constructor - only use for serialization.
Definition ImuFactorWithGravity.h:63
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition ImuFactorWithGravity.h:96
ImuFactor2WithGravityT is the NavState version of ImuFactorWithGravityT, just as ImuFactor2T is the N...
Definition ImuFactorWithGravity.h:236
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition ImuFactorWithGravity.cpp:97
const PIM & preintegratedMeasurements() const
Definition ImuFactorWithGravity.h:296
double gravityMagnitude() const
Definition ImuFactorWithGravity.h:301
ImuFactor2WithGravityT(Key state_i, Key state_j, Key bias, Key gravity, const PIM &preintegratedMeasurements, std::optional< double > gravityMagnitude={})
Constructor.
Definition ImuFactorWithGravity.h:269
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Check if two factors are equal.
Definition ImuFactorWithGravity.cpp:109
ImuFactor2WithGravityT()
Default constructor - only use for serialization.
Definition ImuFactorWithGravity.h:253
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition ImuFactorWithGravity.h:284
Vector9 evaluateError(const NavState &state_i, const NavState &state_j, const imuBias::ConstantBias &bias_i, const GRAVITY &gravity, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3, OptionalMatrixType H4) const override
implement functions needed to derive from Factor
Definition ImuFactorWithGravity.cpp:119
Navigation state: Pose (rotation, translation) + velocity Following Barrau20icra, this class belongs ...
Definition NavState.h:45
Adapter mapping a gravity parametrization GRAVITY to the nav-frame gravity vector expected by Preinte...
Definition PreintegrationBase.h:322
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition NoiseModelFactorN.h:307
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