Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmake/HandleGeneralOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ option(GTSAM_ALLOW_DEPRECATED_SINCE_V43 "Allow use of methods/functions depr
option(GTSAM_SUPPORT_NESTED_DISSECTION "Support Metis-based nested dissection" ON)
option(GTSAM_TANGENT_PREINTEGRATION "Use new ImuFactor with integration on tangent space" ON)
option(GTSAM_SLOW_BUT_CORRECT_BETWEENFACTOR "Use the slower but correct version of BetweenFactor" OFF)
option(GTSAM_SLOW_BUT_CORRECT_EXPMAP "Use slower but correct expmap for Pose2" OFF)
option(GTSAM_SLOW_BUT_CORRECT_EXPMAP "Use slower but correct expmap for Pose2" ON)

message(WARNING "GTSAM_SLOW_BUT_CORRECT_EXPMAP has been deprecated and will be removed in a future release.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this message be displayed only when set to OFF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.


if (GTSAM_FORCE_SHARED_LIB AND GTSAM_FORCE_STATIC_LIB)
message(FATAL_ERROR "GTSAM_FORCE_SHARED_LIB and GTSAM_FORCE_STATIC_LIB are both true. Please, to unambiguously select the desired library type to use to build GTSAM, set one of GTSAM_FORCE_SHARED_LIB=ON, GTSAM_FORCE_STATIC_LIB=ON, or BUILD_SHARED_LIBS={ON/OFF}")
Expand Down
2 changes: 1 addition & 1 deletion gtsam/basis/tests/testChebyshev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ TEST(Chebyshev2, InterpolatePose2) {
std::placeholders::_1, nullptr);
Matrix numericalH =
numericalDerivative11<Pose2, Matrix, 3 * N>(f, X);
EXPECT(assert_equal(numericalH, actualH, 1e-9));
EXPECT(assert_equal(numericalH, actualH, 1e-5));
}

#ifdef GTSAM_POSE3_EXPMAP
Expand Down
4 changes: 4 additions & 0 deletions gtsam/slam/tests/testInitializePose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ TEST(InitializePose3, computePoses2D) {
const Values poses = initialize::computePoses<Pose2>(orientations, &poseGraph);

// posesInFile is seriously noisy, so we check error of recovered poses
#ifdef GTSAM_SLOW_BUT_CORRECT_EXPMAP
EXPECT_DOUBLES_EQUAL(0.080775, inputGraph->error(poses), 1e-6);
#else
EXPECT_DOUBLES_EQUAL(0.0810283, inputGraph->error(poses), 1e-6);
#endif
}

/* ************************************************************************* */
Expand Down
16 changes: 7 additions & 9 deletions gtsam_unstable/slam/TSAMFactors.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,13 @@ class OdometryFactorBase: public NoiseModelFactorN<Pose2, Pose2, Pose2, Pose2> {
Pose2 pose2_g = base2.compose(pose2, D_pose2_g_base2, D_pose2_g_pose2);
Matrix D_e_pose1_g, D_e_pose2_g;
Pose2 d = pose1_g.between(pose2_g, D_e_pose1_g, D_e_pose2_g);
if (H1)
*H1 = D_e_pose1_g * D_pose1_g_base1;
if (H2)
*H2 = D_e_pose1_g * D_pose1_g_pose1;
if (H3)
*H3 = D_e_pose2_g * D_pose2_g_base2;
if (H4)
*H4 = D_e_pose2_g * D_pose2_g_pose2;
return measured_.localCoordinates(d);
Matrix3 H;
auto error = measured_.localCoordinates(d, nullptr, H);
if (H1) *H1 = H * D_e_pose1_g * D_pose1_g_base1;
if (H2) *H2 = H * D_e_pose1_g * D_pose1_g_pose1;
if (H3) *H3 = H * D_e_pose2_g * D_pose2_g_base2;
if (H4) *H4 = H * D_e_pose2_g * D_pose2_g_pose2;
return error;
} else {
Pose2 pose1_g = base1.compose(pose1);
Pose2 pose2_g = base2.compose(pose2);
Expand Down
8 changes: 4 additions & 4 deletions gtsam_unstable/slam/tests/testTSAMFactors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ TEST( OdometryFactorBase, all ) {
pose2);

// Verify the Jacobians are correct
EXPECT(assert_equal(H1Expected, H1Actual, 1e-9));
EXPECT(assert_equal(H2Expected, H2Actual, 1e-9));
EXPECT(assert_equal(H3Expected, H3Actual, 1e-9));
EXPECT(assert_equal(H4Expected, H4Actual, 1e-9));
EXPECT(assert_equal(H1Expected, H1Actual, 1e-5));
EXPECT(assert_equal(H2Expected, H2Actual, 1e-5));
EXPECT(assert_equal(H3Expected, H3Actual, 1e-5));
EXPECT(assert_equal(H4Expected, H4Actual, 1e-5));
}

//*************************************************************************
Expand Down
3 changes: 2 additions & 1 deletion python/gtsam/tests/test_FixedLagSmootherExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def test_FixedLagSmootherExample(self):

i = 0

# regression values work for both slow and fast retract, with loose threshold
ground_truth = [
gtsam.Pose2(0.995821, 0.0231012, 0.0300001),
gtsam.Pose2(1.49284, 0.0457247, 0.045),
Expand Down Expand Up @@ -114,7 +115,7 @@ def test_FixedLagSmootherExample(self):
smoother_batch.update(new_factors, new_values, new_timestamps)

estimate = smoother_batch.calculateEstimatePose2(current_key)
self.assertTrue(estimate.equals(ground_truth[i], 1e-4))
self.gtsamAssertEquals(estimate, ground_truth[i], 1e-2)
i += 1

new_timestamps.clear()
Expand Down
3 changes: 2 additions & 1 deletion python/gtsam/tests/test_backwards_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def test_FixedLagSmootherExample(self):

i = 0

# regression values work for both slow and fast retract, with loose threshold
ground_truth = [
Pose2(0.995821, 0.0231012, 0.0300001),
Pose2(1.49284, 0.0457247, 0.045),
Expand Down Expand Up @@ -267,7 +268,7 @@ def test_FixedLagSmootherExample(self):
smoother_batch.update(new_factors, new_values, new_timestamps)

estimate = smoother_batch.calculateEstimatePose2(current_key)
self.assertTrue(estimate.equals(ground_truth[i], 1e-4))
self.gtsamAssertEquals(estimate, ground_truth[i], 1e-2)
i += 1

new_timestamps.clear()
Expand Down
2 changes: 2 additions & 0 deletions tests/testGncOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ TEST(GncOptimizer, setInlierCostThresholds) {
}

/* ************************************************************************* */
#ifndef GTSAM_SLOW_BUT_CORRECT_EXPMAP
TEST(GncOptimizer, optimizeSmallPoseGraph) {
/// load small pose graph
const string filename = findExampleDataFile("w100.graph");
Expand Down Expand Up @@ -771,6 +772,7 @@ TEST(GncOptimizer, optimizeSmallPoseGraph) {
// compare
CHECK(assert_equal(expected, actual, 1e-3)); // yay! we are robust to outliers!
}
#endif

/* ************************************************************************* */
TEST(GncOptimizer, knownInliersAndOutliers) {
Expand Down
15 changes: 10 additions & 5 deletions tests/testNonlinearOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ TEST_UNSAFE(NonlinearOptimizer, MoreOptimization) {
Values expected;
expected.insert(0, Pose2(0, 0, 0));
expected.insert(1, Pose2(1, 0, M_PI / 2));
#ifdef GTSAM_SLOW_BUT_CORRECT_EXPMAP
expected.insert(2, Pose2(1, 1, -M_PI));
#else
expected.insert(2, Pose2(1, 1, M_PI));
#endif

VectorValues expectedGradient;
expectedGradient.insert(0,Z_3x1);
Expand All @@ -276,11 +280,12 @@ TEST_UNSAFE(NonlinearOptimizer, MoreOptimization) {

// test convergence
Values actual = optimizer.optimize();
EXPECT(assert_equal(expected, actual));

EXPECT(assert_equal(expected, actual, 1e-5));

// Check that the gradient is zero
GaussianFactorGraph::shared_ptr linear = optimizer.linearize();
EXPECT(assert_equal(expectedGradient,linear->gradientAtZero()));
EXPECT(assert_equal(expectedGradient,linear->gradientAtZero(), 1e-7));
}
EXPECT(assert_equal(expected, DoglegOptimizer(fg, init).optimize()));

Expand Down Expand Up @@ -309,16 +314,16 @@ TEST_UNSAFE(NonlinearOptimizer, MoreOptimization) {

// test convergence (does not!)
Values actual = optimizer.optimize();
EXPECT(assert_equal(expected, actual));
EXPECT(assert_equal(expected, actual, 1e-8));

// Check that the gradient is zero (it is not!)
linear = optimizer.linearize();
EXPECT(assert_equal(expectedGradient,linear->gradientAtZero()));
EXPECT(assert_equal(expectedGradient,linear->gradientAtZero(), 1e-8));

// Check that the gradient is zero for damped system (it is not!)
damped = optimizer.buildDampedSystem(*linear, sqrtHessianDiagonal);
VectorValues actualGradient = damped.gradientAtZero();
EXPECT(assert_equal(expectedGradient,actualGradient));
EXPECT(assert_equal(expectedGradient,actualGradient, 1e-8));

/* This block was made to test the original initial guess "init"
// Check errors at convergence and errors in direction of gradient (decreases!)
Expand Down
Loading