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 _moped_handler_alg_h_ 00026 #define _moped_handler_alg_h_ 00027 00028 #include <iri_moped_handler/MopedHandlerConfig.h> 00029 #include "mutex.h" 00030 00031 // C++ includes 00032 #include <iostream> 00033 #include <vector> 00034 #include <cmath> 00035 using namespace std; 00036 00037 // Publisher subscriber headers 00038 #include <pr_msgs/ObjectPoseList.h> 00039 00040 // PCL specific includes 00041 #include <pcl/ros/conversions.h> 00042 #include <pcl/point_cloud.h> 00043 #include <pcl/point_types.h> 00044 00045 //include moped_handler_alg main library 00046 00052 class MopedHandlerAlgorithm 00053 { 00054 protected: 00061 CMutex alg_mutex_; 00062 00063 // private attributes and methods 00064 00065 public: 00072 typedef iri_moped_handler::MopedHandlerConfig Config; 00073 00080 Config config_; 00081 00090 MopedHandlerAlgorithm(void); 00091 00097 void lock(void) { alg_mutex_.enter(); }; 00098 00104 void unlock(void) { alg_mutex_.exit(); }; 00105 00113 bool try_enter(void) { return alg_mutex_.try_enter(); }; 00114 00126 void config_update(Config& new_cfg, uint32_t level=0); 00127 00128 // here define all moped_handler_alg interface methods to retrieve and set 00129 // the driver parameters 00130 00137 ~MopedHandlerAlgorithm(void); 00138 00139 }; 00140 00141 #endif 00142 00143 00144 // DEAD CODE 00145 00146 /* 00147 // Struct for position 00148 typedef struct 00149 { 00150 float x, y, z; 00151 } pos_t; 00152 00153 // Struct for orientation 00154 typedef struct 00155 { 00156 float x, y, z, w; 00157 } ori_t; 00158 00159 // Struct for object pose. 00160 typedef struct 00161 { 00162 pos_t pos2D; 00163 pos_t pos3D; 00164 ori_t ori; 00165 } Op_t; 00166 00167 // Attributes 00168 vector<Op_t> inputOpl; // Object Position List 00169 vector<Op_t> outputOpl; // Object Position List 00170 pcl::PointCloud<pcl::PointXYZ> pcl_; 00171 00172 // Main functions 00173 00174 // Set data to @attribute opl from a ROS message. 00175 void setObjectDataFromRosMsg(pr_msgs::ObjectPoseList input); 00176 00177 // Starts to compute the input data and fills the output data. 00178 void compute(); 00179 00180 // Creates and returns a ROS msg from the output OPL. 00181 pr_msgs::ObjectPoseList getRosMsgWithObjectData(); 00182 00183 // Other functions 00184 // Given a position wrt the camera, gives the pixel showing that position. 00185 void getPose2Pixel(float x, float y, float z, int& xPixel, int& yPixel, pcl::PointCloud<pcl::PointXYZ> pcl); 00186 // Given a pixel position (x, y) returns the distance to that pixel in the @param pcl. 00187 // float getDepthPixel(int x, int y, pcl::PointCloud<pcl::PointXYZ> pcl); 00188 // Given a pixel, return the point in that pixel (wrt the camera), according to the input pcl. 00189 MopedHandlerAlgorithm::pos_t getPixel2Pose(float xPixel, float yPixel, pcl::PointCloud<pcl::PointXYZ> pcl); 00190 00191 */