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 _voice_recognition_client_alg_node_h_ 00026 #define _voice_recognition_client_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "voice_recognition_client_alg.h" 00030 00031 // [publisher subscriber headers] 00032 //#include <std_msgs/String.h> 00033 #include <iri_perception_msgs/voiceRecognitionAnswer.h> 00034 00035 // [service client headers] 00036 00037 // [action server client headers] 00038 #include <tibi_dabo_msgs/sequenceAction.h> 00039 #include <actionlib/client/simple_action_client.h> 00040 #include <actionlib/client/terminal_state.h> 00041 #include <iri_perception_msgs/voiceRecognitionAction.h> 00042 00047 class VoiceRecognitionClientAlgNode : public algorithm_base::IriBaseAlgorithm<VoiceRecognitionClientAlgorithm> 00048 { 00049 private: 00050 // [publisher attributes] 00051 ros::Publisher code_publisher_; 00052 //std_msgs::String String_msg_; 00053 iri_perception_msgs::voiceRecognitionAnswer voiceRecognitionAnswer_msg_; 00054 00055 // [subscriber attributes] 00056 00057 // [service attributes] 00058 00059 // [client attributes] 00060 00061 // [action server attributes] 00062 00063 // [action client attributes] 00064 actionlib::SimpleActionClient<tibi_dabo_msgs::sequenceAction> hri_client_; 00065 tibi_dabo_msgs::sequenceGoal hri_goal_; 00066 void hriMakeActionRequest(); 00067 void hriDone(const actionlib::SimpleClientGoalState& state, const tibi_dabo_msgs::sequenceResultConstPtr& result); 00068 void hriActive(); 00069 void hriFeedback(const tibi_dabo_msgs::sequenceFeedbackConstPtr& feedback); 00070 00071 actionlib::SimpleActionClient<iri_perception_msgs::voiceRecognitionAction> voice_recognition_client_; 00072 iri_perception_msgs::voiceRecognitionGoal voice_recognition_goal_; 00073 void voice_recognitionMakeActionRequest(); 00074 void voice_recognitionDone(const actionlib::SimpleClientGoalState& state, const iri_perception_msgs::voiceRecognitionResultConstPtr& result); 00075 void voice_recognitionActive(); 00076 void voice_recognitionFeedback(const iri_perception_msgs::voiceRecognitionFeedbackConstPtr& feedback); 00077 00078 bool voice_recognition_action_in_progress; 00079 bool voice_recognition_done; 00080 bool hri_action_in_progress; 00081 00082 typedef enum {TTS_=0,LEDS_=1,HEAD_=2,LEFT_ARM_=3,RIGHT_ARM_=4} clients; 00083 static const int NUM_CLIENTS=RIGHT_ARM_-TTS_+1; 00084 00085 std::string answer_; 00086 int code_; 00087 int lastCode_; 00088 int lastStatus_; 00089 00090 public: 00097 VoiceRecognitionClientAlgNode(void); 00098 00105 ~VoiceRecognitionClientAlgNode(void); 00106 00107 protected: 00120 void mainNodeThread(void); 00121 00134 void node_config_update(Config &config, uint32_t level); 00135 00142 void addNodeDiagnostics(void); 00143 00144 // [diagnostic functions] 00145 00146 // [test functions] 00147 }; 00148 00149 #endif