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_virtual_features_alg_node_h_ 00026 #define _artag_virtual_features_alg_node_h_ 00027 00028 #include <iri_base_algorithm/iri_base_algorithm.h> 00029 #include "artag_image_based_vs_alg.h" 00030 00031 #include <tf/transform_datatypes.h> 00032 00033 // [publisher subscriber headers] 00034 #include <ar_pose/ARMarkers.h> 00035 #include <std_msgs/Float64MultiArray.h> 00036 #include <std_msgs/Bool.h> 00037 00038 // [service client headers] 00039 00040 // [action server client headers] 00041 00046 class ArtagImageBasedVsAlgNode : public algorithm_base::IriBaseAlgorithm<ArtagImageBasedVsAlgorithm> 00047 { 00048 private: 00049 // [publisher attributes] 00050 ros::Publisher pn_publisher_; 00051 std_msgs::Float64MultiArray pn_msg_; 00052 ros::Publisher cj_0_publisher_; 00053 std_msgs::Float64MultiArray cj_0_msg_; 00054 ros::Publisher P0_publisher_; 00055 std_msgs::Float64MultiArray P0_msg_; 00056 ros::Publisher alfas_publisher_; 00057 std_msgs::Float64MultiArray alfas_msg_; 00058 ros::Publisher cP_publisher_; 00059 std_msgs::Float64MultiArray cP_msg_; 00060 ros::Publisher object_found_publisher_; 00061 std_msgs::Bool object_found_msg_; 00062 00063 // [subscriber attributes] 00064 void marker_callback(const ar_pose::ARMarkers::ConstPtr& msg); 00065 ros::Subscriber marker_subscriber_; 00066 CMutex marker_mutex_; 00067 // [service attributes] 00068 00069 // [client attributes] 00070 00071 // [action server attributes] 00072 00073 // [action client attributes] 00074 00075 Eigen::MatrixXd pn_; //Virtual features 00076 Eigen::MatrixXd cj_0_; //Virtual features mean point 00077 Eigen::MatrixXd P0_; //Base points (barycentric coordinates) 00078 Eigen::MatrixXd alfas_; //Proportional factors to form each point with the basis (alfas) 00079 Eigen::MatrixXd cP_; //Current virtual features detected (with the ARtag transform) 00080 Eigen::Matrix4d cTo_; //Marker transform in the camera frame 00081 int n_; 00082 bool random_points_; //To compute random virtual features 00083 bool planar_; //To check basis planarity 00084 bool init_; //To execute only once at initial point 00085 bool object_found_; //Marker detected or not 00086 00087 public: 00094 ArtagImageBasedVsAlgNode(void); 00095 00102 ~ArtagImageBasedVsAlgNode(void); 00103 00104 protected: 00117 void mainNodeThread(void); 00125 void virtual_features(); 00126 00132 void fill_msg(std_msgs::Float64MultiArray& msg, const Eigen::MatrixXd& data); 00133 00146 void node_config_update(Config &config, uint32_t level); 00147 00154 void addNodeDiagnostics(void); 00155 00156 // [diagnostic functions] 00157 00158 // [test functions] 00159 }; 00160 00161 #endif