Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
PCLObjectDetector.hpp
Go to the documentation of this file.
1 #ifndef PCLOBJECTDETECTOR_HPP_
2 #define PCLOBJECTDETECTOR_HPP_
3 
4 // Pointcloud header
5 #include <pcl/point_types.h>
6 #include <pcl/filters/passthrough.h>
7 #include <pcl/ModelCoefficients.h>
8 #include <pcl/io/pcd_io.h>
9 #include <pcl/point_types.h>
10 #include <pcl/sample_consensus/method_types.h>
11 #include <pcl/sample_consensus/model_types.h>
12 #include <pcl/segmentation/sac_segmentation.h>
13 #include <pcl/surface/convex_hull.h>
14 #include <pcl/filters/extract_indices.h>
15 #include <pcl/filters/voxel_grid.h> // for downsampling
16 #include <pcl/segmentation/extract_clusters.h>
17 #include <pcl/common/impl/centroid.hpp>
18 #include <pcl/common/common.h>
19 
20 #include "Object.hpp"
21 
22 using pclPtrType = pcl::PointCloud<pcl::PointXYZ>::Ptr;
23 using pclType = pcl::PointCloud<pcl::PointXYZ>;
24 
25 #include <iostream>
26 #include <string>
27 
29 private:
30  void passThroughFilter(pclPtrType p_inputCloudPtr, pclPtrType p_outputCloudPtr, float y_min, float y_max);
31 
32  void downsampling(pclPtrType p_inputCloudPtr, pclPtrType p_outputCloudPtr, float p_leafSize);
33 
34 protected:
35  std::string m_name = "none";
36 
37 public:
38  int filter_pcl(pclPtrType p_pclPtr, pclPtrType p_cloudFiltered, float p_leafsize, float y_min, float y_max) {
39  int ret = 0;
40 
41  if(p_pclPtr == nullptr) {
42  ret = -1;
43  } else {
44  downsampling(p_pclPtr, p_cloudFiltered, p_leafsize);
45 
46  passThroughFilter(p_cloudFiltered, p_cloudFiltered, y_min, y_max);
47 
48  ret = 0;
49  }
50 
51  return ret;
52  };
53 
54  virtual std::shared_ptr<std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr>> cluster_data(pclPtrType p_pclPtr, std::vector<Object>& p_objectsVecRef, float clusterTolerance, int minClusterSize, int maxClusterSize) const = 0;
55 
56  std::string get_name(void) {
57  return m_name;
58  };
59 };
60 
62 public:
64  m_name = "euclidean detector";
65  };
66 
67  float m_minSizeX = 0.1;
68  float m_minSizeY = 0.2;
69  float m_minSizeZ = 0.001f;
70 
71  float m_maxSizeX = 1.f;
72  float m_maxSizeY = 1.f;
73  float m_maxSizeZ = 1.f;
74 
77 
78  std::shared_ptr<std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr>> cluster_data(pclPtrType p_pclPtr, std::vector<Object>& p_objectsVecRef, float clusterTolerance, int minClusterSize, int maxClusterSize) const;
79 };
80 
81 #endif /* ifndef PCLOBJECTDETECTOR_HPP_ */
Object.hpp
EuclideanDetector::m_maxSizeZ
float m_maxSizeZ
Definition: PCLObjectDetector.hpp:73
EuclideanDetector::m_minSizeY
float m_minSizeY
Definition: PCLObjectDetector.hpp:68
EuclideanDetector
Definition: PCLObjectDetector.hpp:61
EuclideanDetector::m_postProcessingClusterSizeMax
float m_postProcessingClusterSizeMax
Definition: PCLObjectDetector.hpp:76
PCLObjectDetector::downsampling
void downsampling(pclPtrType p_inputCloudPtr, pclPtrType p_outputCloudPtr, float p_leafSize)
Definition: PCLObjectDetector.cpp:101
PCLObjectDetector
Definition: PCLObjectDetector.hpp:28
EuclideanDetector::EuclideanDetector
EuclideanDetector()
Definition: PCLObjectDetector.hpp:63
PCLObjectDetector::m_name
std::string m_name
Definition: PCLObjectDetector.hpp:35
pclPtrType
pcl::PointCloud< pcl::PointXYZ >::Ptr pclPtrType
Definition: PCLObjectDetector.hpp:22
EuclideanDetector::m_minSizeX
float m_minSizeX
Definition: PCLObjectDetector.hpp:67
EuclideanDetector::m_postProcessingClusterSizeMin
float m_postProcessingClusterSizeMin
Definition: PCLObjectDetector.hpp:75
PCLObjectDetector::cluster_data
virtual std::shared_ptr< std::vector< pcl::PointCloud< pcl::PointXYZ >::Ptr > > cluster_data(pclPtrType p_pclPtr, std::vector< Object > &p_objectsVecRef, float clusterTolerance, int minClusterSize, int maxClusterSize) const =0
pclType
pcl::PointCloud< pcl::PointXYZ > pclType
Definition: PCLObjectDetector.hpp:23
PCLObjectDetector::passThroughFilter
void passThroughFilter(pclPtrType p_inputCloudPtr, pclPtrType p_outputCloudPtr, float y_min, float y_max)
Definition: PCLObjectDetector.cpp:108
EuclideanDetector::cluster_data
std::shared_ptr< std::vector< pcl::PointCloud< pcl::PointXYZ >::Ptr > > cluster_data(pclPtrType p_pclPtr, std::vector< Object > &p_objectsVecRef, float clusterTolerance, int minClusterSize, int maxClusterSize) const
Definition: PCLObjectDetector.cpp:7
EuclideanDetector::m_maxSizeX
float m_maxSizeX
Definition: PCLObjectDetector.hpp:71
PCLObjectDetector::get_name
std::string get_name(void)
Definition: PCLObjectDetector.hpp:56
EuclideanDetector::m_maxSizeY
float m_maxSizeY
Definition: PCLObjectDetector.hpp:72
PCLObjectDetector::filter_pcl
int filter_pcl(pclPtrType p_pclPtr, pclPtrType p_cloudFiltered, float p_leafsize, float y_min, float y_max)
Definition: PCLObjectDetector.hpp:38
EuclideanDetector::m_minSizeZ
float m_minSizeZ
Definition: PCLObjectDetector.hpp:69