scene_recognition.h
Go to the documentation of this file.
1 
18 #ifndef RECOGNIZER_PREDICTION_ISM_SCENE_RECOGNITION_NODE_H
19 #define RECOGNIZER_PREDICTION_ISM_SCENE_RECOGNITION_NODE_H
20 
21 #include <iostream>
22 #include <fstream>
23 #include <cmath>
24 
25 #include <ISM/recognizer/Recognizer.hpp>
26 #include <ISM/utility/TableHelper.hpp>
27 #include <ISM/common_type/ObjectSet.hpp>
28 
29 /* ----------------- Foreign messages/services ------------------ */
30 #include <std_srvs/Empty.h>
31 
32 #include <asr_ism_visualizations/ObjectModelVisualizerRVIZ.hpp>
33 #include <asr_ism_visualizations/ism_result_visualizer_rviz.hpp>
34 #include <dynamic_reconfigure/server.h>
35 #include <asr_recognizer_prediction_ism/rp_ism_nodeConfig.h>
36 
37 /* ----------------- Package messages/services ------------------ */
38 #include <asr_world_model/CompletePattern.h>
39 #include <asr_world_model/VisualizeSampledPoses.h>
40 #include <asr_world_model/PushCompletePatterns.h>
41 
42 
43 #include "asr_recognizer_prediction_ism/FindScenes.h"
44 #include "asr_recognizer_prediction_ism/SetLogDir.h"
45 #include "asr_recognizer_prediction_ism/ToggleVisualization.h"
46 
47 /* ----------------- Local includes ------------------ */
49 #include "ism_helper.h"
50 
52 {
54  {
55  /* ----------------- ROS ------------------ */
61 
64 
65  /* ----------------- ISM ------------------ */
66  ISM::RecognizerPtr recognizer_;
67  ISM::TableHelperPtr table_helper_;
68  double bin_size_;
70  std::string database_filename_;
71  unsigned int rater_type_;
72 
75 
76  unsigned int object_set_max_count_;
77 
79 
80  //Settings for handling of rotation invariant objects
82  std::string rotation_frame_;
83  std::string rotation_object_type_;
84  std::string rotation_object_id_;
85 
86  //Size of last object set, on which find_scenes() has been performed.
87  unsigned int last_object_set_size_;
88  //Buffer shared with pose prediction.
89  std::vector<ISM::RecognitionResultPtr>& results_already_shared_;
90 
91  //Mapping from patterns to objects from loaded sqlite file.
93 
94  std::map<std::string, std::set<std::pair<std::string, std::string> > > pattern_object_map_;
95  std::set<std::string> unique_pattern_names_;
96 
97  /* ----------------- Visualization ------------------ */
101 
103  double step_;
104  std::string base_frame_;
106  VIZ::ISMResultVisualizerRVIZPtr res_visualizer_;
107  VIZ::ObjectModelVisualizerRVIZ* object_model_visualizer_;
111 
112  std::vector<ISM::RecognitionResultPtr> incomplete_recognition_results_;
113  std::vector<ISM::RecognitionResultPtr> results_for_visualization_;
114  std::set<std::pair<std::string, std::string> > object_types_and_ids_set_;
115 
116  /* ----------------- Help functions ------------------ */
117  std::vector<ISM::ObjectPtr> extractRealObjects(ISM::RecognitionResultPtr result_ptr);
118 
119  static bool compareConfidence(ISM::RecognitionResultPtr i,ISM::RecognitionResultPtr j);
120  static bool isCompleteSubset(std::set<std::pair<std::string, std::string> > set_a,
121  std::set<std::pair<std::string, std::string> > set_b);
122 
123  public:
124 
128  //TODO: Comment.
129  SceneRecognition(std::vector<ISM::RecognitionResultPtr>& results_already_shared, SharedRecognitionResultsManagerPtr shared_recognition_results_ptr);
130 
132 
139  bool processFindScenesServiceCall(asr_recognizer_prediction_ism::FindScenes::Request &request, asr_recognizer_prediction_ism::FindScenes::Response &response);
140 
147  bool setLogFilePathServiceCall(asr_recognizer_prediction_ism::SetLogDir::Request &request, asr_recognizer_prediction_ism::SetLogDir::Response &response);
148 
155  bool processToggleVisualizationServiceCall(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response);
156 
163  bool processResetServiceCall(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response);
164 
165  private:
166  void createObjectSetsFromPoseSamples(std::vector<asr_msgs::AsrObject>::iterator object_it, std::vector<asr_msgs::AsrObject>::iterator end_it,
167  ISM::ObjectSetPtr temp_set_ptr, std::vector<ISM::ObjectSetPtr>& object_sets, bool measured_value_only);
168  void writeObjectConstellationToXML(std::vector<ISM::ObjectPtr> &objects, int sceneRecogCount, int constellation_count);
169 
170  void filterIncompleteRR(std::vector<ISM::RecognitionResultPtr> &recognition_results);
171  void sortBestRRperScene(std::stringstream& output);
172  void deleteAllNewRR();
173 
174  };
175 
177 
178 }
179 #endif
std::vector< ISM::RecognitionResultPtr > & results_already_shared_
std::set< std::pair< std::string, std::string > > object_types_and_ids_set_
SceneRecognition(std::vector< ISM::RecognitionResultPtr > &results_already_shared, SharedRecognitionResultsManagerPtr shared_recognition_results_ptr)
SceneRecognitionNode Constructor.
std::vector< ISM::ObjectPtr > extractRealObjects(ISM::RecognitionResultPtr result_ptr)
bool processFindScenesServiceCall(asr_recognizer_prediction_ism::FindScenes::Request &request, asr_recognizer_prediction_ism::FindScenes::Response &response)
processFindScenesServiceCall Receives service call with detected AsrObjects.
std::vector< ISM::RecognitionResultPtr > results_for_visualization_
SharedRecognitionResultsManagerPtr shared_recognition_results_ptr_
void sortBestRRperScene(std::stringstream &output)
std::vector< ISM::RecognitionResultPtr > incomplete_recognition_results_
static bool isCompleteSubset(std::set< std::pair< std::string, std::string > > set_a, std::set< std::pair< std::string, std::string > > set_b)
std::map< std::string, std::set< std::pair< std::string, std::string > > > pattern_object_map_
bool setLogFilePathServiceCall(asr_recognizer_prediction_ism::SetLogDir::Request &request, asr_recognizer_prediction_ism::SetLogDir::Response &response)
processSetLogDirServiceCall Receives service call where to write object constellations, used for scene recognition.
boost::shared_ptr< SceneRecognition > SceneRecognitionPtr
void filterIncompleteRR(std::vector< ISM::RecognitionResultPtr > &recognition_results)
void writeObjectConstellationToXML(std::vector< ISM::ObjectPtr > &objects, int sceneRecogCount, int constellation_count)
bool processResetServiceCall(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response)
processResetServiceCall Clears the old recognition results.
void createObjectSetsFromPoseSamples(std::vector< asr_msgs::AsrObject >::iterator object_it, std::vector< asr_msgs::AsrObject >::iterator end_it, ISM::ObjectSetPtr temp_set_ptr, std::vector< ISM::ObjectSetPtr > &object_sets, bool measured_value_only)
VIZ::ObjectModelVisualizerRVIZ * object_model_visualizer_
static bool compareConfidence(ISM::RecognitionResultPtr i, ISM::RecognitionResultPtr j)
bool processToggleVisualizationServiceCall(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response)
processToggleVisualizationServiceCall Toggle the visualization via service call.
VIZ::ISMResultVisualizerRVIZPtr res_visualizer_


asr_recognizer_prediction_ism
Author(s): Aumann Florian, Heller Florian, Hutmacher Robin, Meißner Pascal, Stöckle Patrick, Stroh Daniel
autogenerated on Wed Jan 8 2020 03:18:32