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 _kinton_arm_tag_tracker_alg_node_h_ 00026 #define _kinton_arm_tag_tracker_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "kinton_arm_tag_tracker_alg.h" 00030 00031 // [publisher subscriber headers] 00032 #include <sensor_msgs/JointState.h> 00033 #include <geometry_msgs/Twist.h> 00034 #include <geometry_msgs/TwistWithCovariance.h> 00035 00036 using namespace KDL; 00037 using namespace Eigen; 00038 using namespace std; 00039 00040 // [service client headers] 00041 00042 // [action server client headers] 00043 00048 class KintonArmTagTrackerAlgNode : public algorithm_base::IriBaseAlgorithm<KintonArmTagTrackerAlgorithm> 00049 { 00050 private: 00051 // [publisher attributes] 00052 ros::Publisher output_publisher_; 00053 sensor_msgs::JointState JointState_msg_; 00054 00055 // [subscriber attributes] 00056 ros::Subscriber input_subscriber_; 00057 void input_callback(const geometry_msgs::TwistWithCovariance::ConstPtr& msg); 00058 CMutex input_mutex_; 00059 00060 bool activate_; //When to activate the servoing. 00061 00062 ros::Time time_,time_last_; //Time variables. 00063 double dt_; // Time diferential. 00064 bool init_; //Initialize timers and arm parameters. 00065 00066 // Arm parameters 00067 Chain kdl_chain_; //Arm chain. 00068 int num_joints_; //Number of joints. 00069 bool cam_vel_ok_; // Check the camera velocities covariance. 00070 Matrix4d T_endeff_; // Homogenous Transform between inertial frame and arm end-effector frame. 00071 00072 geometry_msgs::Pose pose_; //Artag pose to compute Quadrotor position r.t. marker 00073 00074 MatrixXd q_; // DOF variables. 00075 00076 MatrixXd cam_vel_; //Actual velocity of the camera from the visual servo. 00077 00078 KintonArmTagTrackerAlgorithm tag_tracker_; 00079 00085 void init_arm(); 00086 // [service attributes] 00087 00088 // [client attributes] 00089 00090 // [action server attributes] 00091 00092 // [action client attributes] 00093 00094 public: 00101 KintonArmTagTrackerAlgNode(void); 00102 00109 ~KintonArmTagTrackerAlgNode(void); 00110 00111 protected: 00124 void mainNodeThread(void); 00125 00138 void node_config_update(Config &config, uint32_t level); 00139 00146 void addNodeDiagnostics(void); 00147 00148 // [diagnostic functions] 00149 00150 // [test functions] 00151 }; 00152 00153 #endif