cloud_handler.h
Go to the documentation of this file.
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/search/kdtree.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, 
00055                 std::string marker_name,
00056                 std::string topic_name, std::string server_name,
00057                 object_manipulator::MechanismInterface &mechanism,
00058                 std::string cloud_frame);
00059 
00060   ~CloudHandler();
00061 
00063   void clear();
00064 
00066   void refresh();
00067   void refresh(const std::string &topic);
00068   void updateCloud(sensor_msgs::PointCloud2 cloud, std::string name);
00069 
00071   sensor_msgs::PointCloud2 get();
00072   void get(sensor_msgs::PointCloud2 &cloud);
00073 
00074 private:
00075 
00076   typedef interactive_markers::MenuHandler MenuHandler;
00077 
00078   void makeMenu();
00079 
00080   void pickup( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
00081 
00082   void makeMarker(float size);
00083 
00084   void saveCloudAndNormals();
00085 
00086   void menuPoint( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
00087   void menuFocus( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
00088   void leftClickPoint( const visualization_msgs::InteractiveMarkerFeedbackConstPtr &feedback );
00089 
00090   std::string marker_name_, topic_;
00091   ros::NodeHandle *nh_;
00092   ros::Publisher pub_left_click_, pub_right_click_, pub_refresh_flag_, pub_focus_;
00093   tf::TransformListener *tfl_;
00094 
00095   interactive_markers::InteractiveMarkerServer marker_server_;
00096   interactive_markers::MenuHandler menu_handler_;
00097 
00098   sensor_msgs::PointCloud2 msg_cloud_;
00099   pcl::PointCloud<PointT>::Ptr cloud_pts_;
00100   pcl::PointCloud<pcl::Normal>::Ptr cloud_normals_;
00101   pcl::search::KdTree<PointT>::Ptr tree_;
00102   double voxel_size_;
00103   bool double_menu_;
00104   
00105   object_manipulator::MechanismInterface &mechanism_;
00106   actionlib::SimpleActionClient<point_cloud_server::StoreCloudAction> cloud_server_client_;
00107   std::string head_pointing_frame_;
00108   std::string cloud_frame_;
00109 };
00110 
00111 //}
00112 
00113 #endif


pr2_marker_control
Author(s): Adam Leeper
autogenerated on Fri Jan 3 2014 12:07:28