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


libpointmatcher
Author(s):
autogenerated on Sun Dec 22 2024 03:21:54