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_hri_teleop_alg_node_h_ 00026 #define _tibi_dabo_hri_teleop_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "tibi_dabo_hri_teleop_alg.h" 00030 00031 // [publisher subscriber headers] 00032 #include <sensor_msgs/Joy.h> 00033 00034 // [service client headers] 00035 #include <actionlib/client/simple_action_client.h> 00036 #include <actionlib/client/terminal_state.h> 00037 #include <tibi_dabo_msgs/sequenceAction.h> 00038 00039 // [action server client headers] 00040 00041 #include "mutex.h" 00042 00047 class TibiDaboHriTeleopAlgNode : public algorithm_base::IriBaseAlgorithm<TibiDaboHriTeleopAlgorithm> 00048 { 00049 private: 00050 // [publisher attributes] 00051 00052 // [subscriber attributes] 00053 ros::Subscriber joy_subscriber_; 00054 void joy_callback(const sensor_msgs::Joy::ConstPtr& msg); 00055 CMutex joy_mutex_; 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(std::vector<std::string> &xml_files); 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 CMutex hri_access; 00072 std::string sequence_file; 00073 bool hri_action_in_progress_; 00074 typedef enum {TTS_=0,LEDS_=1,HEAD_=2,LEFT_ARM_=3,RIGHT_ARM_=4} clients; 00075 static const int NUM_CLIENTS=RIGHT_ARM_-TTS_+1; 00076 00077 int index_; 00078 00079 std::vector<int> prev_buttons_; 00080 std::vector<std::string> xml_files; 00081 std::vector<std::string> button_files_; 00082 00083 public: 00090 TibiDaboHriTeleopAlgNode(void); 00091 00098 ~TibiDaboHriTeleopAlgNode(void); 00099 00100 protected: 00113 void mainNodeThread(void); 00114 00127 void node_config_update(Config &config, uint32_t level); 00128 00135 void addNodeDiagnostics(void); 00136 00137 // [diagnostic functions] 00138 00139 // [test functions] 00140 00141 //int useExtraButton(const unsigned int & index); 00142 int indexFromButtons(const std::vector<int> & buttons); 00143 }; 00144 00145 #endif