AbsoluteTestSetGenerator.cpp
Go to the documentation of this file.
1 
19 
21 
23  TestSetGenerator(pEvaluator, pFullyMeshedTopology, pObjectTypes)
24 { }
25 
27 { }
28 
29 std::vector<boost::shared_ptr<TestSet>> AbsoluteTestSetGenerator::generateRandomSets(std::vector<boost::shared_ptr<ISM::ObjectSet>> pExamplesList, unsigned int pTestSetCount)
30 {
31  TestSetGenerator::mPrintHelper.printAsHeader("Generating " + boost::lexical_cast<std::string>(pTestSetCount) + " random test sets.");
32 
33  std::random_device rd;
34  boost::mt19937 eng; // Mersenne Twister
35  eng.seed(rd());
36  boost::uniform_int<> dist(0,RAND_MAX); // Normal Distribution
37  boost::variate_generator<boost::mt19937,boost::uniform_int<>> gen(eng,dist); // Variate generator
38 
39  ROS_INFO_STREAM("Found " << TestSetGenerator::mTypes.size() << " object types.");
40 
41  std::vector<boost::shared_ptr<TestSet>> testSets(pTestSetCount);
42 
43  for (unsigned int i = 0; i < pTestSetCount; i++)
44  {
45  testSets[i].reset(new TestSet());
46  for (std::string objectType: mTypes)
47  {
48  ISM::ObjectPtr object;
49 
50  unsigned int counter = 0;
51  while (!object && counter < pExamplesList.size()) // does not iterate over all timesteps; using example list size to scale
52  {
53  unsigned int newRandomTimestep = gen() % pExamplesList.size();
54  for (ISM::ObjectPtr currentObject: pExamplesList[newRandomTimestep]->objects)
55  {
56  if (currentObject->type == objectType)
57  {
58  object = ISM::ObjectPtr(new ISM::Object(*currentObject)); // deep copy the object.
59  break;
60  }
61  }
62  counter++;
63  }
64 
65  if (!object)
66  throw std::runtime_error("In TestSetGenerator::generateTestSets(): Failed to find object of type " + objectType + " in evidence list.");
67 
68  testSets[i]->mObjectSet->insert(object);
69  }
70  }
71 
72  return testSets;
73 }
74 
75 }
76 
#define ROS_INFO_STREAM(args)
virtual std::vector< boost::shared_ptr< TestSet > > generateRandomSets(std::vector< boost::shared_ptr< ISM::ObjectSet >> pExamplesList, unsigned int pTestSetCount)
std::vector< std::string > testSets
AbsoluteTestSetGenerator(boost::shared_ptr< AbstractTopologyEvaluator > pEvaluator, boost::shared_ptr< SceneModel::Topology > pFullyMeshedTopology, const std::vector< std::string > &pObjectTypes)


asr_psm
Author(s): Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meißner Pascal
autogenerated on Fri Nov 15 2019 03:57:54