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_head_tracking_alg_node_h_ 00026 #define _tibi_dabo_head_tracking_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "tibi_dabo_head_tracking_alg.h" 00030 00031 // [publisher subscriber headers] 00032 #include <trajectory_msgs/JointTrajectoryPoint.h> 00033 #include <sensor_msgs/JointState.h> 00034 00035 // [service client headers] 00036 00037 // [action server client headers] 00038 #include <iri_action_server/iri_action_server.h> 00039 #include <iri_nav_msgs/followTargetAction.h> 00040 #include <actionlib/client/simple_action_client.h> 00041 #include <actionlib/client/terminal_state.h> 00042 00043 #include "eventserver.h" 00044 00049 class TibiDaboHeadTrackingAlgNode : public algorithm_base::IriBaseAlgorithm<TibiDaboHeadTrackingAlgorithm> 00050 { 00051 private: 00052 // [publisher attributes] 00053 ros::Publisher joint_position_publisher_; 00054 trajectory_msgs::JointTrajectoryPoint JointTrajectoryPoint_msg_; 00055 00056 // [subscriber attributes] 00057 ros::Subscriber target_joints_subscriber_; 00058 void target_joints_callback(const trajectory_msgs::JointTrajectoryPoint::ConstPtr& msg); 00059 CMutex target_pos_mutex_; 00060 ros::Subscriber joint_feedback_subscriber_; 00061 void joint_feedback_callback(const sensor_msgs::JointState::ConstPtr& msg); 00062 CMutex joint_feedback_mutex_; 00063 00064 // [service attributes] 00065 00066 // [client attributes] 00067 00068 // [action server attributes] 00069 IriActionServer<iri_nav_msgs::followTargetAction> follow_target_aserver_; 00070 void follow_targetStartCallback(const iri_nav_msgs::followTargetGoalConstPtr& goal); 00071 void follow_targetStopCallback(void); 00072 bool follow_targetIsFinishedCallback(void); 00073 bool follow_targetHasSucceedCallback(void); 00074 void follow_targetGetResultCallback(iri_nav_msgs::followTargetResultPtr& result); 00075 void follow_targetGetFeedbackCallback(iri_nav_msgs::followTargetFeedbackPtr& feedback); 00076 00077 // [action client attributes] 00078 00079 CEventServer *event_server; 00080 std::string feedback_on_event_id; 00081 // state machine events 00082 std::string new_req_event_id_; 00083 int mode; 00084 float target_pan; 00085 float target_tilt; 00086 double pan_angle; 00087 double tilt_angle; 00088 00089 typedef enum {IDLE_STATE, FOLLOW_STATE, PREEMPT_STATE} states; 00090 states current_state_; 00091 00092 public: 00099 TibiDaboHeadTrackingAlgNode(void); 00100 00107 ~TibiDaboHeadTrackingAlgNode(void); 00108 00109 protected: 00122 void mainNodeThread(void); 00123 00136 void node_config_update(Config &config, uint32_t level); 00137 00144 void addNodeDiagnostics(void); 00145 00146 // [diagnostic functions] 00147 00148 // [test functions] 00149 }; 00150 00151 #endif