old_prediction_normalized.cpp
Go to the documentation of this file.
1 
19 #include <ISM/utility/GeometryHelper.hpp>
20 namespace pose_prediction_ism
21 {
23  PosePredictor::PosePredictor(dbfileName, "normalized", PPNor)
24 {
25 }
26 
28 {
29 
30 }
31 void PaperPredictionNormalized::nonReferenceObjectProcessing(IsmObject object, ISM::VoteSpecifierPtr specifier, ISM::PosePtr &referencePose, unsigned int weight)
32 {
33  using namespace ISM;
34  PointPtr absPosition = GeometryHelper::getSourcePoint(referencePose,
35  specifier->refToObjectQuat,
36  specifier->radius);
37  PosePtr absPose = GeometryHelper::getSourcePose(referencePose,
38  absPosition,
39  specifier->refToObjectPoseQuat);
40  for(unsigned int i = 0; i < weight; i++)
41  objectPoseMap[object].push_back(absPose);
42 }
43 
45  std::string patternName, double numberOfSpecifiers)
46 {
47  objectPoseMap.clear();
49  calculateRecursiveUnfoundPoses(referencePose,patternName,1,0);
51  ROS_ASSERT(!objectPoseMap.empty());
52  ROS_ASSERT(!objectSizeMap.empty());
53  createAttributedPointCloudFromMap(numberOfSpecifiers);
55 }
56 
58  ISM::VoteSpecifierPtr specifier,
59  ISM::PosePtr &referencePose,
60  unsigned int weight,
61  unsigned int specifiersSize,
62  unsigned int level)
63 {
64  //ROS_INFO("Object %s is a reference object", objectType.c_str());
65  using namespace ISM;
66  PointPtr absPosition = GeometryHelper::getSourcePoint(referencePose,
67  specifier->refToObjectQuat,
68  specifier->radius);
69  PosePtr absPose = GeometryHelper::getSourcePose(referencePose,
70  absPosition,
71  specifier->refToObjectPoseQuat);
72  unsigned int nextLevel = level + 1;
73  if(GeometryHelper::poseEqual(referencePose, absPose))
74  {
75  ROS_DEBUG("Object %s is identical to the reference of the ism in which it is object", objectType.c_str());
76  unsigned int numberOfHypotheses = specifiersSize * weight;
77  //ROS_DEBUG_STREAM("numberOfHypotheses: " << numberOfHypotheses << " weight: " << weight << " percentage: " << percentage);
78  calculateRecursiveUnfoundPoses(absPose, objectType, numberOfHypotheses, nextLevel);
79  return true;
80  }
81  else
82  {
83  //ROS_DEBUG("Object %s is NOT identical to the reference of the ism in which it is object", objectType.c_str());
84  calculateRecursiveUnfoundPoses(absPose, objectType, weight, nextLevel);
85  return false;
86  }
87 }
88 
89 
91 {
92  ROS_DEBUG_STREAM("objectMap contains:" << std::endl);
93  for (std::map<IsmObject , std::vector<ISM::PosePtr>>::iterator it=objectPoseMap.begin(); it!=objectPoseMap.end(); ++it)
94  {
95  IsmObject object = it->first;
96  unsigned int posesSize = it->second.size();
97  unsigned int specifiersSize = objectSizeMap[object];
98  unsigned int threshold = round(numberOfSpecifiers * specifiersSize);
99  for (unsigned int i = 0; i < threshold; ++i)
100  {
101  unsigned int index = rand() % posesSize;
102  addPointToPointCloud(it->second.at(index), object.first, object.second);
103  }
104  it->second.clear();
105  }
106  objectPoseMap.clear();
107  objectSizeMap.clear();
108 }
109 
110 void PaperPredictionNormalized::createAttributedPointCloud(ISM::PosePtr reference_pose_ptr, double percentage_of_records_for_prediction)
111 {
112 }
113 
114 
116  std::string patternName,
117  unsigned int weight,
118  unsigned int level)
119 {
120  IsmObjectSet objectsInPattern = getObjectTypesAndIdsBelongingToPattern(patternName);
121  for (IsmObject object : objectsInPattern)
122  {
123  std::vector<ISM::VoteSpecifierPtr> specifiers = votes_.at(patternName).at(object.first).at(object.second);
124  if(isReferenceObject(object))
125  {
126  for (unsigned int i = 0; i < specifiers.size(); i++)
127  {
128  bool skipOtherSpecifiers = referenceObjectProcessing(object.first,
129  specifiers.at(i),
130  referencePose,
131  weight,
132  specifiers.size(),
133  level);
134  if (skipOtherSpecifiers){
135  ROS_DEBUG_STREAM("Skipping further votes for object " << "(" << object.first << "," << object.second << ")" << ".");
136  break;
137  }
138 
139  }
140  }
141  else
142  {
143  objectSizeMap[object] = specifiers.size();
144  for (unsigned int i = 0; i < specifiers.size(); i++)
146  specifiers.at(i),
147  referencePose, weight);
148  }
149  }
150 }
151 }
ISM::PatternToObjectToVoteMap votes_
void addPointToPointCloud(ISM::PosePtr pose_to_add, std::string type, std::string identifier)
RecognizerPredictionISM::addPointToPointCloud Adds an ISM Pose with object type and identifier as att...
bool referenceObjectProcessing(std::string objectType, ISM::VoteSpecifierPtr specifier, ISM::PosePtr &referencePose, unsigned int weight, unsigned int specifiersSize, unsigned int level)
referenceObjectProcessing Processes a reference object. Processes the following steps.
AttributedPointCloud attributed_point_cloud_
std::set< IsmObject > IsmObjectSet
void createAttributedPointCloud(ISM::PosePtr reference_pose_ptr, double percentage_of_records_for_prediction)
#define ROS_DEBUG_STREAM(args)
std::pair< std::string, std::string > IsmObject
void calculateRecursiveUnfoundPoses(ISM::PosePtr &referencePose, std::string patternName, unsigned int weight, unsigned int level)
bool isReferenceObject(IsmObject object)
void createAttributedPointCloudFromMap(double numberOfSpecifiers)
#define ROS_ASSERT(cond)
std::map< IsmObject, std::vector< ISM::PosePtr > > objectPoseMap
AttributedPointCloud predictUnfoundPoses(ISM::PosePtr &referencePose, std::string patternName, double percentage_of_records_for_prediction)
RecognizerPredictionISM::calcUnfoundPoses Processes the following steps for each object in the object...
IsmObjectSet getObjectTypesAndIdsBelongingToPattern(std::string type)
void nonReferenceObjectProcessing(IsmObject object, ISM::VoteSpecifierPtr specifier, ISM::PosePtr &referencePose, unsigned int weight)
asr_msgs::AsrAttributedPointCloud AttributedPointCloud
Definition: typedef.h:37
#define ROS_DEBUG(...)


asr_lib_pose_prediction_ism
Author(s): Heizmann Heinrich, Heller Florian, Meißner Pascal, Stöckle Patrick
autogenerated on Thu Jan 9 2020 07:19:56