32 ROS_INFO_STREAM(
"Pose prediction is run for scene " << pattern_name <<
" with " << percentage_of_records_for_prediction <<
" times the demonstration trajectory lengths.");
38 x.push_back(
IsmObject (pattern_name,
"MOCK"));
49 for (
IsmObject object : objects_in_pattern)
53 predecessors.push_back(
object);
58 std::pair<PathsWithScoresMap::iterator,bool>ret;
62 p.push_back(newPathWithScore);
67 "New path was not inserted");
70 .at(
object.second).size();
77 "New path was not inserted");
80 predecessors.pop_back();
83 ROS_DEBUG_STREAM(
"Object " <<
"(" <<
object.first <<
"," <<
object.second <<
")" <<
"was already found");
94 unsigned int threshold = round(percentage_of_records_for_prediction * SIZE);
98 bool has_choice_for_path = paths_with_scores.size() > 1;
99 Slots percentage_slots;
100 if (has_choice_for_path)
102 for (
unsigned int i = 0; i < threshold ; ++i)
105 if (has_choice_for_path)
107 double slot = rand() / double(RAND_MAX);
108 Slots::iterator percentage_slots_it = percentage_slots.begin();
109 PathsWithScores::iterator current_path_it = paths_with_scores.begin();
110 ROS_ASSERT(percentage_slots.size() == paths_with_scores.size());
111 while (slot > (*percentage_slots_it))
113 percentage_slots_it++;
115 ROS_ASSERT(percentage_slots_it != percentage_slots.end());
117 predecessors = current_path_it->first;
120 predecessors = paths_with_scores.begin()->first;
121 ISM::PosePtr object_pose_ptr =
predictPose(reference_pose_ptr,predecessors);
137 if (paths_with_scores.size() > 1)
140 for (PathsWithScores::iterator current_path_it = paths_with_scores.begin();
141 current_path_it != paths_with_scores.end();
143 sum += current_path_it->second;
144 double current_sum = 0.0;
145 Slots percentage_slots;
146 for (PathsWithScores::iterator current_path_it = paths_with_scores.begin();
147 current_path_it != paths_with_scores.end();
150 double score = current_path_it->second;
151 double percentage_score = score / sum;
152 current_sum += percentage_score;
153 percentage_slots.push_back(current_sum);
155 ROS_ASSERT(percentage_slots.size() == paths_with_scores.size());
156 if (percentage_slots[paths_with_scores.size() - 1] != 1.0)
157 percentage_slots[paths_with_scores.size() - 1] = 1.0;
161 ROS_DEBUG(
"No random election necessary: There is only one path");
166 double score = 1 / ( (double) path.size() );
168 "There must be more than one predecessor, otherwise all objects are in the reference");
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
void createAttributedPointCloud(ISM::PosePtr reference_pose_ptr, double percentage_of_records_for_prediction)
std::pair< IsmObjects, double > PathWithScore
ISM::PosePtr predictPose(ISM::PosePtr reference_pose_ptr, IsmObjects path_to_object)
#define ROS_ASSERT_MSG(cond,...)
AttributedPointCloud predictUnfoundPoses(ISM::PosePtr &reference_pose, std::string pattern_name, double percentage_of_records_for_prediction)
predictUnfoundPoses Processes the following steps for each object in the objectpattern set...
SizeMap specifiers_size_map_
#define ROS_DEBUG_STREAM(args)
std::pair< std::string, std::string > IsmObject
bool isReferenceObject(IsmObject object)
std::vector< PathWithScore > PathsWithScores
double calculatePathScore(IsmObjects path)
#define ROS_INFO_STREAM(args)
RandomPath(std::string database_filename)
PathsWithScoresMap paths_with_scores_map_
std::vector< IsmObject > IsmObjects
std::vector< double > Slots
void createPathsWithScoresMap(std::string type, IsmObjects predecessors)
bool isFoundObject(IsmObject object)
IsmObjectSet getObjectTypesAndIdsBelongingToPattern(std::string type)
asr_msgs::AsrAttributedPointCloud AttributedPointCloud