diff --git a/gtsam/navigation/tests/testImuFactor.cpp b/gtsam/navigation/tests/testImuFactor.cpp index 03cff1f37..51aa7c7c5 100644 --- a/gtsam/navigation/tests/testImuFactor.cpp +++ b/gtsam/navigation/tests/testImuFactor.cpp @@ -117,14 +117,26 @@ Vector3 evaluateLogRotation(const Vector3 thetahat, const Vector3 deltatheta) { Matrix9 MonteCarlo(const PreintegratedImuMeasurements& pim, const NavState& state, const imuBias::ConstantBias& bias, double dt, const Pose3& body_P_sensor, const Vector3& measuredAcc, - const Vector3& measuredOmega, size_t N = 10000) { + const Vector3& measuredOmega, size_t N = 10, size_t M = 1) { // Get mean prediction from "ground truth" measurements PreintegratedImuMeasurements pim1 = pim; - for (size_t k=0;k<10;k++) + for (size_t k=0;kaccelerometerCovariance = kMeasuredAccCovariance; p->gyroscopeCovariance = kMeasuredOmegaCovariance; + // Check G1 and G2 derivatives of pim.update + // Now, preintegrate for 3 seconds, in 10 steps PreintegratedImuMeasurements pim(p, kZeroBiasHat); for (size_t i = 0; i < 10; i++) pim.integrateMeasurement(measuredAcc, measuredOmega, dt / 10); - // Get mean prediction from "ground truth" measurements + Matrix93 aG1,aG2; + boost::function f = + boost::bind(&PreintegrationBase::updatedDeltaXij, pim, _1, _2, dt/10, + boost::none, boost::none, boost::none); + pim.updatedDeltaXij(measuredAcc, measuredOmega, dt / 10, boost::none, aG1, aG2); + EXPECT(assert_equal(numericalDerivative21(f, measuredAcc, measuredOmega, 1e-7), aG1, 1e-7)); + EXPECT(assert_equal(numericalDerivative22(f, measuredAcc, measuredOmega, 1e-7), aG2, 1e-7)); + cout << "aG1" << endl; + cout << aG1 << endl; + cout << "aG2:" << endl; + cout << aG2 << endl; + + // Do Monte-Carlo analysis PreintegratedImuMeasurements pimMC(kZeroBiasHat, p->accelerometerCovariance, p->gyroscopeCovariance, Z_3x3, true); // MonteCarlo does not sample integration noise Matrix9 Q = MonteCarlo(pimMC, state1, kZeroBias, dt/10, Pose3(), measuredAcc,