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 
16 typedef PM::DataPoints DP;
17 
18 extern std::string dataPath;
19 
20 extern DP ref2D;
21 extern DP data2D;
22 extern DP ref3D;
23 extern DP data3D;
26 
27 //---------------------------
28 // Base for ICP tests
29 //---------------------------
30 
31 class IcpHelper: public testing::Test
32 {
33 public:
34 
36 
38 
39  virtual void dumpVTK()
40  {
41  // Make available a VTK inspector for manual inspection
42  icp.inspector =
43  PM::get().InspectorRegistrar.create(
44  "VTKFileInspector",
45  {{"baseFileName", "./unitTest"}}
46  );
47  }
48 
50  {
52  const int dim = validT2d.cols();
53 
54  const BOOST_AUTO(validTrans, validT2d.block(0, dim-1, dim-1, 1).norm());
55  const BOOST_AUTO(testTrans, testT.block(0, dim-1, dim-1, 1).norm());
56 
57  const BOOST_AUTO(validAngle, acos(validT2d(0,0)));
58  const BOOST_AUTO(testAngle, acos(testT(0,0)));
59 
60  EXPECT_NEAR(validTrans, testTrans, 0.05);
61  EXPECT_NEAR(validAngle, testAngle, 0.05);
62  }
63 
65  {
66  //dumpVTK();
67 
69  const int dim = validT2d.cols();
70 
71  const BOOST_AUTO(validTrans, validT3d.block(0, dim-1, dim-1, 1).norm());
72  const BOOST_AUTO(testTrans, testT.block(0, dim-1, dim-1, 1).norm());
73 
74  const BOOST_AUTO(testRotation, Eigen::Quaternion<float>(Eigen::Matrix<float,3,3>(testT.topLeftCorner(3,3))));
75  const BOOST_AUTO(validRotation, Eigen::Quaternion<float>(Eigen::Matrix<float,3,3>(validT3d.topLeftCorner(3,3))));
76 
77  const BOOST_AUTO(angleDist, validRotation.angularDistance(testRotation));
78 
79  //cout << testT << endl;
80  //cout << "angleDist: " << angleDist << endl;
81  //cout << "transDist: " << abs(validTrans-testTrans) << endl;
82  EXPECT_NEAR(validTrans, testTrans, 0.1);
83  EXPECT_NEAR(angleDist, 0.0, 0.1);
84 
85  }
86 };
87 
88 #endif /* UTEST_HPP_ */
89 
90 
ref3D
DP ref3D
Definition: utest.cpp:47
PointMatcher::Parameters
Parametrizable::Parameters Parameters
alias
Definition: PointMatcher.h:186
validT2d
PM::TransformationParameters validT2d
Definition: utest.cpp:49
IcpHelper::params
PM::Parameters params
Definition: utest.h:37
data2D
DP data2D
Definition: utest.cpp:46
EXPECT_NEAR
#define EXPECT_NEAR(val1, val2, abs_error)
Definition: gtest.h:19868
PointMatcher< float >
testing::Test
Definition: gtest.h:17760
IcpHelper::icp
PM::ICP icp
Definition: utest.h:35
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
dataPath
std::string dataPath
Definition: utest.cpp:43
ref2D
DP ref2D
Definition: utest.cpp:45
testing::internal::string
::std::string string
Definition: gtest.h:1979
IcpHelper
Definition: utest.h:31
IcpHelper::validate3dTransformation
void validate3dTransformation()
Definition: utest.h:64
DP
PM::DataPoints DP
Definition: utest.h:16
IcpHelper::dumpVTK
virtual void dumpVTK()
Definition: utest.h:39
PM
PointMatcher< float > PM
Definition: utest.h:15
PointMatcher::ICPChainBase::inspector
std::shared_ptr< Inspector > inspector
inspector
Definition: PointMatcher.h:663
validT3d
PM::TransformationParameters validT3d
Definition: utest.cpp:50
PointMatcher< float >::get
static const PointMatcher & get()
Return instances.
Definition: Registry.cpp:141
IcpHelper::validate2dTransformation
void validate2dTransformation()
Definition: utest.h:49
PointMatcher.h
public interface
data3D
DP data3D
Definition: utest.cpp:48
IO.h
PointMatcher::ICP
ICP algorithm.
Definition: PointMatcher.h:699
PointMatcher< float >::TransformationParameters
Matrix TransformationParameters
A matrix holding the parameters a transformation.
Definition: PointMatcher.h:182


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