hole_detection_alg.cpp
Go to the documentation of this file.
00001 #include "hole_detection_alg.h"
00002 using namespace std;
00003 
00004 HoleDetectionAlgorithm::HoleDetectionAlgorithm(void)
00005 {
00006 }
00007 
00008 HoleDetectionAlgorithm::~HoleDetectionAlgorithm(void)
00009 {
00010 }
00011 
00012 void HoleDetectionAlgorithm::config_update(Config& new_cfg, uint32_t level)
00013 {
00014   this->lock();
00015 
00016   // save the current configuration
00017   this->config_=new_cfg;
00018   
00019   this->unlock();
00020 }
00021 
00022 // HoleDetectionAlgorithm Public API
00023 
00024 void HoleDetectionAlgorithm::cloud_all(int hole_min_p, float box_y_end, float box_z_ini, 
00025                float box_x, float box_y_ini, float box_z_end, 
00026                float Xl, float Xc, float Xr, float Y, 
00027                pcl::PointCloud<pcl::PointXYZRGB>& cloud_in, 
00028                pcl::PointCloud<pcl::PointXYZ>::Ptr& cloud_for)
00029 {
00030 int l=0;
00031 int c=0;
00032 int r=0;
00033 
00034 
00035 for (size_t rowIndex=0, pointIndex=0; rowIndex<cloud_in.height; ++rowIndex)
00036 {
00037   for (size_t colIndex=0; colIndex<cloud_in.width; ++colIndex, ++pointIndex)
00038   {
00039     if (box_y_ini < cloud_in.points[pointIndex].y && 
00040       cloud_in.points[pointIndex].y < box_y_end && 
00041       box_z_ini < cloud_in.points[pointIndex].z && 
00042       cloud_in.points[pointIndex].z < box_z_end)
00043     {
00044       if (-(box_x/2) < cloud_in.points[pointIndex].x && 
00045         cloud_in.points[pointIndex].x < ((box_x/3)-(box_x/2)))
00046       {
00047         cloud_in.points[pointIndex].r=0;
00048         cloud_in.points[pointIndex].g=0;
00049         cloud_in.points[pointIndex].b=255;
00050         l=l+1;
00051       }
00052       if (((box_x/3)-(box_x/2)) < cloud_in.points[pointIndex].x && 
00053         cloud_in.points[pointIndex].x < ((box_x/2)-(box_x/3)))
00054       {
00055         cloud_in.points[pointIndex].r=0;
00056         cloud_in.points[pointIndex].g=255;
00057         cloud_in.points[pointIndex].b=255;
00058         c=c+1;
00059       }
00060       if (((box_x/2)-(box_x/3)) < cloud_in.points[pointIndex].x && 
00061         cloud_in.points[pointIndex].x < (box_x/2))
00062       {
00063         cloud_in.points[pointIndex].r=0;
00064         cloud_in.points[pointIndex].g=127;
00065         cloud_in.points[pointIndex].b=255;
00066         r=r+1;
00067       }
00068     }
00069   }
00070 }
00071 
00073 // Hole Point Cloud
00075 
00076 
00077 Y=-0.1;
00078 
00079 for (size_t rowIndex=0, pointIndex=0; rowIndex<5; ++rowIndex)
00080 {
00081   Xl= -(box_x/2);
00082   Xc= ((box_x/3)-(box_x/2));
00083   Xr= ((box_x/2)-(box_x/3));
00084   for (size_t colIndex=0; colIndex<5; ++colIndex, ++pointIndex)
00085         {
00086     if (l<hole_min_p)
00087     {
00088       cloud_for->points.push_back (pcl::PointXYZ(Xl+0.05, Y, box_z_ini));
00089       Xl=Xl+0.05;
00090     }
00091     if (c<hole_min_p)
00092     {
00093       cloud_for->points.push_back (pcl::PointXYZ(Xc+0.05, Y, box_z_ini));
00094       Xc=Xc+0.05;
00095     }
00096     if (r<hole_min_p)
00097     {
00098       cloud_for->points.push_back (pcl::PointXYZ(Xr+0.05, Y, box_z_ini));
00099       Xr=Xr+0.05;
00100     }
00101   }
00102   Y=Y-0.05;
00103 }
00104 
00105 }


iri_hole_detection
Author(s): asantamaria
autogenerated on Fri Dec 6 2013 20:21:38