fake_object_recognition.h
Go to the documentation of this file.
00001 
00018 #ifndef FAKE_OBJECT_RECOGNITION_H
00019 #define FAKE_OBJECT_RECOGNITION_H
00020 
00021 #include <ros/ros.h>
00022 #include <sensor_msgs/Image.h>
00023 #include <object_config.h>
00024 #include <asr_fake_object_recognition/GetRecognizer.h>
00025 #include <asr_fake_object_recognition/ReleaseRecognizer.h>
00026 #include <asr_fake_object_recognition/GetAllRecognizers.h>
00027 #include <asr_fake_object_recognition/ClearAllRecognizers.h>
00028 #include <tf/tf.h>
00029 #include <tf/transform_listener.h>
00030 #include <asr_msgs/AsrObject.h>
00031 #include <visualization_msgs/Marker.h>
00032 #include <dynamic_reconfigure/server.h>
00033 #include <asr_fake_object_recognition/FakeObjectRecognitionConfig.h>
00034 #include <error_simulation.h>
00035 #include <std_msgs/ColorRGBA.h>
00036 #include <geometry_msgs/Point.h>
00037 //Eigen
00038 #include <Eigen/Geometry>
00039 
00040 #include <visualization_msgs/MarkerArray.h>
00041 
00042 namespace fake_object_recognition {
00043 
00044 using namespace asr_fake_object_recognition;
00045 
00047 const static std::string NODE_NAME("asr_fake_object_recognition");
00048 
00050 const static std::string GET_RECOGNIZER_SERVICE_NAME("get_recognizer");
00051 
00053 const static std::string RELEASE_RECOGNIZER_SERVICE_NAME("release_recognizer");
00054 
00056 const static std::string GET_ALL_RECOGNIZERS_SERVICE_NAME("get_all_recognizers");
00057 
00059 const static std::string CLEAR_ALL_RECOGNIZERS_SERVICE_NAME("clear_all_recognizers");
00060 
00065 class FakeObjectRecognition {
00066 
00067 private:
00069     ros::NodeHandle nh_;
00070 
00072     dynamic_reconfigure::Server<FakeObjectRecognitionConfig> reconfigure_server_;
00073 
00075     FakeObjectRecognitionConfig config_;
00076 
00078     bool config_changed_;
00079 
00081     ros::ServiceServer get_recognizer_service_;
00082     ros::ServiceServer release_recognizer_service_;
00083 
00084     ros::ServiceServer get_all_recognizers_service_;
00085     ros::ServiceServer clear_all_recognizers_service_;
00086 
00087 
00089     ros::Publisher recognized_objects_pub_;
00090     ros::Publisher recognized_objects_marker_pub_;
00091     ros::Publisher generated_constellation_marker_pub_;
00092     ros::Publisher object_normals_pub_;
00093 
00095     ros::Timer timer_;
00096 
00098     bool recognition_released_;
00099 
00101     double fovx_;
00102     double fovy_;
00103     double ncp_;
00104     double fcp_;
00105 
00107     std::string frame_world_;
00108     std::string frame_camera_left_;
00109     std::string frame_camera_right_;
00110 
00112     std::string config_file_path_;
00113 
00115     std::string output_rec_objects_topic_;
00116     std::string output_rec_markers_topic_;
00117     std::string output_constellation_marker_topic_;
00118     std::string output_normals_topic_;
00119 
00121     double rating_threshold_d_;
00123     double rating_threshold_x_;
00125     double rating_threshold_y_;
00126 
00128     double rating_threshold_;
00129 
00131     double timer_duration_;
00132 
00134     std::vector<ObjectConfig> objects_;
00135 
00137     std::vector<std::string> objects_to_rec_;
00138 
00140     tf::TransformListener listener_;
00141 
00143     ErrorSimulation err_sim_;
00144 
00146     std::map<std::string, std::vector<geometry_msgs::Point>> normals_;
00147 
00149     std::map<std::string, std::array<geometry_msgs::Point, 8>> bounding_box_corners_;
00150 
00152     ros::ServiceClient object_metadata_service_client_;
00153 
00155     std::string bb_corners_file_name_;
00156 
00158     std::string object_database_name_;
00159 
00160 
00161 
00165     void loadObjects();
00166 
00174     bool parsePoseString(std::string pose_in, geometry_msgs::Pose &pose_out, std::string delim, std::string angles);
00175 
00182     bool processGetRecognizerRequest(GetRecognizer::Request &req, GetRecognizer::Response &res);
00183 
00190     bool processReleaseRecognizerRequest(ReleaseRecognizer::Request &req, ReleaseRecognizer::Response &res);
00191 
00198     bool processGetAllRecognizersRequest(GetAllRecognizers::Request &req, GetAllRecognizers::Response &res);
00199 
00206     bool processClearAllRecognizers(ClearAllRecognizers::Request &req, ClearAllRecognizers::Response &res);
00207 
00208 
00214     void timerCallback(const ros::TimerEvent &event);
00215 
00222     void configCallback(FakeObjectRecognitionConfig &config, uint32_t level);
00223 
00227     void doRecognition();
00228 
00236     bool objectIsVisible(const geometry_msgs::Pose &pose_left, const geometry_msgs::Pose &pose_right);
00237     
00249     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,
00250                          const std::vector<geometry_msgs::Point> &normals_left, const std::vector<geometry_msgs::Point> &normals_right);
00251 
00260     geometry_msgs::Pose transformFrame(const geometry_msgs::Pose &pose, const std::string &frame_from, const std::string &frame_to);
00261 
00270     asr_msgs::AsrObjectPtr createAsrMessage(const ObjectConfig &object_config, const geometry_msgs::Pose &pose, const std::string &frame_id);
00271 
00281     visualization_msgs::Marker createMarker(const asr_msgs::AsrObjectPtr &object, int id, int lifetime, bool use_col_init = false);
00282 
00289     static std_msgs::ColorRGBA getMeshColor(std::string observed_id);
00290 
00300     static std_msgs::ColorRGBA createColorRGBA(float red, float green, float blue, float alpha);
00301 
00309     std::vector<geometry_msgs::Point> transformPoints(std::vector<geometry_msgs::Point> points_list, Eigen::Quaterniond rotation, Eigen::Vector3d translation);
00310 
00318     std::array<geometry_msgs::Point, 8> transformPoints(std::array<geometry_msgs::Point, 8> points_list, Eigen::Quaterniond rotation, Eigen::Vector3d translation);
00319 
00327     visualization_msgs::MarkerArray::Ptr createNormalMarker(const ObjectConfig &object, int id, int lifetime);
00328 
00334     std::vector<geometry_msgs::Point> getNormals(const ObjectConfig &object);
00335 
00342      bool getBBfromFile(std::array<geometry_msgs::Point, 8> &result, std::string object_type);
00343 
00349     std::array<geometry_msgs::Point, 8> calculateBB(const ObjectConfig &object);
00350 
00358     geometry_msgs::Point createPoint(double x, double y, double z);
00359 
00360 public:
00364     FakeObjectRecognition();
00365 
00366 };
00367 
00368 }
00369 
00370 
00371 #endif /* FAKE_OBJECT_RECOGNITION_H */
00372 


asr_fake_object_recognition
Author(s): Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Meißner Pascal, Qattan Mohamad
autogenerated on Sat Jun 8 2019 19:15:45