convert_pose_alg_node.h
Go to the documentation of this file.
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 _convert_pose_alg_node_h_
00026 #define _convert_pose_alg_node_h_
00027 
00028 #include <iri_base_algorithm/iri_base_algorithm.h>
00029 #include "convert_pose_alg.h"
00030 #include "eventserver.h"
00031 #include <iostream>
00032 #include "stdlib.h"
00033 #include "math.h"
00034 #include <tf/transform_listener.h>
00035 
00036 // [publisher subscriber headers]
00037 #include <geometry_msgs/Twist.h>
00038 #include <sensor_msgs/JointState.h>
00039 #include <std_msgs/Float64MultiArray.h>
00040 #include <std_msgs/Int32.h>
00041 #include <ar_pose/ARMarkers.h>
00042 #include <geometry_msgs/PoseStamped.h>
00043 
00044 // [service client headers]
00045 #include <kinematics_msgs/GetPositionIK.h>
00046 
00047 // [action server client headers]
00048 #include <iri_darwin_robot/tracking_headAction.h>
00049 #include <control_msgs/FollowJointTrajectoryAction.h>
00050 #include <actionlib/client/simple_action_client.h>
00051 #include <actionlib/client/terminal_state.h>
00052 #include <arm_navigation_msgs/MoveArmAction.h>
00053 
00054 typedef enum {initial_pose=0,initial_angle,move_back,search_left_marker,transform_left_pose,search_right_marker,transform_right_pose,make_decision,make_decision2,open_gripper,take_connectors,take_connectors2,close_gripper,done,correct_position,tracking_angle,tracking_left,tracking_right,tracking,new_goal,go_forward,go_back,turn_right,turn_left,go_right,go_left} TStates;
00055 
00060 class ConvertPoseAlgNode : public algorithm_base::IriBaseAlgorithm<ConvertPoseAlgorithm>
00061 {
00062   private:
00063     // [publisher attributes]    
00064     ros::Publisher cmd_vel_publisher_;
00065     geometry_msgs::Twist Twist_msg_;
00066     ros::Publisher head_target_publisher_;
00067     std_msgs::Float64MultiArray Float64MultiArray_msg_;
00068     ros::Publisher execute_action_publisher_;
00069     std_msgs::Int32 Int32_msg_;
00070 
00071     // [subscriber attributes]
00072     ros::Subscriber adc_channels_subscriber_;
00073     void adc_channels_callback(const std_msgs::Float64MultiArray::ConstPtr& msg);
00074     CMutex adc_channels_mutex_;
00075     double current_voltage;
00076     ros::Subscriber joint_state_subscriber_;
00077     void joint_state_callback(const sensor_msgs::JointState::ConstPtr& msg);
00078     CMutex joint_state_mutex_;
00079     sensor_msgs::JointState current_state;
00080     ros::Subscriber marker_subscriber_;
00081     void marker_callback(const ar_pose::ARMarkers::ConstPtr& msg);
00082     CMutex marker_mutex_;
00083     geometry_msgs::PoseStamped marker_;
00084     geometry_msgs::PoseStamped conv_msg_;
00085     geometry_msgs::PoseStamped right_pose_;
00086     geometry_msgs::PoseStamped left_pose_;
00087     ar_pose::ARMarkers msg_;
00088 
00089     // [service attributes]
00090 
00091     // [client attributes]
00092     ros::ServiceClient get_ik_client_;
00093     kinematics_msgs::GetPositionIK get_ik_srv_;
00094 
00095     // [action server attributes]
00096 
00097     // [action client attributes]
00098     actionlib::SimpleActionClient<iri_darwin_robot::tracking_headAction> tracking_head_client_;
00099     iri_darwin_robot::tracking_headGoal tracking_head_goal_;
00100     void tracking_headMakeActionRequest();
00101     void tracking_headDone(const actionlib::SimpleClientGoalState& state,  const iri_darwin_robot::tracking_headResultConstPtr& result);
00102     void tracking_headActive();
00103     void tracking_headFeedback(const iri_darwin_robot::tracking_headFeedbackConstPtr& feedback);
00104 
00105     actionlib::SimpleActionClient<control_msgs::FollowJointTrajectoryAction> move_joints_client_;
00106     control_msgs::FollowJointTrajectoryGoal move_joints_goal_;
00107     void move_jointsMakeActionRequest();
00108     void move_jointsDone(const actionlib::SimpleClientGoalState& state,  const control_msgs::FollowJointTrajectoryResultConstPtr& result);
00109     void move_jointsActive();
00110     void move_jointsFeedback(const control_msgs::FollowJointTrajectoryFeedbackConstPtr& feedback);
00111     bool joints_moving;
00112 
00113     actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> move_right_arm_client_;
00114     arm_navigation_msgs::MoveArmGoal move_right_arm_goal_;
00115     void move_right_armMakeActionRequest();
00116     void move_right_armDone(const actionlib::SimpleClientGoalState& state,  const arm_navigation_msgs::MoveArmResultConstPtr& result);
00117     void move_right_armActive();
00118     void move_right_armFeedback(const arm_navigation_msgs::MoveArmFeedbackConstPtr& feedback);
00119     bool right_arm_moving;
00120 
00121     actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> move_left_arm_client_;
00122     arm_navigation_msgs::MoveArmGoal move_left_arm_goal_;
00123     void move_left_armMakeActionRequest();
00124     void move_left_armDone(const actionlib::SimpleClientGoalState& state,  const arm_navigation_msgs::MoveArmResultConstPtr& result);
00125     void move_left_armActive();
00126     void move_left_armFeedback(const arm_navigation_msgs::MoveArmFeedbackConstPtr& feedback);
00127     bool left_arm_moving;
00128     
00129     tf::TransformListener tf_listener;   
00130     bool ready;
00131     bool head_moving;
00132     bool left_marker_found;
00133     bool right_marker_found;    
00134     bool right_data_ready;
00135     bool left_data_ready;
00136     bool left_done;
00137     bool ready_for_check;
00138     bool left_ok;
00139     bool right_ok;  
00140     bool prev_left_ok;
00141     bool prev_right_ok;
00142     bool left_ready_tf;
00143     bool right_ready_tf;
00144     bool first_goal;
00145     bool success;
00146     double current_pan;
00147     int n; 
00148  
00149     TStates state;
00150 
00151   public:
00158     ConvertPoseAlgNode(void);
00159 
00166     ~ConvertPoseAlgNode(void);
00167 
00168   protected:
00181     void mainNodeThread(void);
00182 
00195     void node_config_update(Config &config, uint32_t level);
00196 
00203     void addNodeDiagnostics(void);
00204 
00205     // [diagnostic functions]
00206     
00207     // [test functions]
00208 };
00209 
00210 #endif


convert_pose
Author(s): darwin
autogenerated on Fri Dec 6 2013 20:54:52