utest.h
Go to the documentation of this file.
1 #ifndef UTEST_HPP_
2 #define UTEST_HPP_
3 
5 #include "pointmatcher/IO.h"
6 #include "../contrib/gtest/gtest.h"
7 
8 #include <string>
9 #include <fstream>
10 
11 #include "boost/filesystem.hpp"
12 #include "boost/filesystem/path.hpp"
13 #include "boost/filesystem/operations.hpp"
14 
15 typedef float NumericType;
18 
19 extern std::string dataPath;
20 
21 extern DP ref2D;
22 extern DP data2D;
23 extern DP ref3D;
24 extern DP data3D;
27 
28 //---------------------------
29 // Base for ICP tests
30 //---------------------------
31 
32 class IcpHelper: public testing::Test
33 {
34 public:
35 
37 
39 
40  virtual void dumpVTK()
41  {
42  // Make available a VTK inspector for manual inspection
43  icp.inspector =
44  PM::get().InspectorRegistrar.create(
45  "VTKFileInspector",
46  {{"baseFileName", "./unitTest"}}
47  );
48  }
49 
51  {
52  const PM::TransformationParameters testT = icp(data2D, ref2D);
53  const int dim = validT2d.cols();
54 
55  const BOOST_AUTO(validTrans, validT2d.block(0, dim-1, dim-1, 1).norm());
56  const BOOST_AUTO(testTrans, testT.block(0, dim-1, dim-1, 1).norm());
57 
58  const BOOST_AUTO(validAngle, acos(validT2d(0,0)));
59  const BOOST_AUTO(testAngle, acos(testT(0,0)));
60 
61  EXPECT_NEAR(validTrans, testTrans, 0.05);
62  EXPECT_NEAR(validAngle, testAngle, 0.05);
63  }
64 
66  {
67  //dumpVTK();
68 
69  const PM::TransformationParameters testT = icp(data3D, ref3D);
70  const int dim = validT2d.cols();
71 
72  const BOOST_AUTO(validTrans, validT3d.block(0, dim-1, dim-1, 1).norm());
73  const BOOST_AUTO(testTrans, testT.block(0, dim-1, dim-1, 1).norm());
74 
75  const BOOST_AUTO(testRotation, Eigen::Quaternion<float>(Eigen::Matrix<float,3,3>(testT.topLeftCorner(3,3))));
76  const BOOST_AUTO(validRotation, Eigen::Quaternion<float>(Eigen::Matrix<float,3,3>(validT3d.topLeftCorner(3,3))));
77 
78  const BOOST_AUTO(angleDist, validRotation.angularDistance(testRotation));
79 
80  //cout << testT << endl;
81  //cout << "angleDist: " << angleDist << endl;
82  //cout << "transDist: " << abs(validTrans-testTrans) << endl;
83  EXPECT_NEAR(validTrans, testTrans, 0.1);
84  EXPECT_NEAR(angleDist, 0.0, 0.1);
85 
86  }
87 };
88 
89 #endif /* UTEST_HPP_ */
90 
91 
DP data2D
Definition: utest.cpp:46
public interface
DP ref3D
Definition: utest.cpp:47
PM::Parameters params
Definition: utest.h:38
void validate2dTransformation()
Definition: utest.h:50
PM::TransformationParameters validT2d
Definition: utest.cpp:49
PM::DataPoints DataPoints
::std::string string
Definition: gtest.h:1979
Parametrizable::Parameters Parameters
alias
Definition: PointMatcher.h:186
#define EXPECT_NEAR(val1, val2, abs_error)
Definition: gtest.h:19868
Functions and classes that are dependant on scalar type are defined in this templatized class...
Definition: PointMatcher.h:130
void validate3dTransformation()
Definition: utest.h:65
static const PointMatcher & get()
Return instances.
Definition: Registry.cpp:145
virtual void dumpVTK()
Definition: utest.h:40
DP ref2D
Definition: utest.cpp:45
PM::TransformationParameters validT3d
Definition: utest.cpp:50
std::string dataPath
Definition: utest.cpp:43
std::shared_ptr< Inspector > inspector
inspector
Definition: PointMatcher.h:666
PM::ICP icp
Definition: utest.h:36
DP data3D
Definition: utest.cpp:48
PM::DataPoints DP
Definition: utest.h:17
PointMatcher< NumericType > PM
Definition: utest.h:16
ICP algorithm.
Definition: PointMatcher.h:702
Matrix TransformationParameters
A matrix holding the parameters a transformation.
Definition: PointMatcher.h:182
float NumericType
Definition: utest.h:15


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:03