Transformations.cpp
Go to the documentation of this file.
1 #include "../utest.h"
2 
3 using namespace std;
4 using namespace PointMatcherSupport;
5 
6 
7 //---------------------------
8 // Transformation Checker modules
9 //---------------------------
10 
11 // Utility classes
13 {
14 public:
15  std::shared_ptr<PM::TransformationChecker> transformCheck;
16 
17  // Will be called for every tests
18  virtual void SetUp()
19  {
20  icp.setDefault();
21  // Uncomment for consol outputs
22  //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
23 
24  icp.transformationCheckers.clear();
25  }
26 
27  // Will be called for every tests
28  virtual void TearDown(){}
29 
30  void addFilter(string name, PM::Parameters params)
31  {
32  transformCheck =
33  PM::get().TransformationCheckerRegistrar.create(name, params);
34 
35  icp.transformationCheckers.push_back(transformCheck);
36  }
37 };
38 
39 
40 TEST_F(TransformationCheckerTest, CounterTransformationChecker)
41 {
42  addFilter("CounterTransformationChecker", {{"maxIterationCount", toParam(20)}});
43  validate2dTransformation();
44 }
45 
46 TEST_F(TransformationCheckerTest, DifferentialTransformationChecker)
47 {
48  addFilter("DifferentialTransformationChecker", {
49  {"minDiffRotErr", toParam(0.001)},
50  {"minDiffTransErr", toParam(0.001)},
51  {"smoothLength", toParam(4)}
52  }
53  );
54  validate2dTransformation();
55 }
56 
57 TEST_F(TransformationCheckerTest, BoundTransformationChecker)
58 {
59  // Since that transChecker is trigger when the distance is growing
60  // and that we do not expect that to happen in the test dataset, we
61  // keep the Counter to get out of the looop
62  std::shared_ptr<PM::TransformationChecker> extraTransformCheck;
63 
64  extraTransformCheck = PM::get().TransformationCheckerRegistrar.create(
65  "CounterTransformationChecker"
66  );
67  icp.transformationCheckers.push_back(extraTransformCheck);
68 
69  addFilter("BoundTransformationChecker", {
70  {"maxRotationNorm", toParam(1.0)},
71  {"maxTranslationNorm", toParam(1.0)}
72  }
73  );
74  validate2dTransformation();
75 }
76 
77 //---------------------------
78 // Transformation
79 //---------------------------
80 TEST(Transformation, RigidTransformation)
81 {
82  std::shared_ptr<PM::Transformation> rigidTrans;
83  rigidTrans = PM::get().REG(Transformation).create("RigidTransformation");
84 
85  //-------------------------------------
86  // Construct a 3D non-orthogonal matrix
87  PM::Matrix T_3D = PM::Matrix::Identity(4,4);
88  //T_3D(0,0) = 2.3;
89  //T_3D(0,1) = 0.03;
90  T_3D << 0.99935116, 0.13669771, 0.03436585, 1.71138524,
91  -0.02633967, 0.99326295, -0.04907545, -0.10860933,
92  -0.03615132, 0.04400287, 0.99820427, -0.04454497,
93  0. , 0. , 0. , 1.;
94 
95  EXPECT_FALSE(rigidTrans->checkParameters(T_3D));
96 
97  EXPECT_THROW(rigidTrans->compute(data3D, T_3D), TransformationError);
98 
99  // Check stability over iterations
100  for(int i = 0; i < 10; i++)
101  {
102  T_3D = rigidTrans->correctParameters(T_3D);
103  ASSERT_TRUE(rigidTrans->checkParameters(T_3D));
104  }
105 
106  //-------------------------------------
107  // Construct a 2D non-orthogonal matrix
108  PM::Matrix T_2D_non_ortho = PM::Matrix::Identity(3,3);
109  T_2D_non_ortho(0,0) = 0.8;
110  T_2D_non_ortho(0,1) = -0.5;
111  T_2D_non_ortho(1,0) = 0.5;
112  T_2D_non_ortho(1,1) = 0.8;
113 
114  EXPECT_FALSE(rigidTrans->checkParameters(T_2D_non_ortho));
115 
116  EXPECT_THROW(rigidTrans->compute(data2D, T_2D_non_ortho), TransformationError);
117 
118  // Check stability over iterations
119  for(int i = 0; i < 10; i++)
120  {
121  T_2D_non_ortho = rigidTrans->correctParameters(T_2D_non_ortho);
122  EXPECT_TRUE(rigidTrans->checkParameters(T_2D_non_ortho));
123  }
124 
125  //-------------------------------------
126  // Construct a 2D reflection matrix
127  PM::Matrix T_2D_reflection = PM::Matrix::Identity(3,3);
128  T_2D_reflection(1,1) = -1;
129 
130  EXPECT_THROW(rigidTrans->correctParameters(T_2D_reflection), TransformationError);
131 }
PointMatcher< float >::Parameters
Parametrizable::Parameters Parameters
alias
Definition: PointMatcher.h:186
PointMatcherSupport::toParam
std::string toParam(const S &value)
Return the a string value using lexical_cast.
Definition: Parametrizable.h:92
TransformationCheckerTest
Definition: Transformations.cpp:12
TransformationCheckerTest::SetUp
virtual void SetUp()
Definition: Transformations.cpp:18
TEST_F
TEST_F(TransformationCheckerTest, CounterTransformationChecker)
Definition: Transformations.cpp:40
EXPECT_TRUE
#define EXPECT_TRUE(condition)
Definition: gtest.h:19327
TransformationCheckerTest::transformCheck
std::shared_ptr< PM::TransformationChecker > transformCheck
Definition: Transformations.cpp:15
TransformationCheckerTest::addFilter
void addFilter(string name, PM::Parameters params)
Definition: Transformations.cpp:30
IcpHelper
Definition: utest.h:31
EXPECT_FALSE
#define EXPECT_FALSE(condition)
Definition: gtest.h:19330
data2D
DP data2D
Definition: utest.cpp:46
TransformationCheckerTest::TearDown
virtual void TearDown()
Definition: Transformations.cpp:28
ASSERT_TRUE
#define ASSERT_TRUE(condition)
Definition: gtest.h:19333
PointMatcher< float >::Matrix
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dense matrix over ScalarType.
Definition: PointMatcher.h:169
data3D
DP data3D
Definition: utest.cpp:48
std
EXPECT_THROW
#define EXPECT_THROW(statement, expected_exception)
Definition: gtest.h:19311
PointMatcher< float >::get
static const PointMatcher & get()
Return instances.
Definition: Registry.cpp:141
PointMatcherSupport
Functions and classes that are not dependant on scalar type are defined in this namespace.
Definition: Bibliography.cpp:45
PointMatcherSupport::TransformationError
An expection thrown when a transformation has invalid parameters.
Definition: PointMatcher.h:89
TEST
TEST(Transformation, RigidTransformation)
Definition: Transformations.cpp:80


mp2p_icp
Author(s):
autogenerated on Thu Dec 26 2024 03:48:13