test_paper_prediction_normalized.cpp
Go to the documentation of this file.
1 
18 // Bring in my package's API, which is what I'm testing
19 #include "asr_recognizer_prediction_ism/pose_prediction/PaperPredictionNormalized.h"
20 // Bring in gtest
21 #include <random>
22 #include <gtest/gtest.h>
23 
24 // Declare a test
26 {
27  class PaperPredictionNormalizedTest : public ::testing::Test
28  {
29  protected:
30 
31  // Per-test-case set-up.
32  // Called before the first test in this test case.
33  // Can be omitted if not needed.
34  static void SetUpTestCase()
35  {
36  }
37 
38  // Per-test-case tear-down.
39  // Called after the last test in this test case.
40  // Can be omitted if not needed.
41  static void TearDownTestCase()
42  {
43  }
44 
45  // You can define per-test set-up and tear-down logic as usual.
46  virtual void SetUp()
47  {
48  std::string dbfilename = "/home/patrick/catkin_ws/src/ilcasRosFull/perception/scene_understanding/recognizer_prediction_ism/test/rsc/smacks_throne.sqlite";
49  double confidence = 1;
50  double numberOfSpecifiers = 20;
51  patternName= "test";
52  confidence = 1;
53 
54  referencePose = ISM::PosePtr(new ISM::Pose);
55  referencePose->getQuatPtr()->setW(1);
56  recognizedSet = ISM::ObjectSetPtr(new ISM::ObjectSet());
57  resultPtr = ISM::RecognitionResultPtr(new ISM::RecognitionResult(patternName,referencePose,
58  recognizedSet,confidence,
60  recognitionResults.push_back(resultPtr);
61  paperPredictionNormalizedPtr = PaperPredictionNormalizedPtr(new PaperPredictionNormalized(confidence,
62  numberOfSpecifiers,
63  dbfilename));
64  }
65  virtual void TearDown()
66  {
67 
68  }
69 
70  public:
71  std::string patternName;
72  ISM::PosePtr referencePose;
73  ISM::ObjectSetPtr recognizedSet;
74  std::vector<ISM::PointPtr> idealPoints;
75  std::vector<ISM::VotedPointsTypePtr> votedPoints;
76  ISM::RecognitionResultPtr resultPtr;
77 
78  std::vector<ISM::RecognitionResultPtr> recognitionResults;
79  PaperPredictionNormalizedPtr paperPredictionNormalizedPtr;
80 
81  };
83  {
84  using namespace ISM;
85 
86  PointPtr plateDeepPointPtr(new Point(-0.888345658850255, 0.632926776060424,
87  0.660864250036386));
88  QuaternionPtr plateDeepQuatPtr(new Quaternion(0.651570493634819, -0.643417330721776,
89  -0.27727505130885, 0.2908411529908));
90  PosePtr plateDeepPosePtr(new Pose(plateDeepPointPtr, plateDeepQuatPtr));
91 
92  paperPredictionNormalizedPtr->calcUnfoundPoses(plateDeepPosePtr,patternName,1);
93 
94  PointPtr cupPdVPointPtr(new Point(-0.89555632189646,
95  0.876282245569256,
96  0.675197306649648));
97  QuaternionPtr cupPdVQuatPtr(new Quaternion(0.0437368287079934,
98  -0.00284608589628875,
99  -0.673893495136102,
100  0.737527319373925));
101  bool found = false;
102  asr_next_best_view::AttributedPointCloud attributedPointCloud = paperPredictionNormalizedPtr->getAttributedPointCloud();
103  for (asr_next_best_view::AttributedPoint attributedPoint : attributedPointCloud.elements)
104  {
105  double x = attributedPoint.pose.position.x;
106  double y = attributedPoint.pose.position.y;
107  double z = attributedPoint.pose.position.z;
108  double qw = attributedPoint.pose.orientation.w;
109  double qx = attributedPoint.pose.orientation.x;
110  double qy = attributedPoint.pose.orientation.y;
111  double qz = attributedPoint.pose.orientation.z;
112 
113  PointPtr currentPointPtr(new Point(x,y,z));
114  QuaternionPtr currentQuaternionPtr(new Quaternion(qw, qx, qy, qz));
115  double distance = GeometryHelper::getDistanceBetweenPoints(currentPointPtr,cupPdVPointPtr);
116  double angle = GeometryHelper::getAngleBetweenQuats(currentQuaternionPtr, cupPdVQuatPtr);
117 
118  if (distance < 0.003 && angle < 5)
119  {
120  found = true;
121  }
122  }
123  EXPECT_TRUE(found);
124  }
125 
126 }
127 // Run all the tests that were declared with TEST()
128 int main(int argc, char **argv)
129 {
130  testing::InitGoogleTest(&argc, argv);
131  return RUN_ALL_TESTS();
132 }
TEST_F(PaperPredictionNormalizedTest, databaseTest)
int main(int argc, char **argv)


asr_recognizer_prediction_ism
Author(s): Aumann Florian, Heller Florian, Hutmacher Robin, Meißner Pascal, Stöckle Patrick, Stroh Daniel
autogenerated on Wed Jan 8 2020 03:18:32