PreintegratedRotation.cpp
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 
22 #include "PreintegratedRotation.h"
23 
24 using namespace std;
25 
26 namespace gtsam {
27 
28 void PreintegratedRotationParams::print(const string& s) const {
29  cout << (s.empty() ? s : s + "\n") << endl;
30  cout << "gyroscopeCovariance:\n[\n" << gyroscopeCovariance << "\n]" << endl;
31  if (omegaCoriolis)
32  cout << "omegaCoriolis = (" << omegaCoriolis->transpose() << ")" << endl;
33  if (body_P_sensor) body_P_sensor->print("body_P_sensor");
34 }
35 
36 bool PreintegratedRotationParams::equals(
37  const PreintegratedRotationParams& other, double tol) const {
38  if (body_P_sensor) {
39  if (!other.body_P_sensor
40  || !assert_equal(*body_P_sensor, *other.body_P_sensor, tol))
41  return false;
42  }
43  if (omegaCoriolis) {
44  if (!other.omegaCoriolis
45  || !equal_with_abs_tol(*omegaCoriolis, *other.omegaCoriolis, tol))
46  return false;
47  }
48  return equal_with_abs_tol(gyroscopeCovariance, other.gyroscopeCovariance, tol);
49 }
50 
51 void PreintegratedRotation::resetIntegration() {
52  deltaTij_ = 0.0;
53  deltaRij_ = Rot3();
54  delRdelBiasOmega_ = Z_3x3;
55 }
56 
57 void PreintegratedRotation::print(const string& s) const {
58  cout << s;
59  cout << " deltaTij [" << deltaTij_ << "]" << endl;
60  cout << " deltaRij.ypr = (" << deltaRij_.ypr().transpose() << ")" << endl;
61 }
62 
63 bool PreintegratedRotation::equals(const PreintegratedRotation& other,
64  double tol) const {
65  return this->matchesParamsWith(other)
66  && deltaRij_.equals(other.deltaRij_, tol)
67  && std::abs(deltaTij_ - other.deltaTij_) < tol
68  && equal_with_abs_tol(delRdelBiasOmega_, other.delRdelBiasOmega_, tol);
69 }
70 
71 namespace internal {
73  const Vector3& bias, OptionalJacobian<3, 3> H_bias) const {
74  // First we compensate the measurements for the bias
75  Vector3 correctedOmega = measuredOmega - bias;
76 
77  // Then compensate for sensor-body displacement: we express the quantities
78  // (originally in the IMU frame) into the body frame.
79  // Note that the rotate Jacobian is just body_P_sensor->rotation().matrix().
80  if (body_P_sensor) {
81  // rotation rate vector in the body frame
82  correctedOmega = body_P_sensor->rotation() * correctedOmega;
83  }
84 
85  // rotation vector describing rotation increment computed from the
86  // current rotation rate measurement
87  const Vector3 integratedOmega = correctedOmega * deltaT;
88  Rot3 incrR = Rot3::Expmap(integratedOmega, H_bias); // expensive !!
89  if (H_bias) {
90  *H_bias *= -deltaT; // Correct so accurately reflects bias derivative
91  if (body_P_sensor) *H_bias *= body_P_sensor->rotation().matrix();
92  }
93  return incrR;
94 }
95 } // namespace internal
96 
97 void PreintegratedRotation::integrateGyroMeasurement(
98  const Vector3& measuredOmega, const Vector3& biasHat, double deltaT,
100  Matrix3 H_bias;
102  const Rot3 incrR = f(biasHat, H_bias);
103 
104  // Update deltaTij and rotation
105  deltaTij_ += deltaT;
106  deltaRij_ = deltaRij_.compose(incrR, F);
107 
108  // Update Jacobian
109  const Matrix3 incrRt = incrR.transpose();
110  delRdelBiasOmega_ = incrRt * delRdelBiasOmega_ + H_bias;
111 }
112 
113 #ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V43
114 void PreintegratedRotation::integrateMeasurement(
115  const Vector3& measuredOmega, const Vector3& biasHat, double deltaT,
116  OptionalJacobian<3, 3> optional_D_incrR_integratedOmega,
118  integrateGyroMeasurement(measuredOmega, biasHat, deltaT, F);
119 
120  // If asked, pass obsolete Jacobians as well
121  if (optional_D_incrR_integratedOmega) {
122  Matrix3 H_bias;
124  const Rot3 incrR = f(biasHat, H_bias);
125  *optional_D_incrR_integratedOmega << H_bias / -deltaT;
126  }
127 }
128 #endif
129 
130 Rot3 PreintegratedRotation::biascorrectedDeltaRij(const Vector3& biasOmegaIncr,
131  OptionalJacobian<3, 3> H) const {
132  const Vector3 biasInducedOmega = delRdelBiasOmega_ * biasOmegaIncr;
133  const Rot3 deltaRij_biascorrected = deltaRij_.expmap(biasInducedOmega,{}, H);
134  if (H)
135  (*H) *= delRdelBiasOmega_;
136  return deltaRij_biascorrected;
137 }
138 
139 Vector3 PreintegratedRotation::integrateCoriolis(const Rot3& rot_i) const {
140  if (!p_->omegaCoriolis)
141  return Vector3::Zero();
142  return rot_i.transpose() * (*p_->omegaCoriolis) * deltaTij_;
143 }
144 
145 } // namespace gtsam
H
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Definition: gnuplot_common_settings.hh:74
Eigen::internal::print
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
Definition: NEON/PacketMath.h:3115
gtsam::PreintegratedRotationParams
Definition: PreintegratedRotation.h:57
s
RealScalar s
Definition: level1_cplx_impl.h:126
biased_x_rotation::bias
const Vector3 bias(1, 2, 3)
gtsam::equal_with_abs_tol
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
Definition: base/Matrix.h:80
gtsam::Vector3
Eigen::Vector3d Vector3
Definition: Vector.h:44
body_P_sensor
static Pose3 body_P_sensor(Rot3::RzRyRx(-M_PI_2, 0.0, -M_PI_2), Point3(0.25, -0.10, 1.0))
common::deltaT
static const double deltaT
Definition: testImuFactor.cpp:183
Expmap
Pose2_ Expmap(const Vector3_ &xi)
Definition: InverseKinematicsExampleExpressions.cpp:47
biased_x_rotation::measuredOmega
const Vector3 measuredOmega
Definition: testPreintegratedRotation.cpp:35
gtsam::Rot3
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition: Rot3.h:58
operator()
internal::enable_if< internal::valid_indexed_view_overload< RowIndices, ColIndices >::value &&internal::traits< typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::ReturnAsIndexedView, typename EIGEN_INDEXED_VIEW_METHOD_TYPE< RowIndices, ColIndices >::type >::type operator()(const RowIndices &rowIndices, const ColIndices &colIndices) EIGEN_INDEXED_VIEW_METHOD_CONST
Definition: IndexedViewMethods.h:73
PreintegratedRotation.h
gtsam::symbol_shorthand::F
Key F(std::uint64_t j)
Definition: inference/Symbol.h:153
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
gtsam
traits
Definition: SFMdata.h:40
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
std
Definition: BFloat16.h:88
gtsam::PreintegratedRotation
Definition: PreintegratedRotation.h:117
gtsam::Rot3::transpose
Matrix3 transpose() const
Definition: Rot3M.cpp:143
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:41
gtsam::tol
const G double tol
Definition: Group.h:79
abs
#define abs(x)
Definition: datatypes.h:17
internal
Definition: BandTriangularSolver.h:13
gtsam::LieGroup::expmap
Class expmap(const TangentVector &v) const
Definition: Lie.h:78
gtsam::internal::IncrementalRotation
Function object for incremental rotation.
Definition: PreintegratedRotation.h:38
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:12:46