testManifoldPreintegration.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 
23 
25 
26 #include "imuFactorTesting.h"
27 
28 using namespace std::placeholders;
29 
30 namespace testing {
31 // Create default parameters with Z-down and above noise parameters
32 static std::shared_ptr<PreintegrationParams> Params() {
33  auto p = PreintegrationParams::MakeSharedD(kGravity);
34  p->gyroscopeCovariance = kGyroSigma * kGyroSigma * I_3x3;
35  p->accelerometerCovariance = kAccelSigma * kAccelSigma * I_3x3;
36  p->integrationCovariance = 0.0001 * I_3x3;
37  return p;
38 }
39 }
40 
41 /* ************************************************************************* */
42 TEST(ManifoldPreintegration, BiasCorrectionJacobians) {
43  testing::SomeMeasurements measurements;
44 
45  std::function<Rot3(const Vector3&, const Vector3&)> deltaRij =
46  [=](const Vector3& a, const Vector3& w) {
48  testing::integrateMeasurements(measurements, &pim);
49  return pim.deltaRij();
50  };
51 
52  std::function<Point3(const Vector3&, const Vector3&)> deltaPij =
53  [=](const Vector3& a, const Vector3& w) {
55  testing::integrateMeasurements(measurements, &pim);
56  return pim.deltaPij();
57  };
58 
59  std::function<Vector3(const Vector3&, const Vector3&)> deltaVij =
60  [=](const Vector3& a, const Vector3& w) {
62  testing::integrateMeasurements(measurements, &pim);
63  return pim.deltaVij();
64  };
65 
66  // Actual pre-integrated values
68  testing::integrateMeasurements(measurements, &pim);
69 
70  EXPECT(
72  Matrix3(Z_3x3)));
73  EXPECT(
75  pim.delRdelBiasOmega(), 1e-3));
76 
77  EXPECT(
79  pim.delPdelBiasAcc()));
80  EXPECT(
82  pim.delPdelBiasOmega(), 1e-3));
83 
84  EXPECT(
86  pim.delVdelBiasAcc()));
87  EXPECT(
89  pim.delVdelBiasOmega(), 1e-3));
90 }
91 
92 /* ************************************************************************* */
93 TEST(ManifoldPreintegration, computeError) {
95  NavState x1, x2;
97  Matrix9 aH1, aH2;
98  Matrix96 aH3;
99  pim.computeError(x1, x2, bias, aH1, aH2, aH3);
100  std::function<Vector9(const NavState&, const NavState&,
101  const imuBias::ConstantBias&)>
102  f = std::bind(&ManifoldPreintegration::computeError, pim,
103  std::placeholders::_1, std::placeholders::_2,
104  std::placeholders::_3, nullptr, nullptr,
105  nullptr);
106  // NOTE(frank): tolerance of 1e-3 on H1 because approximate away from 0
107  EXPECT(assert_equal(numericalDerivative31(f, x1, x2, bias), aH1, 1e-9));
108  EXPECT(assert_equal(numericalDerivative32(f, x1, x2, bias), aH2, 1e-9));
109  EXPECT(assert_equal(numericalDerivative33(f, x1, x2, bias), aH3, 1e-9));
110 }
111 
112 /* ************************************************************************* */
113 int main() {
114  TestResult tr;
115  return TestRegistry::runAllTests(tr);
116 }
117 /* ************************************************************************* */
const double kGravity
static int runAllTests(TestResult &result)
Eigen::Vector3d Vector3
Definition: Vector.h:43
static std::shared_ptr< PreintegrationParams > Params()
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:40
void integrateMeasurements(const vector< ImuMeasurement > &measurements, PIM *pim)
Some functions to compute numerical derivatives.
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
Common testing infrastructure.
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.
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative21(const std::function< Y(const X1 &, const X2 &)> &h, const X1 &x1, const X2 &x2, double delta=1e-5)
static const double kAccelSigma
Vector3 deltaPij() const override
internal::FixedSizeMatrix< Y, X3 >::type numericalDerivative33(std::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
Vector3 deltaVij() const override
Test harness methods for expressions.
TEST(ManifoldPreintegration, BiasCorrectionJacobians)
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative32(std::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
#define EXPECT(condition)
Definition: Test.h:150
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative31(std::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RowVector3d w
static const Vector kZero
imuBias::ConstantBias Bias
Definition: testImuBias.cpp:27
Pose3 x1
Definition: testPose3.cpp:663
float * p
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative22(std::function< Y(const X1 &, const X2 &)> h, const X1 &x1, const X2 &x2, double delta=1e-5)
static std::shared_ptr< PreintegratedCombinedMeasurements::Params > Params(const Matrix3 &biasAccCovariance=Matrix3::Zero(), const Matrix3 &biasOmegaCovariance=Matrix3::Zero(), const Matrix6 &biasAccOmegaInt=Matrix6::Zero())
static const double kGyroSigma


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:38:44