old_prediction_non_normalized.cpp
Go to the documentation of this file.
1 
19 #include <ISM/utility/GeometryHelper.hpp>
20 namespace pose_prediction_ism
21 {
23  PosePredictor(dbfileName,"non_normalized", PPNonNor)
24 {
25 }
27 {
28 
29 }
30 
31  AttributedPointCloud PaperPredictionNonNormalized::predictUnfoundPoses(ISM::PosePtr &referencePose, std::string patternName, double numberOfSpecifiers)
32 {
33 
34  ROS_INFO_STREAM("Pose prediction is run for scene " << patternName << ".");
35  ROS_INFO_STREAM("It is run for a reference with the pose " << referencePose << ".");
36 
38  calculateRecursiveUnfoundPoses(referencePose,patternName, 1);
40 
41 }
42 
44  std::string patternName,
45  unsigned int weight)
46 {
47  ROS_DEBUG_STREAM("" << referencePose);
48  IsmObjectSet objectsInPattern = getObjectTypesAndIdsBelongingToPattern(patternName);
49  for (IsmObject object : objectsInPattern)
50  {
51  ROS_DEBUG("Taking votes for object %s", object.first.c_str());
52  if (!isFoundObject(object))
53 
54  {
55  //ROS_DEBUG("Object %s was NOT found yet", object.first.c_str());
56  std::vector<ISM::VoteSpecifierPtr> specifiers = votes_.at(patternName).at(object.first).at(object.second);
57  ROS_DEBUG_STREAM("object: " << object.first << std::endl << "specifiers size" << specifiers.size());
58  if(isReferenceObject(object))
59  {
60  for (auto& specifier : specifiers)
61  {
62  bool skipOtherSpecifiers = referenceObjectProcessing(object.first,
63  specifier,
64  referencePose,
65  weight,
66  specifiers.size());
67 
68  if (skipOtherSpecifiers) break;
69  }
70  }
71  else
72  {
73  for (auto& specifier : specifiers)
74  {
75  bool skipOtherSpecifiers = nonReferenceObjectProcessing(object,
76  specifier,
77  referencePose,
78  weight,
79  specifiers.size());
80  if (skipOtherSpecifiers) break;
81  }
82  }
83  }
84  else
85  {
86  ROS_DEBUG("Object %s was already found, no further proceeding", object.first.c_str());
87  }
88  }
89 }
90 bool PaperPredictionNonNormalized::nonReferenceObjectProcessing(IsmObject object, ISM::VoteSpecifierPtr specifier, ISM::PosePtr &referencePose, unsigned int weight, unsigned int specifiersSize)
91 {
92  using namespace ISM;
93  PointPtr absPosition = GeometryHelper::getSourcePoint(referencePose,
94  specifier->refToObjectQuat,
95  specifier->radius);
96  PosePtr absPose = GeometryHelper::getSourcePose(referencePose,
97  absPosition,
98  specifier->refToObjectPoseQuat);
99  if(ISM::GeometryHelper::poseEqual(referencePose, absPose))
100  {
101 
102  unsigned int numberOfHypotheses = weight * specifiersSize;
103  addPointToPointCloudWithNumber(absPose, object, numberOfHypotheses);
104  return true;
105  }
106  else
107  {
108  addPointToPointCloudWithNumber(absPose, object, 1);
109  return false;
110  }
111 }
113  ISM::VoteSpecifierPtr specifier,
114  ISM::PosePtr &referencePose,
115  unsigned int weight,
116  unsigned int specifiersSize)
117 {
118  //ROS_INFO("Object %s is a reference object", objectType.c_str());
119  using namespace ISM;
120  PointPtr absPosition = GeometryHelper::getSourcePoint(referencePose,
121  specifier->refToObjectQuat,
122  specifier->radius);
123  PosePtr absPose = GeometryHelper::getSourcePose(referencePose,
124  absPosition,
125  specifier->refToObjectPoseQuat);
126  if(GeometryHelper::poseEqual(referencePose, absPose))
127  {
128  ROS_DEBUG("Object %s is identical to the reference of the ism in which it is object", objectType.c_str());
129  unsigned int numberOfHypotheses = specifiersSize * weight;
130  //ROS_DEBUG_STREAM("numberOfHypotheses: " << numberOfHypotheses << " weight: " << weight << " percentage: " << percentage);
131  calculateRecursiveUnfoundPoses(absPose, objectType, numberOfHypotheses);
132  return true;
133  }
134  else
135  {
136  //ROS_DEBUG("Object %s is NOT identical to the reference of the ism in which it is object", objectType.c_str());
137  calculateRecursiveUnfoundPoses(absPose, objectType, weight);
138  return false;
139  }
140 }
141 
142 void PaperPredictionNonNormalized::createAttributedPointCloud(ISM::PosePtr reference_pose_ptr, double percentage_of_records_for_prediction)
143 {
144 
145 }
146 void PaperPredictionNonNormalized::addPointToPointCloudWithNumber(ISM::PosePtr poseToAdd, IsmObject object, unsigned int numberOfHypotheses)
147 {
148  addPointToPointCloud(poseToAdd, object.first, object.second);
149 }
150 
151 
152 
153 }
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...
AttributedPointCloud attributed_point_cloud_
std::set< IsmObject > IsmObjectSet
bool referenceObjectProcessing(std::string objectType, ISM::VoteSpecifierPtr specifier, ISM::PosePtr &referencePose, unsigned int weight, unsigned int specifiersSize)
referenceObjectProcessing Processes a reference object. Processes the following steps.
void createAttributedPointCloud(ISM::PosePtr reference_pose_ptr, double percentage_of_records_for_prediction)
void addPointToPointCloudWithNumber(ISM::PosePtr poseToAdd, IsmObject object, unsigned int numberOfHypotheses)
AttributedPointCloud predictUnfoundPoses(ISM::PosePtr &referencePose, std::string patternName, double numberOfSpecifiers)
RecognizerPredictionISM::calcUnfoundPoses Processes the following steps for each object in the object...
#define ROS_DEBUG_STREAM(args)
std::pair< std::string, std::string > IsmObject
bool isReferenceObject(IsmObject object)
#define ROS_INFO_STREAM(args)
bool nonReferenceObjectProcessing(IsmObject object, ISM::VoteSpecifierPtr specifier, ISM::PosePtr &referencePose, unsigned int weight, unsigned int specifiersSize)
nonReferenceObjectProcessing Processes a non reference Object Processes the following steps...
void calculateRecursiveUnfoundPoses(ISM::PosePtr &referencePose, std::string patternName, unsigned int weight)
bool isFoundObject(IsmObject object)
IsmObjectSet getObjectTypesAndIdsBelongingToPattern(std::string type)
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