common_information_handler.cpp
Go to the documentation of this file.
1 
19 
20 namespace world_model
21 {
22 
24  model_type_ptr_per_type_map_ptr_(model_type_ptr_per_type_map_ptr), settings_ptr_(settings_ptr)
25 {
27  ROS_INFO_STREAM("CommonInformationHandler initialized");
28 }
29 
30 
31 bool CommonInformationHandler::processGetRecognizerNameServiceCall(asr_world_model::GetRecognizerName::Request &request,
32  asr_world_model::GetRecognizerName::Response &response)
33 {
34  debug_helper_ptr_->write(std::stringstream() << "Calling processGetRecognizerNameServiceCall for object_type: " << request.object_type, (DebugHelper::SERVICE_CALLS + DebugHelper::COMMON_INFORMATION));
35 
36  ModelTypePtrPerTypeMap::iterator perTypeit = model_type_ptr_per_type_map_ptr_->find(request.object_type);
37  if (perTypeit == model_type_ptr_per_type_map_ptr_->end()) {
38  ROS_WARN_STREAM("No recognizer name found for this object type: " << request.object_type);
39  return false;
40  }
41 
42  response.recognizer_name = perTypeit->second->recognizerName;
43  debug_helper_ptr_->write(std::stringstream() << "Returning recognizer name: " << response.recognizer_name, DebugHelper::COMMON_INFORMATION);
44  return true;
45 }
46 
47 
48 bool CommonInformationHandler::processGetIntermediateObjectWeightServiceCall(asr_world_model::GetIntermediateObjectWeight::Request &request,
49  asr_world_model::GetIntermediateObjectWeight::Response &response)
50 {
51  debug_helper_ptr_->write(std::stringstream() << "Calling processGetIntermediateObjectWeightServiceCall for object_type: " << request.object_type, (DebugHelper::SERVICE_CALLS + DebugHelper::COMMON_INFORMATION));
52 
53  ModelTypePtrPerTypeMap::iterator perTypeit = model_type_ptr_per_type_map_ptr_->find(request.object_type);
54  if (perTypeit == model_type_ptr_per_type_map_ptr_->end()) {
55  ROS_WARN_STREAM("No weight found for this object type: " << request.object_type);
56  return false;
57  }
58 
59  response.value = perTypeit->second->weight;
60  debug_helper_ptr_->write(std::stringstream() << "Returning weight: " << response.value, DebugHelper::COMMON_INFORMATION);
61  return true;
62 }
63 
64 bool CommonInformationHandler::processGetAllObjectsListServiceCall(asr_world_model::GetAllObjectsList::Request &request,
65  asr_world_model::GetAllObjectsList::Response &response) {
66  debug_helper_ptr_->write(std::stringstream() << "Calling processGetAllObjectsListServiceCall", (DebugHelper::SERVICE_CALLS + DebugHelper::COMMON_INFORMATION));
67 
68  debug_helper_ptr_->write(std::stringstream() << "All objects: ", DebugHelper::COMMON_INFORMATION);
69 
70  for (const std::pair<std::string, ModelTypePtr> &model_type_ptr_per_type_pair: *model_type_ptr_per_type_map_ptr_) {
71  for (const std::pair<std::string, ModelObjectPtr> &model_object_ptr_per_id_pair : model_type_ptr_per_type_pair.second->model_object_ptr_per_id_map) {
72  pushTypeAndId(response.allObjects, model_type_ptr_per_type_pair.first, model_object_ptr_per_id_pair.first);
73  }
74  }
75  response.scenePath = settings_ptr_->dbfilename;
76  debug_helper_ptr_->write(std::stringstream() << response.allObjects.size() << " object(s) in scenes", DebugHelper::COMMON_INFORMATION);
77  debug_helper_ptr_->write(std::stringstream() << "Current scenePath: " << response.scenePath, DebugHelper::COMMON_INFORMATION);
78  return true;
79 }
80 
81 bool CommonInformationHandler::processGetMissingObjectListServiceCall(asr_world_model::GetMissingObjectList::Request &request, asr_world_model::GetMissingObjectList::Response &response)
82 {
83  debug_helper_ptr_->write(std::stringstream() << "Calling processGetMissingObjectListServiceCall", (DebugHelper::SERVICE_CALLS + DebugHelper::COMMON_INFORMATION));
84 
85  debug_helper_ptr_->write(std::stringstream() << "Missing objects: ", DebugHelper::COMMON_INFORMATION);
86 
87  for (const std::pair<std::string, ModelTypePtr> &model_type_ptr_per_type_pair: *model_type_ptr_per_type_map_ptr_) {
88  for (const std::pair<std::string, ModelObjectPtr> &model_object_ptr_per_id_pair : model_type_ptr_per_type_pair.second->model_object_ptr_per_id_map) {
89  if (model_object_ptr_per_id_pair.second->bestHypotheses.size() < model_object_ptr_per_id_pair.second->objectCount) {
90  pushTypeAndId(response.missingObjects, model_type_ptr_per_type_pair.first, model_object_ptr_per_id_pair.first);
91  }
92  }
93  }
94 
95  debug_helper_ptr_->write(std::stringstream() << response.missingObjects.size() << " object(s) still missing", DebugHelper::COMMON_INFORMATION);
96  return true;
97 }
98 
99 void CommonInformationHandler::pushTypeAndId(std::vector<asr_msgs::AsrTypeAndId> &typeAndIds, const std::string type, const std::string identifier) const {
100  asr_msgs::AsrTypeAndId typeAndId;
101  typeAndId.type = type;
102  typeAndId.identifier = identifier;
103  typeAndIds.push_back(typeAndId);
104  debug_helper_ptr_->write(std::stringstream() << " - " << type << ", " << identifier, DebugHelper::COMMON_INFORMATION);
105 }
106 
107 }
void pushTypeAndId(std::vector< asr_msgs::AsrTypeAndId > &typeAndIds, const std::string type, const std::string identifier) const
bool processGetRecognizerNameServiceCall(asr_world_model::GetRecognizerName::Request &request, asr_world_model::GetRecognizerName::Response &response)
get the associated recognizer name for a given object
ModelTypePtrPerTypeMapPtr model_type_ptr_per_type_map_ptr_
bool processGetAllObjectsListServiceCall(asr_world_model::GetAllObjectsList::Request &request, asr_world_model::GetAllObjectsList::Response &response)
returns all objects in the current scenes
static boost::shared_ptr< DebugHelper > getInstance()
bool processGetIntermediateObjectWeightServiceCall(asr_world_model::GetIntermediateObjectWeight::Request &request, asr_world_model::GetIntermediateObjectWeight::Response &response)
get the associated Intermediate Object Weight for a given object
#define ROS_WARN_STREAM(args)
#define ROS_INFO_STREAM(args)
CommonInformationHandler(ModelTypePtrPerTypeMapPtr model_type_ptr_per_type_map_ptr, SettingsPtr settings_ptr)
Creates a new instance of CommonInformationHandler.
bool processGetMissingObjectListServiceCall(asr_world_model::GetMissingObjectList::Request &request, asr_world_model::GetMissingObjectList::Response &response)
returns all missing objects in the current scene


asr_world_model
Author(s): Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Trautmann Jeremias
autogenerated on Thu Jan 9 2020 07:20:01