38#ifdef GTSAM_LIEGROUP_PREINTEGRATION
40#elif defined(GTSAM_TANGENT_PREINTEGRATION)
76template <
class Pre
integrationType>
79 template <
class PIM>
friend class ImuFactorT;
80 template <
class PIM>
friend class ImuFactor2T;
101 PreintegrationType(
p, biasHat) {
111 : PreintegrationType(base),
113 this->PreintegrationType::resetIntegration();
121 void print(
const std::string& s =
"Preintegrated Measurements:")
const override;
140 const Vector3& measuredOmega,
const double dt)
override;
175 if (!this->
params() || !this->p().omegaCoriolis ||
176 this->p().omegaCoriolis->isZero(0.0)) {
192 Eigen::Matrix<double, 9, 9> physicalChart =
193 Eigen::Matrix<double, 9, 9>::Identity();
194 if (this->
params() && this->p().omegaCoriolis) {
195 const Matrix3 rotation = predictedAttitude.
matrix();
196 physicalChart.template block<3, 3>(6, 3) =
197 -rotation.transpose() *
200 if constexpr (std::is_same_v<PreintegrationType,
202 Matrix9 chartJacobian;
204 NavState(), this->preintegrated_, {}, &chartJacobian);
205 physicalChart *= chartJacobian;
207 return physicalChart *
preintMeasCov_ * physicalChart.transpose();
212 template <
typename PB = PreintegrationType,
214 typename =
typename std::enable_if<std::is_same<PB, TangentPreintegration>::value>::type>
218 this->PreintegrationType::mergeWith(pim12, H1, H2);
225#if GTSAM_ENABLE_BOOST_SERIALIZATION
227 friend class boost::serialization::access;
228 template<
class ARCHIVE>
229 void serialize(ARCHIVE & ar,
const unsigned int ) {
230 namespace bs = ::boost::serialization;
231 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(PreintegrationType);
232 ar & BOOST_SERIALIZATION_NVP(preintMeasCov_);
253template <
class PIM = Pre
integratedImuMeasurements>
256 imuBias::ConstantBias> {
297 pose_i, vel_i, pose_j, vel_j, bias),
316 template <
class Measurement = PIM>
319 const Rot3& predictedAttitude)
323 pose_i, vel_i, pose_j, vel_j, bias),
330 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
331 return std::make_shared<This>(*
this);
351 const Pose3& pose_j,
const Vector3& vel_j,
358 template <
typename MethodPIMArg = PIM,
360 typename =
typename std::enable_if<
361 std::is_same<MethodPIMArg, PreintegratedImuMeasurementsT<TangentPreintegration>>::value
365 const MethodPIMArg& pim01,
366 const MethodPIMArg& pim12
374 if (!pim01.matchesParamsWith(pim12))
375 throw std::domain_error(
376 "Cannot merge PreintegratedImuMeasurements with different params");
378 if (pim01.p_->body_P_sensor)
379 throw std::domain_error(
380 "Cannot merge PreintegratedImuMeasurements with sensor pose yet");
383 MethodPIMArg pim02 = pim01;
386 pim02.mergeWith(pim12, &H1, &H2);
393 typename MethodPIMArg = PIM,
395 typename =
typename std::enable_if<
396 std::is_same<MethodPIMArg, PreintegratedImuMeasurementsT<TangentPreintegration>>::value
412 throw std::domain_error(
"ImuFactor::Merge: IMU bias keys must be the same");
416 throw std::domain_error(
417 "ImuFactor::Merge: intermediate pose, velocity keys need to match up");
420 auto pim02 =
This::Merge(f01->preintegratedMeasurements(), f12->preintegratedMeasurements());
422 return std::make_shared<This>(
433#if GTSAM_ENABLE_BOOST_SERIALIZATION
434 friend class boost::serialization::access;
435 template<
class ARCHIVE>
436 void serialize(ARCHIVE & ar,
const unsigned int ) {
438 ar & boost::serialization::make_nvp(
"NoiseModelFactor5",
439 boost::serialization::base_object<Base>(*
this));
440 ar & BOOST_SERIALIZATION_NVP(pim_);
451GTSAM_EXPORT std::ostream& operator<<(std::ostream& os,
const ImuFactorT<PIM>& f);
457template <
class PIM = Pre
integratedImuMeasurements>
460 imuBias::ConstantBias> {
493 state_i, state_j, bias),
512 template <
class Measurement = PIM>
515 const Rot3& predictedAttitude)
519 state_i, state_j, bias),
526 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
527 return std::make_shared<This>(*
this);
554#if GTSAM_ENABLE_BOOST_SERIALIZATION
556 friend class boost::serialization::access;
557 template<
class ARCHIVE>
558 void serialize(ARCHIVE & ar,
const unsigned int ) {
560 ar & boost::serialization::make_nvp(
"NoiseModelFactor3",
561 boost::serialization::base_object<Base>(*
this));
562 ar & BOOST_SERIALIZATION_NVP(pim_);
569using ImuFactor2 = ImuFactor2T<>;
573GTSAM_EXPORT std::ostream& operator<<(std::ostream& os,
const ImuFactor2T<PIM>& f);
575template <
class Pre
integrationType>
Arbitrary-arity Jacobian factor with compile-time block dimensions.
GTSAM_EXPORT NavState navStateComponentWiseRetract(const NavState &state, const Vector9 &v, OptionalJacobian< 9, 9 > H1={}, OptionalJacobian< 9, 9 > H2={})
Component-wise NavState retraction independent of the optimization chart.
Definition NavState.cpp:147
IMU preintegration using the SE_2(3) group structure of NavState.
Base class for noise model factors with N variables.
Non-linear factor base classes.
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
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
Matrix3 skewSymmetric(double wx, double wy, double wz)
skew symmetric matrix returns this: 0 -wz wy wz 0 -wx -wy wx 0
Definition Matrix.h:365
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
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition Rot3.h:65
Matrix3 matrix() const
return 3*3 rotation matrix
Definition Rot3M.cpp:261
PreintegratedImuMeasurements accumulates (integrates) the IMU measurements (rotation rates and accele...
Definition ImuFactor.h:77
Matrix9 preintMeasCov_
Definition ImuFactor.h:84
void resetIntegration() override
bool equals(const PreintegratedImuMeasurementsT< PreintegrationType > &expected, double tol=1e-9) const
equals
Definition ImuFactor.cpp:174
PreintegratedImuMeasurementsT(const std::shared_ptr< PreintegrationParams > &p, const imuBias::ConstantBias &biasHat=imuBias::ConstantBias())
Constructor, initializes the class with no measurements.
Definition ImuFactor.h:99
Matrix preintMeasCov() const
Definition ImuFactor.h:143
Matrix9 residualCovarianceAt(const Rot3 &predictedAttitude) const
Definition ImuFactor.h:191
void mergeWith(const PreintegratedImuMeasurementsT< TangentPreintegration > &pim12, Matrix9 *H1, Matrix9 *H2)
Merge in a different set of measurements and update bias derivatives accordingly This method is speci...
Definition ImuFactor.h:215
void print(const std::string &s="Preintegrated Measurements:") const override
print
Definition ImuFactor.cpp:167
PreintegratedImuMeasurementsT(const PreintegrationType &base, const Matrix9 &preintMeasCov)
Construct preintegrated directly from members: base class and preintMeasCov.
Definition ImuFactor.h:110
PreintegratedImuMeasurementsT()
Default constructor with default preintegration parameters.
Definition ImuFactor.h:90
void integrateMeasurement(const Vector3 &measuredAcc, const Vector3 &measuredOmega, const double dt) override
Add a single IMU measurement to the preintegration.
Definition ImuFactor.cpp:189
Matrix9 residualCovariance() const
Express the covariance propagated by the selected backend in the chart used by the IMU factor residua...
Definition ImuFactor.h:173
~PreintegratedImuMeasurementsT() override
Virtual destructor.
Definition ImuFactor.h:117
ImuFactor is a 5-ways factor involving previous state (pose and velocity of the vehicle at previous t...
Definition ImuFactor.h:256
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition ImuFactor.h:330
ImuFactorT()
Default constructor - only use for serialization.
Definition ImuFactor.h:276
static MethodPIMArg Merge(const MethodPIMArg &pim01, const MethodPIMArg &pim12)
Merge two pre-integrated measurement classes.
Definition ImuFactor.h:364
ImuFactorT(Key pose_i, Key vel_i, Key pose_j, Key vel_j, Key bias, const PIM &preintegratedMeasurements)
Constructor.
Definition ImuFactor.h:293
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition ImuFactor.cpp:223
const PreintegratedImuMeasurementsG & preintegratedMeasurements() const
Definition ImuFactor.h:343
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Check if two factors are equal.
Definition ImuFactor.cpp:233
std::shared_ptr< This > shared_ptr
Definition ImuFactor.h:272
ImuFactorT(Key pose_i, Key vel_i, Key pose_j, Key vel_j, Key bias, const Measurement &preintegratedMeasurements, const Rot3 &predictedAttitude)
Construct a factor whose rotating-frame covariance is expressed at a supplied nominal endpoint attitu...
Definition ImuFactor.h:317
static ImuFactorT< MethodPIMArg >::shared_ptr Merge(const typename ImuFactorT< MethodPIMArg >::shared_ptr &f01, const typename ImuFactorT< MethodPIMArg >::shared_ptr &f12)
Merge two factors.
Definition ImuFactor.h:399
Vector9 evaluateError(const Pose3 &pose_i, const Vector3 &vel_i, const Pose3 &pose_j, const Vector3 &vel_j, const imuBias::ConstantBias &bias_i, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3, OptionalMatrixType H4, OptionalMatrixType H5) const override
implement functions needed to derive from Factor
Definition ImuFactor.cpp:242
ImuFactor2 is a ternary factor that uses NavStates rather than Pose/Velocity.
Definition ImuFactor.h:460
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition ImuFactor.cpp:263
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Check if two factors are equal.
Definition ImuFactor.cpp:273
Vector9 evaluateError(const NavState &state_i, const NavState &state_j, const imuBias::ConstantBias &bias_i, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
implement functions needed to derive from Factor
Definition ImuFactor.cpp:282
ImuFactor2T(Key state_i, Key state_j, Key bias, const Measurement &preintegratedMeasurements, const Rot3 &predictedAttitude)
Construct a NavState factor with rotating-frame covariance frozen at a supplied nominal endpoint atti...
Definition ImuFactor.h:513
ImuFactor2T()
Default constructor - only use for serialization.
Definition ImuFactor.h:476
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition ImuFactor.h:526
ImuFactor2T(Key state_i, Key state_j, Key bias, const PIM &preintegratedMeasurements)
Constructor.
Definition ImuFactor.h:489
const PreintegratedImuMeasurementsG & preintegratedMeasurements() const
Definition ImuFactor.h:540
IMU preintegration using the SE_2(3) Lie-group structure of NavState.
Definition LieGroupPreintegration.h:32
IMU pre-integration on NavState manifold.
Definition ManifoldPreintegration.h:33
Navigation state: Pose (rotation, translation) + velocity Following Barrau20icra, this class belongs ...
Definition NavState.h:45
NavState predict(const NavState &state_i, const imuBias::ConstantBias &bias_i, const Vector3 &n_gravity, OptionalJacobian< 9, 9 > H1={}, OptionalJacobian< 9, 6 > H2={}, OptionalJacobian< 9, 3 > H3={}) const
Predict state at time j, for a given gravity vector in the nav frame.
Definition PreintegrationBase.cpp:205
const std::shared_ptr< Params > & params() const
shared pointer to params
Definition PreintegrationBase.h:98
Params & p() const
const reference to params
Definition PreintegrationBase.h:103
Parameters for pre-integration: Usage: Create just a single Params and pass a shared pointer to the c...
Definition PreintegrationParams.h:37
Integrate on the 9D tangent space of the NavState manifold.
Definition TangentPreintegration.h:28
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector9 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