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 double 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  {
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 
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<NumericType>(Eigen::Matrix<NumericType,3,3>(testT.topLeftCorner(3,3))));
76  const BOOST_AUTO(validRotation, Eigen::Quaternion<NumericType>(Eigen::Matrix<NumericType,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 
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:38
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:36
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:32
IcpHelper::validate3dTransformation
void validate3dTransformation()
Definition: utest.h:65
DP
PM::DataPoints DP
Definition: utest.h:17
IcpHelper::dumpVTK
virtual void dumpVTK()
Definition: utest.h:40
PM
PointMatcher< NumericType > PM
Definition: utest.h:16
NumericType
double NumericType
Definition: utest.h:15
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:146
IcpHelper::validate2dTransformation
void validate2dTransformation()
Definition: utest.h:50
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 Mon Sep 16 2024 02:24:10