2016-06-05 04:44:26 +08:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
|
|
|
|
* Atlanta, Georgia 30332-0415
|
|
|
|
|
* All Rights Reserved
|
|
|
|
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
|
|
|
|
|
|
|
|
|
* See LICENSE for the license information
|
|
|
|
|
|
|
|
|
|
* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file testManifoldPreintegration.cpp
|
|
|
|
|
* @brief Unit test for the ManifoldPreintegration
|
|
|
|
|
* @author Luca Carlone
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <gtsam/navigation/ManifoldPreintegration.h>
|
|
|
|
|
#include <gtsam/base/numericalDerivative.h>
|
|
|
|
|
#include <gtsam/nonlinear/expressions.h>
|
|
|
|
|
#include <gtsam/nonlinear/ExpressionFactor.h>
|
|
|
|
|
#include <gtsam/nonlinear/expressionTesting.h>
|
|
|
|
|
|
|
|
|
|
#include <CppUnitLite/TestHarness.h>
|
|
|
|
|
|
|
|
|
|
#include "imuFactorTesting.h"
|
|
|
|
|
|
2021-07-11 09:03:15 +08:00
|
|
|
using namespace std::placeholders;
|
2021-06-21 06:38:52 +08:00
|
|
|
|
2016-06-05 04:44:26 +08:00
|
|
|
namespace testing {
|
|
|
|
|
// Create default parameters with Z-down and above noise parameters
|
|
|
|
|
static boost::shared_ptr<PreintegrationParams> Params() {
|
|
|
|
|
auto p = PreintegrationParams::MakeSharedD(kGravity);
|
|
|
|
|
p->gyroscopeCovariance = kGyroSigma * kGyroSigma * I_3x3;
|
|
|
|
|
p->accelerometerCovariance = kAccelSigma * kAccelSigma * I_3x3;
|
|
|
|
|
p->integrationCovariance = 0.0001 * I_3x3;
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
2016-06-05 07:53:20 +08:00
|
|
|
TEST(ManifoldPreintegration, BiasCorrectionJacobians) {
|
|
|
|
|
testing::SomeMeasurements measurements;
|
2016-06-05 04:44:26 +08:00
|
|
|
|
2021-07-11 09:03:15 +08:00
|
|
|
std::function<Rot3(const Vector3&, const Vector3&)> deltaRij =
|
2016-06-05 07:53:20 +08:00
|
|
|
[=](const Vector3& a, const Vector3& w) {
|
|
|
|
|
ManifoldPreintegration pim(testing::Params(), Bias(a, w));
|
|
|
|
|
testing::integrateMeasurements(measurements, &pim);
|
|
|
|
|
return pim.deltaRij();
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-11 09:03:15 +08:00
|
|
|
std::function<Point3(const Vector3&, const Vector3&)> deltaPij =
|
2016-06-05 07:53:20 +08:00
|
|
|
[=](const Vector3& a, const Vector3& w) {
|
|
|
|
|
ManifoldPreintegration pim(testing::Params(), Bias(a, w));
|
|
|
|
|
testing::integrateMeasurements(measurements, &pim);
|
|
|
|
|
return pim.deltaPij();
|
|
|
|
|
};
|
|
|
|
|
|
2021-07-11 09:03:15 +08:00
|
|
|
std::function<Vector3(const Vector3&, const Vector3&)> deltaVij =
|
2016-06-05 07:53:20 +08:00
|
|
|
[=](const Vector3& a, const Vector3& w) {
|
|
|
|
|
ManifoldPreintegration pim(testing::Params(), Bias(a, w));
|
|
|
|
|
testing::integrateMeasurements(measurements, &pim);
|
|
|
|
|
return pim.deltaVij();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Actual pre-integrated values
|
2016-06-05 04:44:26 +08:00
|
|
|
ManifoldPreintegration pim(testing::Params());
|
2016-06-05 07:53:20 +08:00
|
|
|
testing::integrateMeasurements(measurements, &pim);
|
|
|
|
|
|
|
|
|
|
EXPECT(
|
|
|
|
|
assert_equal(numericalDerivative21(deltaRij, kZero, kZero),
|
|
|
|
|
Matrix3(Z_3x3)));
|
|
|
|
|
EXPECT(
|
|
|
|
|
assert_equal(numericalDerivative22(deltaRij, kZero, kZero),
|
|
|
|
|
pim.delRdelBiasOmega(), 1e-3));
|
|
|
|
|
|
|
|
|
|
EXPECT(
|
|
|
|
|
assert_equal(numericalDerivative21(deltaPij, kZero, kZero),
|
|
|
|
|
pim.delPdelBiasAcc()));
|
|
|
|
|
EXPECT(
|
|
|
|
|
assert_equal(numericalDerivative22(deltaPij, kZero, kZero),
|
|
|
|
|
pim.delPdelBiasOmega(), 1e-3));
|
2016-06-05 04:54:23 +08:00
|
|
|
|
2016-06-05 07:53:20 +08:00
|
|
|
EXPECT(
|
|
|
|
|
assert_equal(numericalDerivative21(deltaVij, kZero, kZero),
|
|
|
|
|
pim.delVdelBiasAcc()));
|
|
|
|
|
EXPECT(
|
|
|
|
|
assert_equal(numericalDerivative22(deltaVij, kZero, kZero),
|
|
|
|
|
pim.delVdelBiasOmega(), 1e-3));
|
2016-06-05 04:44:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
|
|
|
|
TEST(ManifoldPreintegration, computeError) {
|
|
|
|
|
ManifoldPreintegration pim(testing::Params());
|
|
|
|
|
NavState x1, x2;
|
|
|
|
|
imuBias::ConstantBias bias;
|
|
|
|
|
Matrix9 aH1, aH2;
|
|
|
|
|
Matrix96 aH3;
|
|
|
|
|
pim.computeError(x1, x2, bias, aH1, aH2, aH3);
|
2021-07-11 09:03:15 +08:00
|
|
|
std::function<Vector9(const NavState&, const NavState&,
|
|
|
|
|
const imuBias::ConstantBias&)>
|
|
|
|
|
f = std::bind(&ManifoldPreintegration::computeError, pim,
|
|
|
|
|
std::placeholders::_1, std::placeholders::_2,
|
2023-01-14 06:11:03 +08:00
|
|
|
std::placeholders::_3, nullptr, nullptr,
|
|
|
|
|
nullptr);
|
2016-06-05 04:44:26 +08:00
|
|
|
// NOTE(frank): tolerance of 1e-3 on H1 because approximate away from 0
|
|
|
|
|
EXPECT(assert_equal(numericalDerivative31(f, x1, x2, bias), aH1, 1e-9));
|
|
|
|
|
EXPECT(assert_equal(numericalDerivative32(f, x1, x2, bias), aH2, 1e-9));
|
|
|
|
|
EXPECT(assert_equal(numericalDerivative33(f, x1, x2, bias), aH3, 1e-9));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************************************************************* */
|
|
|
|
|
int main() {
|
|
|
|
|
TestResult tr;
|
|
|
|
|
return TestRegistry::runAllTests(tr);
|
|
|
|
|
}
|
|
|
|
|
/* ************************************************************************* */
|