00001 /* 00002 * Multi 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_MULTI_H 00026 #define AR_POSE_AR_MULTI_H 00027 00028 #include <string.h> 00029 #include <stdarg.h> 00030 00031 #include <artoolkit/AR/gsub.h> 00032 #include <artoolkit/AR/video.h> 00033 #include <artoolkit/AR/param.h> 00034 #include <artoolkit/AR/ar.h> 00035 #include <artoolkit/AR/arMulti.h> 00036 00037 #include <ros/ros.h> 00038 #include <ros/package.h> 00039 #include <ros/console.h> 00040 #include <geometry_msgs/TransformStamped.h> 00041 #include <tf/transform_broadcaster.h> 00042 #include <image_transport/image_transport.h> 00043 #include <sensor_msgs/CameraInfo.h> 00044 #include <visualization_msgs/Marker.h> 00045 #include <resource_retriever/retriever.h> 00046 00047 #include <opencv/cv.h> 00048 00049 #if ROS_VERSION_MINIMUM(1, 9, 0) 00050 // new cv_bridge API in Groovy 00051 #include <cv_bridge/cv_bridge.h> 00052 #include <sensor_msgs/image_encodings.h> 00053 #else 00054 // Fuerte support for cv_bridge will be deprecated 00055 #if defined(__GNUC__) 00056 #warning "Support for the old cv_bridge API (Fuerte) is derecated and will be removed when Hydro is released." 00057 #endif 00058 #include <cv_bridge/CvBridge.h> 00059 #endif 00060 00061 #include <ar_pose/ARMarkers.h> 00062 #include <ar_pose/ARMarker.h> 00063 #include <ar_pose/object.h> 00064 00065 const std::string cameraImageTopic_ = "/camera/image_raw"; 00066 const std::string cameraInfoTopic_ = "/camera/camera_info"; 00067 00068 const double AR_TO_ROS = 0.001; 00069 00070 namespace ar_pose 00071 { 00072 class ARMultiPublisher 00073 { 00074 public: 00075 ARMultiPublisher (ros::NodeHandle & n); 00076 ~ARMultiPublisher (void); 00077 00078 private: 00079 void arInit (); 00080 void getTransformationCallback (const sensor_msgs::ImageConstPtr &); 00081 void camInfoCallback (const sensor_msgs::CameraInfoConstPtr &); 00082 00083 ros::NodeHandle n_; 00084 tf::TransformBroadcaster broadcaster_; 00085 ros::Subscriber sub_; 00086 image_transport::Subscriber cam_sub_; 00087 ros::Publisher arMarkerPub_; 00088 00089 image_transport::ImageTransport it_; 00090 #if ! ROS_VERSION_MINIMUM(1, 9, 0) 00091 sensor_msgs::CvBridge bridge_; 00092 #endif 00093 sensor_msgs::CameraInfo cam_info_; 00094 00095 // **** for visualisation in rviz 00096 ros::Publisher rvizMarkerPub_; 00097 visualization_msgs::Marker rvizMarker_; 00098 00099 // **** parameters 00100 ARParam cam_param_; // Camera Calibration Parameters 00101 ARMultiMarkerInfoT *config; // AR Marker Info 00102 ar_object::ObjectData_T * object; 00103 int objectnum; 00104 char pattern_filename_[FILENAME_MAX]; 00105 00106 ar_pose::ARMarkers arPoseMarkers_; 00107 int threshold_; 00108 bool getCamInfo_; 00109 bool publishTf_; 00110 bool publishVisualMarkers_; 00111 CvSize sz_; 00112 #if ROS_VERSION_MINIMUM(1, 9, 0) 00113 cv_bridge::CvImagePtr capture_; 00114 #else 00115 IplImage *capture_; 00116 #endif 00117 00118 }; // end class ARMultiPublisher 00119 } //end namespace ar_pose 00120 00121 #endif