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 _tibi_dabo_questions_alg_node_h_ 00026 #define _tibi_dabo_questions_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "tibi_dabo_questions_alg.h" 00030 00031 // [publisher subscriber headers] 00032 00033 // [service client headers] 00034 00035 // [action server client headers] 00036 #include <iri_perception_msgs/voiceRecognitionAction.h> 00037 #include <actionlib/client/simple_action_client.h> 00038 #include <actionlib/client/terminal_state.h> 00039 #include <tibi_dabo_msgs/sequenceAction.h> 00040 00045 class TibiDaboQuestionsAlgNode : public algorithm_base::IriBaseAlgorithm<TibiDaboQuestionsAlgorithm> 00046 { 00047 private: 00048 // [publisher attributes] 00049 00050 // [subscriber attributes] 00051 00052 // [service attributes] 00053 00054 // [client attributes] 00055 00056 // [action server attributes] 00057 00058 // [action client attributes] 00059 actionlib::SimpleActionClient<iri_perception_msgs::voiceRecognitionAction> voice_recognition_client_; 00060 iri_perception_msgs::voiceRecognitionGoal voice_recognition_goal_; 00061 void voice_recognitionMakeActionRequest(); 00062 void voice_recognitionDone(const actionlib::SimpleClientGoalState& state, const iri_perception_msgs::voiceRecognitionResultConstPtr& result); 00063 void voice_recognitionActive(); 00064 void voice_recognitionFeedback(const iri_perception_msgs::voiceRecognitionFeedbackConstPtr& feedback); 00065 00066 actionlib::SimpleActionClient<tibi_dabo_msgs::sequenceAction> hri_client_; 00067 tibi_dabo_msgs::sequenceGoal hri_goal_; 00068 void hriMakeActionRequest(); 00069 void hriDone(const actionlib::SimpleClientGoalState& state, const tibi_dabo_msgs::sequenceResultConstPtr& result); 00070 void hriActive(); 00071 void hriFeedback(const tibi_dabo_msgs::sequenceFeedbackConstPtr& feedback); 00072 00073 std::string answer_; 00074 int status_; 00075 int lastStatus_; 00076 bool questionsOn_; 00077 bool hriOn_; 00078 bool infoOn_; 00079 bool hri_active_; 00080 bool questions_active_; 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 public: 00092 TibiDaboQuestionsAlgNode(void); 00093 00100 ~TibiDaboQuestionsAlgNode(void); 00101 00102 protected: 00115 void mainNodeThread(void); 00116 00129 void node_config_update(Config &config, uint32_t level); 00130 00137 void addNodeDiagnostics(void); 00138 00139 // [diagnostic functions] 00140 00141 // [test functions] 00142 }; 00143 00144 #endif