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