fake_object_recognition.h
Go to the documentation of this file.
1 
18 #ifndef FAKE_OBJECT_RECOGNITION_H
19 #define FAKE_OBJECT_RECOGNITION_H
20 
21 #include <ros/ros.h>
22 #include <sensor_msgs/Image.h>
23 #include <object_config.h>
24 #include <asr_fake_object_recognition/GetRecognizer.h>
25 #include <asr_fake_object_recognition/ReleaseRecognizer.h>
26 #include <asr_fake_object_recognition/GetAllRecognizers.h>
27 #include <asr_fake_object_recognition/ClearAllRecognizers.h>
28 #include <tf/tf.h>
29 #include <tf/transform_listener.h>
30 #include <asr_msgs/AsrObject.h>
31 #include <visualization_msgs/Marker.h>
32 #include <dynamic_reconfigure/server.h>
33 #include <asr_fake_object_recognition/FakeObjectRecognitionConfig.h>
34 #include <error_simulation.h>
35 #include <std_msgs/ColorRGBA.h>
36 #include <geometry_msgs/Point.h>
37 //Eigen
38 #include <Eigen/Geometry>
39 
40 #include <visualization_msgs/MarkerArray.h>
41 
42 namespace fake_object_recognition {
43 
44 using namespace asr_fake_object_recognition;
45 
47 const static std::string NODE_NAME("asr_fake_object_recognition");
48 
50 const static std::string GET_RECOGNIZER_SERVICE_NAME("get_recognizer");
51 
53 const static std::string RELEASE_RECOGNIZER_SERVICE_NAME("release_recognizer");
54 
56 const static std::string GET_ALL_RECOGNIZERS_SERVICE_NAME("get_all_recognizers");
57 
59 const static std::string CLEAR_ALL_RECOGNIZERS_SERVICE_NAME("clear_all_recognizers");
60 
66 
67 private:
70 
72  dynamic_reconfigure::Server<FakeObjectRecognitionConfig> reconfigure_server_;
73 
75  FakeObjectRecognitionConfig config_;
76 
79 
83 
86 
87 
93 
96 
99 
101  double fovx_;
102  double fovy_;
103  double ncp_;
104  double fcp_;
105 
107  std::string frame_world_;
108  std::string frame_camera_left_;
109  std::string frame_camera_right_;
110 
112  std::string config_file_path_;
113 
119 
126 
129 
132 
134  std::vector<ObjectConfig> objects_;
135 
137  std::vector<std::string> objects_to_rec_;
138 
141 
144 
146  std::map<std::string, std::vector<geometry_msgs::Point>> normals_;
147 
149  std::map<std::string, std::array<geometry_msgs::Point, 8>> bounding_box_corners_;
150 
153 
156 
159 
160 
161 
165  void loadObjects();
166 
174  bool parsePoseString(std::string pose_in, geometry_msgs::Pose &pose_out, std::string delim, std::string angles);
175 
182  bool processGetRecognizerRequest(GetRecognizer::Request &req, GetRecognizer::Response &res);
183 
190  bool processReleaseRecognizerRequest(ReleaseRecognizer::Request &req, ReleaseRecognizer::Response &res);
191 
198  bool processGetAllRecognizersRequest(GetAllRecognizers::Request &req, GetAllRecognizers::Response &res);
199 
206  bool processClearAllRecognizers(ClearAllRecognizers::Request &req, ClearAllRecognizers::Response &res);
207 
208 
214  void timerCallback(const ros::TimerEvent &event);
215 
222  void configCallback(FakeObjectRecognitionConfig &config, uint32_t level);
223 
227  void doRecognition();
228 
236  bool objectIsVisible(const geometry_msgs::Pose &pose_left, const geometry_msgs::Pose &pose_right);
237 
249  bool objectIsVisible(const std::array<geometry_msgs::Point, 8> &bb_left, const std::array<geometry_msgs::Point, 8> &bb_right, const geometry_msgs::Pose &pose_left, const geometry_msgs::Pose &pose_right,
250  const std::vector<geometry_msgs::Point> &normals_left, const std::vector<geometry_msgs::Point> &normals_right);
251 
260  geometry_msgs::Pose transformFrame(const geometry_msgs::Pose &pose, const std::string &frame_from, const std::string &frame_to);
261 
270  asr_msgs::AsrObjectPtr createAsrMessage(const ObjectConfig &object_config, const geometry_msgs::Pose &pose, const std::string &frame_id);
271 
281  visualization_msgs::Marker createMarker(const asr_msgs::AsrObjectPtr &object, int id, int lifetime, bool use_col_init = false);
282 
289  static std_msgs::ColorRGBA getMeshColor(std::string observed_id);
290 
300  static std_msgs::ColorRGBA createColorRGBA(float red, float green, float blue, float alpha);
301 
309  std::vector<geometry_msgs::Point> transformPoints(std::vector<geometry_msgs::Point> points_list, Eigen::Quaterniond rotation, Eigen::Vector3d translation);
310 
318  std::array<geometry_msgs::Point, 8> transformPoints(std::array<geometry_msgs::Point, 8> points_list, Eigen::Quaterniond rotation, Eigen::Vector3d translation);
319 
327  visualization_msgs::MarkerArray::Ptr createNormalMarker(const ObjectConfig &object, int id, int lifetime);
328 
334  std::vector<geometry_msgs::Point> getNormals(const ObjectConfig &object);
335 
342  bool getBBfromFile(std::array<geometry_msgs::Point, 8> &result, std::string object_type);
343 
349  std::array<geometry_msgs::Point, 8> calculateBB(const ObjectConfig &object);
350 
358  geometry_msgs::Point createPoint(double x, double y, double z);
359 
360 public:
365 
366 };
367 
368 }
369 
370 
371 #endif /* FAKE_OBJECT_RECOGNITION_H */
372 
static const std::string GET_ALL_RECOGNIZERS_SERVICE_NAME("get_all_recognizers")
This class is used to simulate typical errors of an object recognition system.
std::map< std::string, std::vector< geometry_msgs::Point > > normals_
std::map< std::string, std::array< geometry_msgs::Point, 8 > > bounding_box_corners_
static const std::string CLEAR_ALL_RECOGNIZERS_SERVICE_NAME("clear_all_recognizers")
static const std::string RELEASE_RECOGNIZER_SERVICE_NAME("release_recognizer")
dynamic_reconfigure::Server< FakeObjectRecognitionConfig > reconfigure_server_
static const std::string GET_RECOGNIZER_SERVICE_NAME("get_recognizer")
This class is used to save information about an available object.
Definition: object_config.h:32
static const std::string NODE_NAME("asr_fake_object_recognition")
The central class of the recognition system used for managing the ros subscriptions, configuration changes, loading of the objects, the recognition itself and the visualisation of the results.


asr_fake_object_recognition
Author(s): Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Meißner Pascal, Qattan Mohamad
autogenerated on Wed Feb 19 2020 03:58:59