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 _darwin_arm_simple_nav_alg_node_h_ 00026 #define _darwin_arm_simple_nav_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "darwin_arm_simple_nav_alg.h" 00030 #include <tf/transform_listener.h> 00031 00032 // [publisher subscriber headers] 00033 #include <sensor_msgs/JointState.h> 00034 00035 // [service client headers] 00036 #include <kinematics_msgs/GetKinematicSolverInfo.h> 00037 #include <kinematics_msgs/GetPositionIK.h> 00038 00039 // [action server client headers] 00040 #include <actionlib/client/simple_action_client.h> 00041 #include <actionlib/client/terminal_state.h> 00042 #include <control_msgs/FollowJointTrajectoryAction.h> 00043 #include <iri_action_server/iri_action_server.h> 00044 #include <arm_navigation_msgs/MoveArmAction.h> 00045 00050 class DarwinArmSimpleNavAlgNode : public algorithm_base::IriBaseAlgorithm<DarwinArmSimpleNavAlgorithm> 00051 { 00052 private: 00053 // [publisher attributes] 00054 00055 // [subscriber attributes] 00056 ros::Subscriber joint_state_subscriber_; 00057 void joint_state_callback(const sensor_msgs::JointState::ConstPtr& msg); 00058 CMutex joint_state_mutex_; 00059 sensor_msgs::JointState current_state; 00060 00061 // [service attributes] 00062 00063 // [client attributes] 00064 ros::ServiceClient ik_info_client_; 00065 kinematics_msgs::GetKinematicSolverInfo ik_info_srv_; 00066 ros::ServiceClient get_ik_client_; 00067 kinematics_msgs::GetPositionIK get_ik_srv_; 00068 00069 // [action server attributes] 00070 IriActionServer<arm_navigation_msgs::MoveArmAction> move_arm_aserver_; 00071 void move_armStartCallback(const arm_navigation_msgs::MoveArmGoalConstPtr& goal); 00072 void move_armStopCallback(void); 00073 bool move_armIsFinishedCallback(void); 00074 bool move_armHasSucceedCallback(void); 00075 void move_armGetResultCallback(arm_navigation_msgs::MoveArmResultPtr& result); 00076 void move_armGetFeedbackCallback(arm_navigation_msgs::MoveArmFeedbackPtr& feedback); 00077 00078 // [action client attributes] 00079 actionlib::SimpleActionClient<control_msgs::FollowJointTrajectoryAction> move_joints_client_; 00080 control_msgs::FollowJointTrajectoryGoal move_joints_goal_; 00081 void move_jointsMakeActionRequest(); 00082 void move_jointsDone(const actionlib::SimpleClientGoalState& state, const control_msgs::FollowJointTrajectoryResultConstPtr& result); 00083 void move_jointsActive(); 00084 void move_jointsFeedback(const control_msgs::FollowJointTrajectoryFeedbackConstPtr& feedback); 00085 00086 bool robot_running; 00087 bool joints_moving; 00088 tf::TransformListener tf_listener; 00089 std::string arm_id; 00090 00091 public: 00098 DarwinArmSimpleNavAlgNode(void); 00099 00106 ~DarwinArmSimpleNavAlgNode(void); 00107 00108 protected: 00121 void mainNodeThread(void); 00122 00135 void node_config_update(Config &config, uint32_t level); 00136 00143 void addNodeDiagnostics(void); 00144 00145 // [diagnostic functions] 00146 00147 // [test functions] 00148 }; 00149 00150 #endif