$search
00001 /* 00002 * Copyright (c) 2011, Willow Garage, Inc. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of the Willow Garage, Inc. nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 // author: Adam Leeper 00031 00032 #ifndef PR2_MARKER_CONTROL_CLOUD_HANDLER 00033 #define PR2_MARKER_CONTROL_CLOUD_HANDLER 00034 00035 #include <ros/ros.h> 00036 00037 #include <interactive_markers/interactive_marker_server.h> 00038 #include <interactive_markers/menu_handler.h> 00039 #include <sensor_msgs/PointCloud2.h> 00040 00041 #include <actionlib/client/simple_action_client.h> 00042 #include <point_cloud_server/StoreCloudAction.h> 00043 #include <pcl/kdtree/kdtree_flann.h> 00044 #include <tf/transform_listener.h> 00045 #include <object_manipulator/tools/mechanism_interface.h> 00046 00047 typedef pcl::PointXYZRGB PointT; 00048 00049 00050 class CloudHandler 00051 { 00052 public: 00053 00054 CloudHandler( ros::NodeHandle *nh, tf::TransformListener *tfl, std::string name, 00055 interactive_markers::InteractiveMarkerServer &server, object_manipulator::MechanismInterface &mechanism); 00056 00057 ~CloudHandler(); 00058 00060 void clear(); 00061 00063 void refresh(); 00064 void refresh(const std::string &topic); 00065 00067 sensor_msgs::PointCloud2 get(); 00068 void get(sensor_msgs::PointCloud2 &cloud); 00069 00070 private: 00071 00072 typedef interactive_markers::MenuHandler MenuHandler; 00073 00074 void makeMenu(); 00075 00076 void pickup( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback ); 00077 00078 void makeMarker(float size); 00079 00080 void saveCloudAndNormals(); 00081 00082 void menuPoint( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback ); 00083 void menuFocus( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback ); 00084 void leftClickPoint( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback ); 00085 00086 std::string name_, topic_; 00087 ros::NodeHandle *nh_; 00088 ros::Publisher pub_left_click_, pub_right_click_, pub_refresh_flag_, pub_focus_; 00089 tf::TransformListener *tfl_; 00090 00091 interactive_markers::InteractiveMarkerServer &marker_server_; 00092 interactive_markers::MenuHandler menu_handler_; 00093 00094 sensor_msgs::PointCloud2 msg_cloud_; 00095 pcl::PointCloud<PointT>::Ptr cloud_pts_; 00096 pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_; 00097 pcl::KdTreeFLANN<PointT>::Ptr tree_; 00098 double voxel_size_; 00099 bool double_menu_; 00100 00101 object_manipulator::MechanismInterface &mechanism_; 00102 actionlib::SimpleActionClient<point_cloud_server::StoreCloudAction> cloud_server_client_; 00103 std::string head_pointing_frame_; 00104 }; 00105 00106 //} 00107 00108 #endif