00001 /* 00002 * Single Marker Pose Estimation using ARToolkit 00003 * Copyright (C) 2013, I Heart Engineering 00004 * Copyright (C) 2010, CCNY Robotics Lab 00005 * William Morris <bill@iheartengineering.com> 00006 * Ivan Dryanovski <ivan.dryanovski@gmail.com> 00007 * Gautier Dumonteil <gautier.dumonteil@gmail.com> 00008 * http://www.iheartengineering.com 00009 * http://robotics.ccny.cuny.edu 00010 * 00011 * This program is free software: you can redistribute it and/or modify 00012 * it under the terms of the GNU General Public License as published by 00013 * the Free Software Foundation, either version 3 of the License, or 00014 * (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 */ 00024 00025 #ifndef AR_POSE_AR_SINGLE_H 00026 #define AR_POSE_AR_SINGLE_H 00027 00028 #include <string.h> 00029 #include <stdarg.h> 00030 00031 #include <AR/param.h> 00032 #include <AR/ar.h> 00033 #include <AR/video.h> 00034 00035 #include <ros/ros.h> 00036 #include <ros/package.h> 00037 #include <ros/console.h> 00038 #include <geometry_msgs/TransformStamped.h> 00039 #include <tf/transform_broadcaster.h> 00040 #include <image_transport/image_transport.h> 00041 #include <sensor_msgs/CameraInfo.h> 00042 #include <visualization_msgs/Marker.h> 00043 #include <resource_retriever/retriever.h> 00044 00045 #include <opencv/cv.h> 00046 #include <opencv/highgui.h> 00047 00048 #if ROS_VERSION_MINIMUM(1, 9, 0) 00049 // new cv_bridge API in Groovy 00050 #include <cv_bridge/cv_bridge.h> 00051 #include <sensor_msgs/image_encodings.h> 00052 #else 00053 // Fuerte support for cv_bridge will be deprecated 00054 #if defined(__GNUC__) 00055 #warning "Support for the old cv_bridge API (Fuerte) is derecated and will be removed when Hydro is released." 00056 #endif 00057 #include <cv_bridge/CvBridge.h> 00058 #endif 00059 00060 00061 #include <ar_pose/ARMarker.h> 00062 00063 const std::string cameraImageTopic_ = "/camera/image_raw"; 00064 const std::string cameraInfoTopic_ = "/camera/camera_info"; 00065 00066 const double AR_TO_ROS = 0.001; 00067 00068 namespace ar_pose 00069 { 00070 class ARSinglePublisher 00071 { 00072 public: 00073 ARSinglePublisher (ros::NodeHandle & n); 00074 ~ARSinglePublisher (void); 00075 00076 private: 00077 void arInit (); 00078 void getTransformationCallback (const sensor_msgs::ImageConstPtr &); 00079 void camInfoCallback (const sensor_msgs::CameraInfoConstPtr &); 00080 00081 ros::NodeHandle n_; 00082 ros::Subscriber sub_; 00083 tf::TransformBroadcaster broadcaster_; 00084 ros::Publisher arMarkerPub_; 00085 00086 ar_pose::ARMarker ar_pose_marker_; 00087 image_transport::ImageTransport it_; 00088 image_transport::Subscriber cam_sub_; 00089 #if ! ROS_VERSION_MINIMUM(1, 9, 0) 00090 sensor_msgs::CvBridge bridge_; 00091 #endif 00092 sensor_msgs::CameraInfo cam_info_; 00093 00094 // **** parameters 00095 00096 //std::string cameraFrame_; 00097 std::string markerFrame_; 00098 bool publishTf_; 00099 bool publishVisualMarkers_; 00100 bool useHistory_; 00101 int threshold_; 00102 double markerWidth_; // Size of the AR Marker in mm 00103 00104 ARParam cam_param_; // Camera Calibration Parameters 00105 int patt_id_; // AR Marker Pattern 00106 char pattern_filename_[FILENAME_MAX]; 00107 bool reverse_transform_; // Reverse direction of transform marker -> cam 00108 00109 double marker_center_[2]; // Physical Center of the Marker 00110 double marker_trans_[3][4]; // Marker Transform 00111 00112 // **** for visualisation in rviz 00113 ros::Publisher rvizMarkerPub_; 00114 visualization_msgs::Marker rvizMarker_; 00115 00116 int contF; 00117 bool getCamInfo_; 00118 CvSize sz_; 00119 #if ROS_VERSION_MINIMUM(1, 9, 0) 00120 cv_bridge::CvImagePtr capture_; 00121 #else 00122 IplImage *capture_; 00123 #endif 00124 00125 }; // end class ARSinglePublisher 00126 } // end namespace ar_pose 00127 00128 #endif