00001 // Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC. 00002 // Author 00003 // All rights reserved. 00004 // 00005 // This file is part of iri-ros-pkg 00006 // iri-ros-pkg is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation, either version 3 of the License, or 00009 // at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 // 00019 // IMPORTANT NOTE: This code has been generated through a script from the 00020 // iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness 00021 // of the scripts. ROS topics can be easly add by using those scripts. Please 00022 // refer to the IRI wiki page for more information: 00023 // http://wikiri.upc.es/index.php/Robotics_Lab 00024 00025 #ifndef _human_assisted_object_detection_alg_node_h_ 00026 #define _human_assisted_object_detection_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "human_assisted_object_detection_alg.h" 00030 #include <image_transport/image_transport.h> 00031 00032 // [publisher subscriber headers] 00033 #include <face_detector_mono/RectArray.h> 00034 #include <sensor_msgs/Image.h> 00035 00036 // [service client headers] 00037 #include <iri_human_assisted_object_detection/haod_learn.h> 00038 #include <iri_human_assisted_object_detection/haod_detect.h> 00039 #include <iri_human_assisted_object_detection/haod_init.h> 00040 00041 // [action server client headers] 00042 00043 typedef enum {idle,init,detect,learn} detection_states; 00044 00049 class HumanAssistedObjectDetectionAlgNode : public algorithm_base::IriBaseAlgorithm<HumanAssistedObjectDetectionAlgorithm> 00050 { 00051 private: 00052 // [publisher attributes] 00053 image_transport::ImageTransport it_; 00054 image_transport::Publisher output_image_publisher_; 00055 sensor_msgs::ImagePtr Image_msg_; 00056 00057 // [subscriber attributes] 00058 ros::Subscriber face_detect_subscriber_; 00059 void face_detect_callback(const face_detector_mono::RectArray::ConstPtr& msg); 00060 CMutex face_detect_mutex_; 00061 image_transport::Subscriber input_image_subscriber_; 00062 void input_image_callback(const sensor_msgs::Image::ConstPtr& msg); 00063 CMutex input_image_mutex_; 00064 00065 // [service attributes] 00066 ros::ServiceServer learn_server_; 00067 bool learnCallback(iri_human_assisted_object_detection::haod_learn::Request &req, iri_human_assisted_object_detection::haod_learn::Response &res); 00068 CMutex learn_mutex_; 00069 ros::ServiceServer detect_server_; 00070 bool detectCallback(iri_human_assisted_object_detection::haod_detect::Request &req, iri_human_assisted_object_detection::haod_detect::Response &res); 00071 CMutex detect_mutex_; 00072 ros::ServiceServer init_server_; 00073 bool initCallback(iri_human_assisted_object_detection::haod_init::Request &req, iri_human_assisted_object_detection::haod_init::Response &res); 00074 CMutex init_mutex_; 00075 00076 // [client attributes] 00077 00078 // [action server attributes] 00079 00080 // [action client attributes] 00081 00082 face_detector_mono::RectArray face_rects; 00083 bool receiving_detections; 00084 00085 sensor_msgs::ImageConstPtr input_image; 00086 bool receiving_images; 00087 00088 cv::Rect rect; 00089 public: 00096 HumanAssistedObjectDetectionAlgNode(void); 00097 00104 ~HumanAssistedObjectDetectionAlgNode(void); 00105 00106 protected: 00119 void mainNodeThread(void); 00120 00133 void node_config_update(Config &config, uint32_t level); 00134 00141 void addNodeDiagnostics(void); 00142 00143 // [diagnostic functions] 00144 00145 // [test functions] 00146 }; 00147 00148 #endif