00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2014, 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 SAMPLING_H_ 00033 #define SAMPLING_H_ 00034 00035 #include "handle_detector/affordances.h" 00036 #include "handle_detector/cylindrical_shell.h" 00037 #include "handle_detector/sampling_visualizer.h" 00038 #include <pcl/point_cloud.h> 00039 #include <pcl/point_types.h> 00040 #include <pcl/visualization/pcl_visualizer.h> 00041 00042 typedef pcl::PointCloud<pcl::PointXYZ> PointCloud; 00043 typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloudRGB; 00044 00048 class Sampling 00049 { 00050 public: 00051 void setAffordances(Affordances &affordances) 00052 { 00053 this->affordances = affordances; 00054 } 00055 ; 00056 00062 void 00063 initParams(const ros::NodeHandle& node); 00064 00071 void 00072 illustrate(const PointCloud::Ptr &cloud, const PointCloudRGB::Ptr &cloudrgb, double target_radius); 00073 00080 std::vector<CylindricalShell> 00081 searchAffordances(const PointCloud::Ptr &cloud, const PointCloudRGB::Ptr &cloudrgb, double target_radius); 00082 00083 private: 00084 Affordances affordances; 00085 int num_iterations; 00086 int num_samples; 00087 int num_init_samples; 00088 double prob_rand_samples; 00089 bool is_visualized; 00090 int method; 00091 00092 // standard parameters 00093 static const int NUM_ITERATIONS; 00094 static const int NUM_SAMPLES; 00095 static const int NUM_INIT_SAMPLES; 00096 static const double PROB_RAND_SAMPLES; 00097 static const bool VISUALIZE_STEPS; 00098 static const int METHOD; 00099 }; 00100 00101 #endif /* SAMPLING_H_ */