farm-ng-core
manifold_prop_tests.h
Go to the documentation of this file.
1 // Copyright (c) 2011, Hauke Strasdat
2 // Copyright (c) 2012, Steven Lovegrove
3 // Copyright (c) 2021, farm-ng, inc.
4 //
5 // Use of this source code is governed by an MIT-style
6 // license that can be found in the LICENSE file or at
7 // https://opensource.org/licenses/MIT.
8 
9 #pragma once
10 
12 
13 namespace sophus {
14 namespace test {
15 
16 template <concepts::Manifold TManifold>
18  using Manifold = TManifold;
19  using Scalar = typename Manifold::Scalar;
20  static int constexpr kDof = Manifold::kDof;
21  static int constexpr kNumParams = Manifold::kNumParams;
22 
23  using Tangent = Eigen::Vector<Scalar, kDof>;
24  using Params = Eigen::Vector<Scalar, kNumParams>;
25 
26  static void oplusOMinusRoundTripTest(std::string manifold_name) {
27  auto params_examples = Manifold::paramsExamples();
28  auto tangent_examples = Manifold::tangentExamples();
29 
30  for (size_t params_id = 0; params_id < params_examples.size();
31  ++params_id) {
32  Params params = SOPHUS_AT(params_examples, params_id);
33  Manifold a = Manifold::fromParams(params);
34  for (size_t tangent_id = 0; tangent_id < tangent_examples.size();
35  ++tangent_id) {
36  Tangent delta = SOPHUS_AT(tangent_examples, tangent_id);
37  Manifold b = a.oplus(delta);
39  a.ominus(b),
40  delta,
41  kEpsilonF64,
42  "oplusOMinusRoundTripTest: {}\n"
43  "a: {}\nb: {}",
44  manifold_name,
45  a.vector().transpose(),
46  b.vector().transpose());
47  }
48  }
49  }
50 
51  static void runAllTests(std::string manifold_name) {
52  oplusOMinusRoundTripTest(manifold_name);
53  }
54 };
55 
56 } // namespace test
57 } // namespace sophus
sophus::test::ManifoldPropTestSuite::kDof
static constexpr int kDof
Definition: manifold_prop_tests.h:20
manifold.h
sophus
Image MutImage, owning images types.
Definition: num_diff.h:20
sophus::test::ManifoldPropTestSuite::kNumParams
static constexpr int kNumParams
Definition: manifold_prop_tests.h:21
sophus::test::ManifoldPropTestSuite::Params
Eigen::Vector< Scalar, kNumParams > Params
Definition: manifold_prop_tests.h:24
sophus::test::ManifoldPropTestSuite
Definition: manifold_prop_tests.h:17
SOPHUS_ASSERT_NEAR
#define SOPHUS_ASSERT_NEAR(...)
Definition: common.h:47
sophus::test::ManifoldPropTestSuite::Scalar
typename Manifold::Scalar Scalar
Definition: manifold_prop_tests.h:19
sophus::test::ManifoldPropTestSuite::Manifold
TManifold Manifold
Definition: manifold_prop_tests.h:18
SOPHUS_AT
#define SOPHUS_AT(...)
Definition: common.h:48
sophus::test::ManifoldPropTestSuite::runAllTests
static void runAllTests(std::string manifold_name)
Definition: manifold_prop_tests.h:51
sophus::test::ManifoldPropTestSuite::Tangent
Eigen::Vector< Scalar, kDof > Tangent
Definition: manifold_prop_tests.h:23
sophus::test::ManifoldPropTestSuite::oplusOMinusRoundTripTest
static void oplusOMinusRoundTripTest(std::string manifold_name)
Definition: manifold_prop_tests.h:26