00001 00034 #ifndef AR_POSE_AR_MULTI_H 00035 #define AR_POSE_AR_MULTI_H 00036 00037 #include <string.h> 00038 #include <stdarg.h> 00039 00040 #include <AR/ar.h> 00041 #include <AR/arMulti.h> 00042 00043 #include <geometry_msgs/TransformStamped.h> 00044 #include <tf/transform_broadcaster.h> 00045 #include <tf/transform_listener.h> 00046 #include <image_transport/image_transport.h> 00047 #include <sensor_msgs/CameraInfo.h> 00048 #include <sensor_msgs/PointCloud2.h> 00049 #include <visualization_msgs/Marker.h> 00050 #include <pcl/ros/conversions.h> 00051 #include <pcl/point_types.h> 00052 #include <message_filters/subscriber.h> 00053 00054 #include <opencv/cv.h> 00055 #include <cv_bridge/CvBridge.h> 00056 00057 #include <ar_pose/ARMarkers.h> 00058 #include <ar_kinect/object.h> 00059 00060 #include <boost/multi_array.hpp> 00061 00062 #define AR_BOUNDING_BOX 00063 #define DEBUG_AR_KINECT 00064 00066 #define ORIGIN "/camera_rgb_optical_frame" 00067 00068 #define TARGET "/PATTERN_BASE" 00069 00070 #define DBG(str) //str 00071 00072 const std::string cameraImageTopic_ = "/camera/depth_registered/image"; 00073 const std::string cameraInfoTopic_ = "/camera/depth_registered/camera_info"; 00074 const std::string cloudTopic_ = "/camera/depth_registered/points"; 00075 00076 00077 class CoordinateFrame; 00078 00079 const double AR_TO_ROS = 0.001; 00080 typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloud; 00081 00082 class ARPublisher 00083 { 00084 public: 00085 ARPublisher (ros::NodeHandle & n); 00086 ~ARPublisher (void); 00087 00088 private: 00090 void arInit (); 00092 void camInfoCallback (const sensor_msgs::CameraInfoConstPtr &); 00097 void cloudCallback (const sensor_msgs::PointCloud2ConstPtr& msg); 00102 void extractObject(const sensor_msgs::PointCloud2ConstPtr& msg); 00103 00104 ros::NodeHandle n_; 00105 tf::TransformBroadcaster broadcaster_; 00106 ros::Subscriber sub_; 00107 image_transport::Subscriber cam_sub_; 00108 ros::Subscriber cloud_sub_; 00109 ros::Publisher arMarkerPub_; 00110 #ifdef DEBUG_AR_KINECT 00111 ros::Publisher kinect_pclPub_; 00112 #endif 00113 00114 image_transport::ImageTransport it_; 00115 sensor_msgs::CvBridge bridge_; 00116 sensor_msgs::CameraInfo cam_info_; 00117 PointCloud cloud_; 00118 00119 // **** for visualisation in rviz 00120 ros::Publisher rvizMarkerPub_; 00121 visualization_msgs::Marker rvizMarker_; 00122 00123 // **** parameters 00125 ARParam cam_param_; 00127 ARMultiMarkerInfoT *config; 00128 ar_object::ObjectData_T * object; 00129 int objectnum; 00130 char pattern_filename_[FILENAME_MAX]; 00131 char data_directory_[FILENAME_MAX]; 00132 00133 ar_pose::ARMarkers arPoseMarkers_; 00134 int threshold_; 00135 bool getCamInfo_; 00136 bool publishTf_; 00137 bool publishVisualMarkers_; 00139 CvSize sz_; 00140 IplImage *capture_; 00141 bool gotcloud_; 00142 int cloud_width_; 00144 cv::Mat1f distances; 00146 double boundingbox_size; 00148 double marker_dist_threshold; 00149 00150 message_filters::Subscriber<sensor_msgs::PointCloud2> sub; 00151 tf::TransformListener tf_; 00152 00154 ros::Publisher result_pcl; 00156 ros::Publisher bb_pcl; 00157 00158 typedef boost::multi_array<CoordinateFrame*, 3> transform_type; 00160 transform_type transformations; 00161 00162 }; // end class ARPublisher 00163 00164 #endif