ErrorMinimizers.cpp
Go to the documentation of this file.
1 #include "../utest.h"
2 
3 using namespace std;
4 using namespace PointMatcherSupport;
5 
6 //---------------------------
7 // Error modules
8 //---------------------------
9 
10 // Utility classes
12 {
13 public:
14  std::shared_ptr<PM::ErrorMinimizer> errorMin;
15 
16  // Will be called for every tests
17  virtual void SetUp()
18  {
19  icp.setDefault();
20  // Uncomment for consol outputs
21  //setLogger(PM::get().LoggerRegistrar.create("FileLogger"));
22  }
23 
24  // Will be called for every tests
25  virtual void TearDown(){}
26 
27  void setError(string name)
28  {
29  errorMin = PM::get().ErrorMinimizerRegistrar.create(name);
30  icp.errorMinimizer = errorMin;
31  }
32 };
33 
34 
36 {
37  setError("PointToPointErrorMinimizer");
38  validate2dTransformation();
39  validate3dTransformation();
40 }
41 
43 {
44  setError("PointToPlaneErrorMinimizer");
45  validate2dTransformation();
46  validate3dTransformation();
47 }
48 
49 TEST_F(ErrorMinimizerTest, ErrorElements)
50 {
51  const unsigned int nbPoints = 100;
52  const unsigned int dimFeatures = 4;
53  const unsigned int dimDescriptors = 3;
54  const unsigned int dimTime = 2;
55 
56  // Fake DataPoints
57  PM::Matrix randFeat = PM::Matrix::Random(dimFeatures, nbPoints);
58  DP::Labels featLabels;
59  featLabels.push_back(DP::Label("x", 1));
60  featLabels.push_back(DP::Label("y", 1));
61  featLabels.push_back(DP::Label("z", 1));
62  featLabels.push_back(DP::Label("pad", 1));
63 
64  PM::Matrix randDesc = PM::Matrix::Random(dimDescriptors, nbPoints);
65  DP::Labels descLabels;
66  descLabels.push_back(DP::Label("dummyDesc", 3));
67 
68  PM::Int64Matrix randTimes = PM::Int64Matrix::Random(dimTime, nbPoints);
69  DP::Labels timeLabels;
70  timeLabels.push_back(DP::Label("dummyTime", 2));
71 
72  // Construct the point cloud from the generated matrices
73  DP request = DP(randFeat, featLabels, randDesc, descLabels, randTimes, timeLabels);
74  DP source = DP(randFeat, featLabels, randDesc, descLabels, randTimes, timeLabels);
75 
76  // Fake Weights
77  PM::OutlierWeights weights = PM::OutlierWeights::Ones(1, nbPoints);
78 
79  // Fake Matches
80  PM::Matches::Ids ids(1, nbPoints);
81  PM::Matches::Dists dists(1, nbPoints);
82 
83  for(unsigned int i=0; i<nbPoints; i++)
84  {
85  ids(0,i) = i;
86  dists(0,i) = 1.0;
87  }
88 
89  // Construct matches from generated matrices
90  PM::Matches matches(dists, ids);
91 
92 
93  // Finally, the constructor for ErrorElements
94  PM::ErrorMinimizer::ErrorElements mPts(request, source, weights, matches);
95 
96  // check number of points
97  EXPECT_EQ(mPts.reference.getNbPoints(), nbPoints);
98  EXPECT_EQ(mPts.reference.getNbPoints(), mPts.reading.getNbPoints());
99 
100  // check descriptor
101  EXPECT_EQ(mPts.reference.getDescriptorDim(), dimDescriptors);
102 
103  // check time
104  EXPECT_EQ(mPts.reference.getTimeDim(), dimTime);
105 
106 }
107 
PointMatcher< float >::OutlierWeights
Matrix OutlierWeights
Weights of the associations between the points in Matches and the points in the reference.
Definition: PointMatcher.h:397
PointMatcher::DataPoints::Labels
A vector of Label.
Definition: PointMatcher.h:229
ErrorMinimizerTest::SetUp
virtual void SetUp()
Definition: ErrorMinimizers.cpp:17
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
ErrorMinimizerTest::errorMin
std::shared_ptr< PM::ErrorMinimizer > errorMin
Definition: ErrorMinimizers.cpp:14
IcpHelper
Definition: utest.h:31
ErrorMinimizerTest::setError
void setError(string name)
Definition: ErrorMinimizers.cpp:27
EXPECT_EQ
#define EXPECT_EQ(expected, actual)
Definition: gtest.h:19747
PointMatcher< float >::Int64Matrix
Eigen::Matrix< std::int64_t, Eigen::Dynamic, Eigen::Dynamic > Int64Matrix
A dense signed 64-bits matrix.
Definition: PointMatcher.h:173
ErrorMinimizerTest
Definition: ErrorMinimizers.cpp:11
PointToPlaneErrorMinimizer
Definition: PointToPlane.h:42
PointMatcher< float >::Matrix
Eigen::Matrix< float, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dense matrix over ScalarType.
Definition: PointMatcher.h:169
ErrorMinimizerTest::TearDown
virtual void TearDown()
Definition: ErrorMinimizers.cpp:25
std
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
DP
PM::DataPoints DP
Definition: convert.cpp:45
TEST_F
TEST_F(ErrorMinimizerTest, PointToPointErrorMinimizer)
Definition: ErrorMinimizers.cpp:35
PointToPointErrorMinimizer
Definition: PointToPoint.h:42
PointMatcher::DataPoints::Label
The name for a certain number of dim.
Definition: PointMatcher.h:221


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