complete_patterns_handler.cpp
Go to the documentation of this file.
1 
19 
20 namespace world_model
21 {
22 
25  ROS_INFO_STREAM("CompletePatternsHandler initialized");
26 }
27 
28 bool CompletePatternsHandler::processPushCompletePatternsCall(asr_world_model::PushCompletePatterns::Request &request,
29  asr_world_model::PushCompletePatterns::Response &response) {
30  debug_helper_ptr_->write(std::stringstream() << "Calling processPushCompletePatternsCall", (DebugHelper::SERVICE_CALLS + DebugHelper::COMPLETE_PATTERN));
31 
32  for (const asr_world_model::CompletePattern &completePattern : request.completePatterns) {
33  CompletePatterns::iterator complete_it = completePatterns.find(completePattern.patternName);
34  if (complete_it == completePatterns.end()) {
35  completePatterns.insert(std::make_pair(completePattern.patternName, completePattern));
36  } else {
37  complete_it->second.confidence = completePattern.confidence;
38  }
39  }
40 
41  debug_helper_ptr_->write(std::stringstream() << "CompletePatterns after push:\n" << completePatterns, DebugHelper::COMPLETE_PATTERN);
42 
43  return true;
44 }
45 
46 bool CompletePatternsHandler::processEmptyCompletePatternsServiceCall(asr_world_model::EmptyCompletePatterns::Request &request,
47  asr_world_model::EmptyCompletePatterns::Response &response) {
48  debug_helper_ptr_->write(std::stringstream() << "Calling processEmptyCompletePatternsServiceCall", (DebugHelper::SERVICE_CALLS + DebugHelper::COMPLETE_PATTERN));
49 
50  completePatterns.clear();
51 
52  return true;
53 }
54 
55 bool CompletePatternsHandler::processGetCompletePatternsServiceCall(asr_world_model::GetCompletePatterns::Request &request,
56  asr_world_model::GetCompletePatterns::Response &response)
57 {
58  debug_helper_ptr_->write(std::stringstream() << "Calling processGetCompletePatternsServiceCall", (DebugHelper::SERVICE_CALLS + DebugHelper::COMPLETE_PATTERN));
59 
60  for (const std::pair<std::string, asr_world_model::CompletePattern> &completePatternPair : completePatterns) {
61  response.completePatterns.push_back(completePatternPair.second);
62  }
63 
64  debug_helper_ptr_->write(std::stringstream() << "Returning completePatternsSet:\n" << response.completePatterns, DebugHelper::COMPLETE_PATTERN);
65 
66  return true;
67 }
68 
69 
70 std::ostream& operator<<(std::ostream &strm, const CompletePatterns &complete_patterns) {
71  for (const std::pair<std::string, asr_world_model::CompletePattern> &completePatternPair : complete_patterns) {
72  strm << completePatternPair.second;
73  }
74  return strm;
75 }
76 
77 std::ostream& operator<<(std::ostream &strm, const std::vector<asr_world_model::CompletePattern> &complete_patterns) {
78  for (const asr_world_model::CompletePattern &completePattern : complete_patterns) {
79  strm << completePattern;
80  }
81  return strm;
82 }
83 
84 }
85 
bool processEmptyCompletePatternsServiceCall(asr_world_model::EmptyCompletePatterns::Request &request, asr_world_model::EmptyCompletePatterns::Response &response)
bool processGetCompletePatternsServiceCall(asr_world_model::GetCompletePatterns::Request &request, asr_world_model::GetCompletePatterns::Response &response)
CompletePatternsHandler()
Creates a new instance of the CompletePatternsHandler.
static boost::shared_ptr< DebugHelper > getInstance()
bool processPushCompletePatternsCall(asr_world_model::PushCompletePatterns::Request &request, asr_world_model::PushCompletePatterns::Response &response)
std::ostream & operator<<(std::ostream &strm, const CompletePatterns &complete_patterns)
#define ROS_INFO_STREAM(args)
std::map< std::string, asr_world_model::CompletePattern > CompletePatterns


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