36 cout <<
" preintMeasCov \n[" << preintMeasCov_ <<
"]" << endl;
49 preintMeasCov_.setZero();
56 throw std::runtime_error(
57 "PreintegratedImuMeasurements::integrateMeasurement: dt <=0");
71 const Matrix3& aCov =
p().accelerometerCovariance;
72 const Matrix3& wCov =
p().gyroscopeCovariance;
73 const Matrix3& iCov =
p().integrationCovariance;
77 preintMeasCov_ = A * preintMeasCov_ * A.transpose();
79 preintMeasCov_.noalias() += B * (aCov /
dt) * B.transpose();
80 preintMeasCov_.noalias() += C * (wCov /
dt) * C.transpose();
83 preintMeasCov_.block<3, 3>(3, 3).noalias() += iCov *
dt;
88 const Matrix& measuredAccs,
const Matrix& measuredOmegas,
91 measuredAccs.rows() == 3 && measuredOmegas.rows() == 3 && dts.rows() == 1);
92 assert(dts.cols() >= 1);
93 assert(measuredAccs.cols() == dts.cols());
94 assert(measuredOmegas.cols() == dts.cols());
95 size_t n =
static_cast<size_t>(dts.cols());
96 for (
size_t j = 0;
j <
n;
j++) {
97 integrateMeasurement(measuredAccs.col(
j), measuredOmegas.col(
j), dts(0,
j));
102 #ifdef GTSAM_TANGENT_PREINTEGRATION 105 PreintegrationType::mergeWith(pim12, H1, H2);
107 const Matrix9 P = *H1 * preintMeasCov_ * H1->transpose();
108 preintMeasCov_ = P + *H2 * pim12.
preintMeasCov_ * H2->transpose();
117 Base(noiseModel::Gaussian::Covariance(pim.preintMeasCov_), pose_i, vel_i,
118 pose_j, vel_j, bias), _PIM_(pim) {
129 f.
_PIM_.
print(
"preintegrated measurements:\n");
130 os <<
" noise model sigmas: " << f.
noiseModel_->sigmas().transpose();
136 cout << (s.empty() ?
s : s +
"\n") <<
"ImuFactor(" << keyFormatter(this->key<1>())
137 <<
"," << keyFormatter(this->key<2>()) <<
"," << keyFormatter(this->key<3>())
138 <<
"," << keyFormatter(this->key<4>()) <<
"," << keyFormatter(this->key<5>())
140 cout << *
this << endl;
148 return e !=
nullptr && base && pim;
162 #ifdef GTSAM_TANGENT_PREINTEGRATION 167 throw std::domain_error(
168 "Cannot merge PreintegratedImuMeasurements with different params");
170 if (pim01.
params()->body_P_sensor)
171 throw std::domain_error(
172 "Cannot merge PreintegratedImuMeasurements with sensor pose yet");
178 pim02.mergeWith(pim12, &H1, &H2);
187 if (f01->key<5>() != f12->key<5>())
188 throw std::domain_error(
"ImuFactor::Merge: IMU bias keys must be the same");
191 if (f01->key<3>() != f12->key<1>() || f01->key<4>() != f12->key<2>())
192 throw std::domain_error(
193 "ImuFactor::Merge: intermediate pose, velocity keys need to match up");
197 Merge(f01->preintegratedMeasurements(), f12->preintegratedMeasurements());
198 return std::make_shared<ImuFactor>(f01->key<1>(),
212 Base(
noiseModel::Gaussian::Covariance(pim.preintMeasCov_), state_i, state_j,
224 f.
_PIM_.
print(
"preintegrated measurements:\n");
225 os <<
" noise model sigmas: " << f.
noiseModel_->sigmas().transpose();
232 cout << (s.empty() ?
s : s +
"\n") <<
"ImuFactor2(" 233 << keyFormatter(this->key<1>()) <<
"," << keyFormatter(this->key<2>()) <<
"," 234 << keyFormatter(this->key<3>()) <<
")\n";
235 cout << *
this << endl;
243 return e !=
nullptr && base && pim;
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
void integrateMeasurement(const Vector3 &measuredAcc, const Vector3 &measuredOmega, const double dt) override
void integrateMeasurements(const Matrix &measuredAccs, const Matrix &measuredOmegas, const Matrix &dts)
Add multiple measurements, in matrix columns.
bool matchesParamsWith(const PreintegrationBase &other) const
check parameters equality: checks whether shared pointer points to same Params object.
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
bool equals(const PreintegratedImuMeasurements &expected, double tol=1e-9) const
equals
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Vector 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
vector of errors
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
void resetIntegration() override
Vector9 computeError(const NavState &state_i, const NavState &state_j, const imuBias::ConstantBias &bias_i, OptionalJacobian< 9, 9 > H1, OptionalJacobian< 9, 9 > H2, OptionalJacobian< 9, 6 > H3) const
Calculate error given navStates.
GTSAM_EXPORT friend std::ostream & operator<<(std::ostream &os, const ImuFactor2 &)
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
gtsam::NonlinearFactor::shared_ptr clone() const override
void print(const std::string &s="Preintegrated Measurements:") const override
print
PreintegratedImuMeasurements _PIM_
void update(const Vector3 &measuredAcc, const Vector3 &measuredOmega, const double dt, Matrix9 *A, Matrix93 *B, Matrix93 *C) override
const SharedNoiseModel & noiseModel() const
access to the noise model
Matrix * OptionalMatrixType
Vector evaluateError(const NavState &state_i, const NavState &state_j, const imuBias::ConstantBias &bias_i, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
vector of errors
const std::shared_ptr< Params > & params() const
shared pointer to params
PreintegratedImuMeasurements _PIM_
Vector9 computeErrorAndJacobians(const Pose3 &pose_i, const Vector3 &vel_i, const Pose3 &pose_j, const Vector3 &vel_j, const imuBias::ConstantBias &bias_i, OptionalJacobian< 9, 6 > H1={}, OptionalJacobian< 9, 3 > H2={}, OptionalJacobian< 9, 6 > H3={}, OptionalJacobian< 9, 3 > H4={}, OptionalJacobian< 9, 6 > H5={}) const
virtual void print(const std::string &s="") const
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Matrix9 preintMeasCov_
(first-order propagation from measurementCovariance).
static const Vector3 measuredAcc
std::shared_ptr< Factor > shared_ptr
A shared_ptr to this class.
GTSAM_EXPORT friend std::ostream & operator<<(std::ostream &os, const ImuFactor &)
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
Matrix< Scalar, Dynamic, Dynamic > C
static const Vector3 measuredOmega(w, 0, 0)
SharedNoiseModel noiseModel_
ofstream os("timeSchurFactors.csv")
std::shared_ptr< This > shared_ptr
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Annotation indicating that a class derives from another given type.
std::shared_ptr< ImuFactor > shared_ptr
void resetIntegration() override
Re-initialize PreintegratedIMUMeasurements.
std::uint64_t Key
Integer nonlinear key type.
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
gtsam::NonlinearFactor::shared_ptr clone() const override
bool equals(const ManifoldPreintegration &other, double tol) const