StreamTest.cpp
Go to the documentation of this file.
1 
20 #define BOOST_TEST_STATIC_LINK
21 
22 #include <boost/test/included/unit_test.hpp>
24 #include <robot_model_services/robot_model/impl/MILDRobotState.hpp>
26 #include <sstream>
27 #include <string>
28 
29 using namespace next_best_view;
30 using namespace boost::unit_test;
31 
32 class StreamTest : public BaseTest {
33 public:
34  StreamTest() : BaseTest(false, true) {}
35 
36  virtual ~StreamTest() {}
37 
38  void testString(std::string stringToTest, std::vector<std::string> occurrencesInString) {
39  for (auto occurrence : occurrencesInString) {
40  BOOST_CHECK_MESSAGE(stringToTest.find(occurrence) != std::string::npos, "attribute " + occurrence + " not found");
41  }
42  }
43 
44  void iterationTest() {
45  ObjectPoint objectPoint = ObjectPoint(SimpleVector3(1, 2, 3));
46  SamplePoint samplePoint = SamplePoint(SimpleVector3(1, 2, 3));
47  ViewportPoint viewportPoint = ViewportPoint();
48  robot_model_services::MILDRobotState mildRobotState = robot_model_services::MILDRobotState(1.0, 2.0, 3.0, 4.0, 5.0);
49  DefaultScoreContainer defaultScoreContainer = DefaultScoreContainer();
50  defaultScoreContainer.setUnweightedInverseMovementCostsBaseRotation(1.7);
51  defaultScoreContainer.setUnweightedUnnormalizedObjectUtilitiy("PlateDeep", 0.1);
52  defaultScoreContainer.setUtilityNormalization(42);
53 
54  std::stringstream objectPointSs;
55  std::stringstream samplePointSs;
56  std::stringstream viewportPointSs;
57  std::stringstream mildRobotStateSs;
58  std::stringstream defaultScoreContainerSs;
59 
60  objectPointSs << objectPoint;
61  samplePointSs << samplePoint;
62  viewportPointSs <<viewportPoint;
63  mildRobotStateSs << mildRobotState;
64  defaultScoreContainerSs << defaultScoreContainer;
65 
66  std::string objectPointStr = objectPointSs.str();
67  std::string samplePointStr = samplePointSs.str();
68  std::string viewportPointStr = viewportPointSs.str();
69  std::string mildRobotStateStr = mildRobotStateSs.str();
70  std::string defaultScoreContainerStr = defaultScoreContainerSs.str();
71 
72  std::vector<std::string> objectPointAttrs = {
73  "x: 1",
74  "w:",
75  "r:",
76  "intermediate_object_weight:"
77  };
78 
79  std::vector<std::string> samplePointAttrs = {
80  "x: 1",
81  "child_indices:"
82  };
83 
84  std::vector<std::string> viewportPointAttrs = {
85  "x: 0",
86  "w: 0",
87  "score:",
88  "object_type_set:"
89  };
90 
91  std::vector<std::string> mildRobotStateAttrs = {
92  "pan:",
93  "tilt:",
94  "x:",
95  "rotation:"
96  };
97 
98  std::vector<std::string> defaultScoreContainerAttrs = {
99  "utilityNormalization: 42",
100  "unweightedInverseMovementCostsBaseRotation: 1.7",
101  "objectUtility:",
102  "weightedInverseCosts:",
103  "objectUtility:",
104  "PlateDeep -> 0.1"
105  };
106 
107  testString(objectPointStr, objectPointAttrs);
108  testString(samplePointStr, samplePointAttrs);
109  testString(viewportPointStr, viewportPointAttrs);
110  testString(mildRobotStateStr, mildRobotStateAttrs);
111  testString(defaultScoreContainerStr, defaultScoreContainerAttrs);
112 
113  std::cout << "ObjectPoint: " << std::endl << objectPoint << std::endl;
114  std::cout << "SamplePoint: " << std::endl << samplePoint << std::endl;
115  std::cout << "ViewportPoint: " << std::endl << viewportPoint << std::endl;
116  std::cout << "MILDRobotState: " << std::endl << mildRobotState << std::endl;
117  std::cout << "DefaultScoreContainer: " << std::endl << defaultScoreContainer << std::endl;
118  }
119 };
120 
121 test_suite* init_unit_test_suite( int argc, char* argv[] ) {
122  ros::init(argc, argv, "nbv_test");
123  ros::start();
124 
125  test_suite* evaluation = BOOST_TEST_SUITE("Evaluation NBV");
126 
128 
129  evaluation->add(BOOST_CLASS_TEST_CASE(&StreamTest::iterationTest, testPtr));
130 
131  framework::master_test_suite().add(evaluation);
132 
133  return 0;
134 }
void testString(std::string stringToTest, std::vector< std::string > occurrencesInString)
Definition: StreamTest.cpp:38
void setUnweightedInverseMovementCostsBaseRotation(float value)
sets the inverse movement costs for the base rotation
ROSCPP_DECL void start()
void setUtilityNormalization(float value)
sets the utility normalization
Eigen::Matrix< Precision, 3, 1 > SimpleVector3
Definition: typedef.hpp:53
SpaceSamplePoint SamplePoint
Definition: typedef.hpp:80
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
RealObjectPoint ObjectPoint
Definition: typedef.hpp:76
void setUnweightedUnnormalizedObjectUtilitiy(std::string objectType, float value)
sets the utilitiy for an object type
this namespace contains all generally usable classes.
DefaultScoreContainer implements the BaseScoreContainer base class.
virtual ~StreamTest()
Definition: StreamTest.cpp:36
void iterationTest()
Definition: StreamTest.cpp:44
DefaultViewportPoint ViewportPoint
Definition: typedef.hpp:81
void testString()
test_suite * init_unit_test_suite(int argc, char *argv[])
Definition: StreamTest.cpp:121


asr_next_best_view
Author(s): Aumann Florian, Borella Jocelyn, Heller Florian, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Stroh Daniel, Trautmann Jeremias, Walter Milena, Wittenbeck Valerij
autogenerated on Thu Jan 9 2020 07:20:18