grasp_localizer.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2015, Andreas ten Pas
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *
00018  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00021  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00022  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00023  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00024  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00028  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  *  POSSIBILITY OF SUCH DAMAGE.
00030  */
00031 
00032 #ifndef GRASP_LOCALIZER_H_
00033 #define GRASP_LOCALIZER_H_
00034 
00035 #include <eigen_conversions/eigen_msg.h>
00036 #include <pcl_conversions/pcl_conversions.h>
00037 #include <ros/ros.h>
00038 #include <sensor_msgs/PointCloud2.h>
00039 
00040 #include <pcl/point_cloud.h>
00041 #include <pcl/point_types.h>
00042 
00043 #include <Eigen/Dense>
00044 
00045 #include <vector>
00046 
00047 #include <agile_grasp/CloudSized.h>
00048 #include <agile_grasp/Grasp.h>
00049 #include <agile_grasp/Grasps.h>
00050 #include <agile_grasp/grasp_hypothesis.h>
00051 #include <agile_grasp/handle.h>
00052 #include <agile_grasp/localization.h>
00053 #include <agile_grasp/rotating_hand.h>
00054 
00055 
00056 typedef pcl::PointCloud<pcl::PointXYZRGBA> PointCloud;
00057 
00069 class GraspLocalizer
00070 {
00071 public:
00072 
00076   struct Parameters
00077   {
00079     int num_threads_;
00080     int num_samples_;
00081     int num_clouds_;    
00082     Eigen::Matrix4d cam_tf_left_;
00083     Eigen::Matrix4d cam_tf_right_;
00084     Eigen::VectorXd workspace_;
00085     
00087     double finger_width_;
00088     double hand_outer_diameter_;
00089     double hand_depth_;
00090     double hand_height_;
00091     double init_bite_;
00092         
00093     // handle search parameters
00094     int min_inliers_;
00095     
00096     // visualization parameters
00097                 int plotting_mode_;
00098                 double marker_lifetime_;
00099   };
00100   
00110   GraspLocalizer(ros::NodeHandle& node, const std::string& cloud_topic, 
00111     const std::string& cloud_frame, int cloud_type, const std::string& svm_file_name,  
00112     const Parameters& params);
00113   
00117   ~GraspLocalizer() { delete localization_; }
00118   
00122   void localizeGrasps();
00123 
00124 private:
00125         
00130   void cloud_callback(const sensor_msgs::PointCloud2ConstPtr& msg);
00131   
00136   void cloud_sized_callback(const agile_grasp::CloudSized& msg);
00137   
00143   agile_grasp::Grasps createGraspsMsgFromHands(const std::vector<Handle>& handles);
00144   
00150   agile_grasp::Grasps createGraspsMsg(const std::vector<Handle>& handles);
00151   
00156   agile_grasp::Grasp createGraspMsg(const Handle& handle);
00157   
00162   agile_grasp::Grasps createGraspsMsg(const std::vector<GraspHypothesis>& hands);
00163   
00168   agile_grasp::Grasp createGraspMsg(const GraspHypothesis& hand);
00169   
00170   std::string svm_file_name_; 
00171   std::string cloud_frame_; 
00172   PointCloud::Ptr cloud_left_, cloud_right_; 
00173   ros::Subscriber cloud_sub_; 
00174   ros::Publisher grasps_pub_; 
00175   Localization* localization_; 
00176   std::vector<GraspHypothesis> hands_; 
00177   std::vector<GraspHypothesis> antipodal_hands_; 
00178   std::vector<Handle> handles_; 
00179   int num_clouds_received_; 
00180   int num_clouds_; 
00181   int size_left_; 
00182   int min_inliers_; 
00183   
00185         static const int POINT_CLOUD_2 = 0; 
00186         static const int CLOUD_SIZED = 1; 
00187 };
00188 
00189 #endif /* GRASP_LOCALIZER_H_ */


agile_grasp
Author(s): Andreas ten Pas
autogenerated on Sat Jun 8 2019 20:08:27