Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef AFFORDANCES_H
00033 #define AFFORDANCES_H
00034
00035 #include <fstream>
00036 #include <iostream>
00037 #include <omp.h>
00038 #include <pcl/features/feature.h>
00039 #include <pcl/features/normal_3d.h>
00040 #include <pcl/features/normal_3d_omp.h>
00041 #include <pcl/kdtree/kdtree_flann.h>
00042 #include <pcl_ros/point_cloud.h>
00043 #include <pcl/point_types.h>
00044 #include <stdlib.h>
00045 #include <string>
00046 #include <tf/transform_datatypes.h>
00047 #include "curvature_estimation_taubin.h"
00048 #include "curvature_estimation_taubin.hpp"
00049 #include "cylindrical_shell.h"
00050
00051 typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
00052 typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloudRGB;
00053
00054
00055 struct WorkspaceLimits
00056 {
00057 double min_x;
00058 double max_x;
00059 double min_y;
00060 double max_y;
00061 double min_z;
00062 double max_z;
00063 };
00064
00070 class Affordances
00071 {
00072 public:
00073
00077 void
00078 initParams(ros::NodeHandle node);
00079
00084 PointCloud::Ptr
00085 maxRangeFilter(const PointCloud::Ptr &cloud_in);
00086
00091 PointCloud::Ptr
00092 workspaceFilter(const PointCloud::Ptr &cloud_in, tf::StampedTransform *transform = NULL);
00093
00098 PointCloudRGB::Ptr
00099 workspaceFilter(const PointCloudRGB::Ptr &cloud_in, tf::StampedTransform *transform = NULL);
00100
00104 std::vector<CylindricalShell>
00105 searchAffordances(const PointCloud::Ptr &cloud, tf::StampedTransform *transform = NULL);
00106
00111 std::vector<CylindricalShell>
00112 searchAffordances(const PointCloud::Ptr &cloud, const std::vector<int> &indices);
00113
00119 std::vector<CylindricalShell>
00120 searchAffordancesTaubin(const PointCloud::Ptr &cloud, const Eigen::MatrixXd &samples,
00121 bool is_logging = true);
00122
00129 std::vector< std::vector<CylindricalShell> >
00130 searchHandles(const PointCloud::Ptr &cloud, std::vector<CylindricalShell> shells);
00131
00132 std::vector<int>
00133 createRandomIndices(const PointCloud::Ptr &cloud, int size);
00134
00141 bool
00142 isPointInWorkspace(double x, double y, double z, tf::StampedTransform *transform = NULL);
00143
00146 std::string getPCDFile() { return this->file; }
00147
00150 int getNumSamples() { return this->num_samples; }
00151
00154 double getTargetRadius() { return this->target_radius; }
00155
00156
00157 private:
00158
00163 void
00164 estimateNormals(const PointCloud::Ptr &cloud,
00165 const pcl::PointCloud<pcl::Normal>::Ptr &cloud_normals);
00166
00175 void
00176 estimateCurvatureAxisPCA(const PointCloud::Ptr &cloud, int nn_center_idx,
00177 std::vector<int> nn_indices, Eigen::Vector3d &axis,
00178 Eigen::Vector3d &normal);
00179
00186 void
00187 estimateCurvatureAxisNormals(const pcl::PointCloud<pcl::Normal>::Ptr &cloud_normals,
00188 const std::vector<int> &nn_indices,
00189 Eigen::Vector3d &axis, Eigen::Vector3d &normal);
00190
00195 std::vector<CylindricalShell>
00196 searchAffordancesNormalsOrPCA(const PointCloud::Ptr &cloud,
00197 tf::StampedTransform *transform = NULL);
00198
00203 std::vector<CylindricalShell>
00204 searchAffordancesTaubin(const PointCloud::Ptr &cloud, tf::StampedTransform *transform = NULL);
00205
00213 void findBestColinearSet(const std::vector<CylindricalShell> &list,
00214 std::vector<int> &inliersMaxSet,
00215 std::vector<int> &outliersMaxSet);
00216
00224 int numInFront(const PointCloud::Ptr &cloud, int center_index, double radius);
00225
00226
00227 double target_radius;
00228 double radius_error;
00229 double handle_gap;
00230 int num_samples;
00231 double max_range;
00232 bool use_clearance_filter;
00233 bool use_occlusion_filter;
00234 int curvature_estimator;
00235 int alignment_runs;
00236 int alignment_min_inliers;
00237 double alignment_dist_radius;
00238 double alignment_orient_radius;
00239 double alignment_radius_radius;
00240 WorkspaceLimits workspace_limits;
00241 int num_threads;
00242 std::string file;
00243
00244
00245 static const int CURVATURE_ESTIMATOR;
00246 static const int NUM_SAMPLES;
00247 static const int NUM_NEAREST_NEIGHBORS;
00248 static const double NEIGHBOR_RADIUS;
00249 static const int MAX_NUM_IN_FRONT;
00250 static const double TARGET_RADIUS;
00251 static const double RADIUS_ERROR;
00252 static const double HANDLE_GAP;
00253 static const double MAX_RANGE;
00254 static const bool USE_CLEARANCE_FILTER;
00255 static const bool USE_OCCLUSION_FILTER;
00256 static const int ALIGNMENT_RUNS;
00257 static const int ALIGNMENT_MIN_INLIERS;
00258 static const double ALIGNMENT_DIST_RADIUS;
00259 static const double ALIGNMENT_ORIENT_RADIUS;
00260 static const double ALIGNMENT_RADIUS_RADIUS;
00261 static const double WORKSPACE_MIN;
00262 static const double WORKSPACE_MAX;
00263 };
00264
00265 #endif