handeye_log.h
Go to the documentation of this file.
00001 #ifndef _HANDEYE_LOG_H_
00002 #define _HANDEYE_LOG_H_
00003 
00004 #include "termios.h"
00005 
00006 #include <fstream>
00007 #include <sstream>
00008 #include <iomanip>
00009 
00010 #include "ros/ros.h"
00011 #include "ros/callback_queue.h"
00012 #include "std_srvs/Empty.h"
00013 #include "iri_wam_common_msgs/wamaction.h"
00014 
00015 #include "tf/tf.h"
00016 
00017 // [PCL_ROS]
00018 #include "pcl_ros/point_cloud.h"
00019 #include "pcl/point_types.h"
00020 #include "pcl/ros/register_point_struct.h"
00021 
00022 //pcl::toROSMsg
00023 #include <pcl/io/pcd_io.h>
00024 
00025 // [publisher subscriber headers]
00026 #include "sensor_msgs/PointCloud2.h"
00027 #include "sensor_msgs/Image.h"
00028 #include "sensor_msgs/image_encodings.h"
00029 #include "geometry_msgs/PoseStamped.h"
00030 
00031 // [opencv2]
00032 #include <opencv2/highgui/highgui.hpp>
00033 
00034 #include <cv_bridge/cv_bridge.h>
00035 
00036 #include "eventserver.h"
00037 #include "threadserver.h"
00038 
00039 #include <boost/circular_buffer.hpp>
00040 #include <Eigen/StdVector>
00041 
00042 typedef union {
00043     struct /*anonymous*/
00044     {
00045         unsigned char Blue;
00046         unsigned char Green;
00047         unsigned char Red;
00048         unsigned char Alpha;
00049     };
00050     float float_value;
00051     long long_value;
00052 } RGBValue;
00053 
00054 class HandeyeLog {
00055 
00056  private:
00057   //service activation parameters
00058   bool flag_tf_robot;
00059   bool flag_tf_pattern;
00060   bool flag_iimg;
00061   bool flag_ipng;
00062   bool flag_dimg;
00063   bool flag_mpcl2;
00064   bool flag_tf_robot_inverse;
00065   int num_captures_;
00066 
00067   int idx;
00068   int nr;
00069   int nc;
00070 
00071   sensor_msgs::PointCloud2ConstPtr* msg_;
00072   int pcl_type_;
00073   pcl::PointCloud<pcl::PointXYZRGB> pcl_xyzrgb_;
00074   pcl::PointCloud<pcl::PointWithRange> pcl_xyzr_;
00075   /* boost::circular_buffer<pcl::PointCloud<pcl::Pointxyzr> > xyzr_cb_(pcl::PointCloud::VectorType); */
00076 
00077   sensor_msgs::PointCloud2 pcl_xyzri_;
00078 
00079 
00080   typedef pcl::PointWithRange Point;
00081   typedef pcl::PointCloud<Point> PointCloud;
00082   boost::circular_buffer<PointCloud, Eigen::aligned_allocator<PointCloud> > cloudBuffer_;
00083 
00084   pcl::PointCloud<pcl::PointXYZ> pcl_xyz_;
00085   cv_bridge::CvImagePtr cv_ptr_;
00086   boost::circular_buffer<cv_bridge::CvImagePtr> iimageBuffer_;
00087 
00088   sensor_msgs::Image::ConstPtr intens_image_;
00089 
00090   std::ofstream matlab_file_;
00091   std::ofstream matlab_file_seq;
00092   std::ofstream img_depth_;
00093   std::ofstream img_intensity_;
00094   std::ofstream tf_robot_file_;
00095   std::ofstream tf_pattern_file_;
00096 
00097   tf::Transform tf_robot_;
00098   tf::Transform tf_pattern_;
00099 
00100   // ROS Handlers
00101   ros::NodeHandle nh;
00102 
00103   // ROS Subscribers
00104   ros::Subscriber pcl2_sub;
00105   ros::Subscriber iimg_sub;
00106   ros::Subscriber tf_robot_sub;
00107   ros::Subscriber tf_pattern_sub;
00108 
00109   // ROS Services
00110   ros::ServiceServer srv;
00111 
00112   // Event Identifiers
00113   std::string mpcl2_event_on_id_;
00114   std::string mpcl2_event_off_id_;
00115   std::string mpcl2_event_stop_id_;
00116   std::string iimg_event_on_id_;
00117   std::string iimg_event_off_id_;
00118   std::string iimg_event_stop_id_;
00119   std::string ipng_event_on_id_;
00120   std::string ipng_event_off_id_;
00121   std::string ipng_event_stop_id_;
00122   std::string dimg_event_on_id_;
00123   std::string dimg_event_off_id_;
00124   std::string dimg_event_stop_id_;
00125   std::string tf_robot_event_on_id_;
00126   std::string tf_robot_event_off_id_;
00127   std::string tf_robot_event_stop_id_;
00128   std::string tf_pattern_event_on_id_;
00129   std::string tf_pattern_event_off_id_;
00130   std::string tf_pattern_event_stop_id_;
00131   std::string tf_robot_inverse_event_on_id_;
00132   std::string tf_robot_inverse_event_off_id_;
00133   std::string tf_robot_inverse_event_stop_id_;
00134 
00135   // Threads Identifiers
00136   std::string mpcl2_thread_id_;
00137   std::string iimg_thread_id_;
00138   std::string ipng_thread_id_;
00139   std::string dimg_thread_id_;
00140   std::string tf_robot_thread_id_;
00141   std::string tf_pattern_thread_id_;
00142   std::string tf_robot_inverse_thread_id_;
00143 
00144   // Thread Server handler
00145   CThreadServer *thread_server;
00146   // Event Server handler
00147   CEventServer *event_server;
00148 
00149   void pcl2_sub_callback(const sensor_msgs::PointCloud2ConstPtr& msg);
00150 
00151   void iimg_sub_callback(const sensor_msgs::ImageConstPtr& msg);
00152 
00153   void tf_robot_sub_callback(const geometry_msgs::PoseStampedConstPtr& msg);
00154 
00155   void tf_pattern_sub_callback(const geometry_msgs::PoseStampedConstPtr& msg);
00156 
00157   bool srv_callback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res);
00158 
00159  protected:
00160 
00161   static void *store_mpcl2_thread(void *param);
00162   static void *store_iimg_thread(void *param);
00163   static void *store_ipng_thread(void *param);
00164   static void *store_dimg_thread(void *param);
00165   static void *store_tf_robot_thread(void *param);
00166   static void *store_tf_pattern_thread(void *param);
00167   static void *store_tf_robot_inverse_thread(void *param);
00168 
00169  public:
00170   HandeyeLog();
00171   ~HandeyeLog();
00172 
00173 };
00174 #endif


handeye_log
Author(s): Sergi Foix
autogenerated on Fri Dec 6 2013 21:18:26