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 _artag_image_based_vs_alg_node_h_ 00026 #define _artag_image_based_vs_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "artag_image_based_vs_alg.h" 00030 00031 #include <geometry_msgs/Twist.h> 00032 // [publisher subscriber headers] 00033 #include <ar_pose/ARMarkers.h> 00034 #include <nav_msgs/Odometry.h> 00035 #include <geometry_msgs/TwistWithCovariance.h> 00036 00037 // [service client headers] 00038 00039 // [action server client headers] 00040 00045 class ArtagImageBasedVsAlgNode : public algorithm_base::IriBaseAlgorithm<ArtagImageBasedVsAlgorithm> 00046 { 00047 private: 00048 // [publisher attributes] 00049 ros::Publisher cmd_vel_cov_publisher_; 00050 geometry_msgs::TwistWithCovariance TwistWC_msg_; 00051 ros::Publisher target_artag_publisher_; 00052 ar_pose::ARMarkers target_artag_msg_; 00053 00054 // [subscriber attributes] 00055 // Input artag 00056 ros::Subscriber input_ARtag_subscriber_; 00057 void input_ARtag_callback(const ar_pose::ARMarkers::ConstPtr& msg); 00058 CMutex input_ARtag_mutex_; 00059 00060 //Quadrotor odometry for special undeactuated output 00061 //Odometry 00062 ros::Subscriber odom_subscriber_; 00063 void odom_callback(const nav_msgs::Odometry::ConstPtr& msg); 00064 CMutex odom_mutex_; 00065 00066 00067 Eigen::MatrixXd cam_vel_; //Camera velocities. 00068 00069 ros::Time time_,time_last_; //Time variables. 00070 double dt_; // Time diferential. 00071 00072 ArtagImageBasedVsAlgorithm artag_image_based_vs_alg_; // Algorithm call. 00073 00074 bool traditional_; // Image-Jacobian type (Traditional or Uncalibrated). 00075 bool random_points_; // To use initial random features 00076 Eigen::MatrixXd desired_pose_; // Desired camera position. 00077 Eigen::MatrixXd current_pose_; // Current camera position. 00078 bool underact_; // To enable underactuation velocities oputput (no roll or pitch velocities). 00079 Eigen::MatrixXd v_rollpitch_; // Roll and pitch quadrotor angular velocities (to extract from output velocities) 00080 Eigen::MatrixXd kp_, kd_, ki_; // PID parameters. 00081 double i_lim_; // Integration limits (+ and -). 00082 00083 bool init_; // To initialize time counters 00084 00085 double fixed_to_id_; //Anchored to this ID 00086 00087 geometry_msgs::Pose pose_; //tag pose 00088 00089 // [service attributes] 00090 00091 // [client attributes] 00092 00093 // [action server attributes] 00094 00095 // [action client attributes] 00096 00097 public: 00104 ArtagImageBasedVsAlgNode(void); 00105 00112 ~ArtagImageBasedVsAlgNode(void); 00113 00114 protected: 00127 void mainNodeThread(void); 00128 00134 void get_marker_info(const ar_pose::ARMarkers::ConstPtr& msg); 00135 00148 void node_config_update(Config &config, uint32_t level); 00149 00156 void addNodeDiagnostics(void); 00157 00158 // [diagnostic functions] 00159 00160 // [test functions] 00161 }; 00162 00163 #endif