29#if GTSAM_ENABLE_BOOST_SERIALIZATION
30#include <boost/serialization/version.hpp>
43 pim.biascorrectedDeltaRij(bias - pim.biasHat(), H2);
47 if (!pim.p().omegaCoriolis || pim.p().omegaCoriolis->isZero(0.0))
48 return Ri.compose(biasCorrected, H1);
52 const Rot3 gammaRotation =
53 Rot3::Expmap(-(*pim.p().omegaCoriolis) * pim.deltaTij());
54 Matrix3 D_gammaRi_Ri, D_Rj_gammaRi, D_Rj_delta;
56 gammaRotation.compose(Ri, {}, H1 ? &D_gammaRi_Ri :
nullptr);
57 const Rot3 Rj = gammaRi.compose(biasCorrected, H1 ? &D_Rj_gammaRi :
nullptr,
58 H2 ? &D_Rj_delta :
nullptr);
60 if (H1) *H1 = D_Rj_gammaRi * D_gammaRi_Ri;
61 if (H2) *H2 = D_Rj_delta * (*H2);
104 const Vector3& biasHat = Vector3::Zero())
119 const Vector3& bias_hat,
double deltaTij,
120 const Rot3& deltaRij,
121 const Matrix3& delRdelBiasOmega,
122 const Matrix3& preint_meas_cov)
127 Params& p()
const {
return *std::static_pointer_cast<Params>(p_); }
128 const Vector3& biasHat()
const {
return biasHat_; }
129 const Matrix3& preintMeasCov()
const {
return preintMeasCov_; }
132 void print(
const std::string& s =
"Preintegrated Measurements: ")
const;
135 bool equals(
const PreintegratedAhrsMeasurements& expected,
136 double tol = 1e-9)
const;
139 void resetIntegration();
150 void integrateMeasurement(
const Vector3& measuredOmega,
double deltaT);
163 return internal::predictAhrs(*
this, Ri, bias, H1, H2);
167#if GTSAM_ENABLE_BOOST_SERIALIZATION
169 friend class boost::serialization::access;
170 template <
class ARCHIVE>
171 void serialize(ARCHIVE& ar,
const unsigned int version) {
172 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(PreintegratedRotation);
173 ar& BOOST_SERIALIZATION_NVP(p_);
174 ar& BOOST_SERIALIZATION_NVP(biasHat_);
176 ar& BOOST_SERIALIZATION_NVP(preintMeasCov_);
177 }
else if (ARCHIVE::is_loading::value) {
178 preintMeasCov_.setZero();
225#if !defined(_MSC_VER) && __GNUC__ == 4 && __GNUC_MINOR__ > 5
226 typedef typename std::shared_ptr<This>
shared_ptr;
249 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
250 return std::make_shared<This>(*
this);
256 std::cout << s <<
"AHRSFactor(" << keyFormatter(this->
template key<1>())
257 <<
"," << keyFormatter(this->
template key<2>()) <<
","
258 << keyFormatter(this->
template key<3>()) <<
")\n";
259 pim_.print(
" preintegrated measurements:");
260 this->noiseModel_->print(
" noise model: ");
265 const auto* expected =
dynamic_cast<const This*
>(&other);
266 return expected !=
nullptr &&
Base::equals(*expected, tol) &&
267 pim_.equals(expected->pim_, tol);
279 Matrix3 D_predict_Ri, D_predict_bias;
281 pim_, Ri, bias, H1 ? &D_predict_Ri :
nullptr,
282 H3 ? &D_predict_bias :
nullptr);
284 Matrix3 D_error_Rj, D_error_predict;
286 predictedRj, H2 ? &D_error_Rj :
nullptr,
287 H1 || H3 ? &D_error_predict :
nullptr);
289 if (H1) *H1 = D_error_predict * D_predict_Ri;
290 if (H2) *H2 = D_error_Rj;
291 if (H3) *H3 = D_error_predict * D_predict_bias;
296#if GTSAM_ENABLE_BOOST_SERIALIZATION
298 friend class boost::serialization::access;
299 template <
class ARCHIVE>
300 void serialize(ARCHIVE& ar,
const unsigned int ) {
302 ar& boost::serialization::make_nvp(
303 "NoiseModelFactor3", boost::serialization::base_object<Base>(*
this));
304 ar& boost::serialization::make_nvp(
"_PIM_", pim_);
321#if GTSAM_ENABLE_BOOST_SERIALIZATION
3D rotation represented as a rotation matrix or quaternion
Rot3 predictAhrs(const PIM &pim, const Rot3 &Ri, const Vector3 &bias, OptionalJacobian< 3, 3 > H1={}, OptionalJacobian< 3, 3 > H2={})
Shared AHRS orientation prediction for compatible preintegration types.
Definition AHRSFactor.h:39
Base class for noise model factors with N variables.
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
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
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
TangentVector logmap(const Class &g) const
logmap as required by manifold concept Applies logarithmic map to group element that takes *this to g
Definition Lie.h:161
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition OptionalJacobian.h:40
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition Rot3.h:65
static Rot3 Expmap(const Vector3 &v, OptionalJacobian< 3, 3 > H={})
Exponential map - create a rotation from canonical coordinates using Rodrigues' formula.
Definition Rot3M.cpp:173
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
PreintegratedAHRSMeasurements accumulates (integrates) the gyroscope measurements (rotation rates) an...
Definition AHRSFactor.h:88
Rot3 predict(const Rot3 &Ri, const Vector3 &bias, gtsam::OptionalJacobian< 3, 3 > H1={}, gtsam::OptionalJacobian< 3, 3 > H2={}) const
Predict the orientation at time j, given orientation and bias at time i.
Definition AHRSFactor.h:160
Vector3 biasHat_
Angular rate bias values used during preintegration.
Definition AHRSFactor.h:90
PreintegratedAhrsMeasurements(const std::shared_ptr< Params > &p, const Vector3 &bias_hat, double deltaTij, const Rot3 &deltaRij, const Matrix3 &delRdelBiasOmega, const Matrix3 &preint_meas_cov)
Non-Default constructor, initialize with measurements.
Definition AHRSFactor.h:118
void resetIntegration()
Reset integrated quantities to zero.
Definition AHRSFactor.cpp:49
PreintegratedAhrsMeasurements(const std::shared_ptr< Params > &p, const Vector3 &biasHat=Vector3::Zero())
Default constructor, initialize with no measurements.
Definition AHRSFactor.h:103
Matrix3 preintMeasCov_
Covariance matrix of the preintegrated measurements (first-order propagation from measurementCovarian...
Definition AHRSFactor.h:91
PreintegratedAhrsMeasurements()
Default constructor, only for serialization and wrappers.
Definition AHRSFactor.h:97
An AHRSFactor is a three-way factor that is based on the preintegrated gyroscope measurements.
Definition AHRSFactor.h:214
std::shared_ptr< This > shared_ptr
Shorthand for a smart pointer to a factor.
Definition AHRSFactor.h:228
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition AHRSFactor.h:254
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition AHRSFactor.h:249
AHRSFactorT()=default
Default constructor - only use for serialization.
Vector3 evaluateError(const Rot3 &Ri, const Rot3 &Rj, const Vector3 &bias, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
implement functions needed to derive from Factor
Definition AHRSFactor.h:276
AHRSFactorT(Key rot_i, Key rot_j, Key bias, const PIM &pim)
Constructor.
Definition AHRSFactor.h:241
const PIM & preintegratedMeasurements() const
Access the preintegrated measurements.
Definition AHRSFactor.h:271
bool equals(const NonlinearFactor &other, double tol=1e-9) const override
equals
Definition AHRSFactor.h:264
PreintegratedRotation()
Default constructor for serialization.
Definition PreintegratedRotation.h:173
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector3 evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition NoiseModelFactorN.h:307
Nonlinear factor base class.
Definition NonlinearFactor.h:70
double error(const Values &c) const override
Calculate the error of the factor.
Definition NonlinearFactor.cpp:146
Gaussian implements the mathematical model |R*x|^2 = |y|^2 with R'*R=inv(Sigma) where y = whiten(x) =...
Definition NoiseModel.h:192