69 const typename pcl::PointCloud<PointT>::Ptr & cloudIn,
70 const pcl::IndicesPtr & indicesIn,
72 const cv::Point3f & viewPoint,
73 pcl::IndicesPtr & groundIndices,
74 pcl::IndicesPtr & obstaclesIndices,
75 pcl::IndicesPtr * flatObstacles)
const
77 groundIndices.reset(
new std::vector<int>);
78 obstaclesIndices.reset(
new std::vector<int>);
81 flatObstacles->reset(
new std::vector<int>);
91 typename pcl::PointCloud<PointT>::Ptr cloud(
new pcl::PointCloud<PointT>);
92 pcl::IndicesPtr indices(
new std::vector<int>);
94 if(preVoxelFiltering_)
99 indices->resize(cloud->size());
100 for(
unsigned int i=0; i<indices->size(); ++i)
108 if(indicesIn->empty() && cloud->is_dense)
110 indices->resize(cloud->size());
111 for(
unsigned int i=0; i<indices->size(); ++i)
128 float roll, pitch, yaw;
130 UDEBUG(
"node.getPose()=%s projMapFrame_=%d", pose.
prettyPrint().c_str(), projMapFrame_?1:0);
134 if(footprintLength_ > 0.0f || footprintWidth_ > 0.0f || footprintHeight_ > 0.0f)
140 footprintLength_>0.0f?-footprintLength_/2.0f:std::numeric_limits<int>::min(),
141 footprintWidth_>0.0f&&footprintLength_>0.0f?-footprintWidth_/2.0f:std::numeric_limits<int>::min(),
145 footprintLength_>0.0f?footprintLength_/2.0f:std::numeric_limits<int>::max(),
146 footprintWidth_>0.0f&&footprintLength_>0.0f?footprintWidth_/2.0f:std::numeric_limits<int>::max(),
147 footprintHeight_>0.0f&&footprintLength_>0.0f&&footprintWidth_>0.0f?footprintHeight_:std::numeric_limits<int>::max(),
154 if(minGroundHeight_ != 0.0f || maxObstacleHeight_ != 0.0f)
157 minGroundHeight_!=0.0f?minGroundHeight_:std::numeric_limits<int>::min(),
158 maxObstacleHeight_>0.0f?maxObstacleHeight_:std::numeric_limits<int>::max());
159 UDEBUG(
"indices after max obstacles height filtering = %d", (
int)indices->size());
164 if(normalsSegmentation_ && !groundIsObstacle_)
166 UDEBUG(
"normalKSearch=%d", normalKSearch_);
167 UDEBUG(
"maxGroundAngle=%f", maxGroundAngle_);
168 UDEBUG(
"Cluster radius=%f", clusterRadius_);
169 UDEBUG(
"flatObstaclesDetected=%d", flatObstaclesDetected_?1:0);
170 UDEBUG(
"maxGroundHeight=%f", maxGroundHeight_);
171 UDEBUG(
"groundNormalsUp=%f", groundNormalsUp_);
172 util3d::segmentObstaclesFromGround<PointT>(
181 flatObstaclesDetected_,
184 Eigen::Vector4f(viewPoint.x, viewPoint.y, viewPoint.z+(projMapFrame_?pose.
z():0), 1),
186 UDEBUG(
"viewPoint=%f,%f,%f", viewPoint.x, viewPoint.y, viewPoint.z+(projMapFrame_?pose.
z():0));
196 minGroundHeight_!=0.0f?minGroundHeight_:std::numeric_limits<int>::min(),
197 maxGroundHeight_!=0.0f?maxGroundHeight_:std::numeric_limits<int>::max());
199 pcl::IndicesPtr notObstacles = groundIndices;
208 UDEBUG(
"groundIndices=%d obstaclesIndices=%d", (
int)groundIndices->size(), (
int)obstaclesIndices->size());
211 if(noiseFilteringRadius_ > 0.0 && noiseFilteringMinNeighbors_ > 0)
213 UDEBUG(
"Radius filtering (%ld ground %ld obstacles, radius=%f k=%d)",
214 groundIndices->size(),
215 obstaclesIndices->size()+(flatObstacles?(*flatObstacles)->size():0),
216 noiseFilteringRadius_,
217 noiseFilteringMinNeighbors_);
218 if(groundIndices->size())
220 groundIndices = noiseFilteringWithMaxRange<PointT>(cloud, groundIndices, rangeMax_, noiseFilteringRadius_, noiseFilteringMinNeighbors_);
222 if(obstaclesIndices->size())
224 obstaclesIndices = noiseFilteringWithMaxRange<PointT>(cloud, obstaclesIndices, rangeMax_, noiseFilteringRadius_, noiseFilteringMinNeighbors_);
226 if(flatObstacles && (*flatObstacles)->size())
228 *flatObstacles = noiseFilteringWithMaxRange<PointT>(cloud, *flatObstacles, rangeMax_, noiseFilteringRadius_, noiseFilteringMinNeighbors_);
230 UDEBUG(
"Radius filtering end (%ld ground %ld obstacles)",
231 groundIndices->size(),
232 obstaclesIndices->size()+(flatObstacles?(*flatObstacles)->size():0));
234 if(groundIndices->empty() && obstaclesIndices->empty())
236 UWARN(
"Cloud (with %d points) is empty after noise "
237 "filtering. Occupancy grid cannot be "
pcl::PointCloud< PointT >::Ptr segmentCloud(const typename pcl::PointCloud< PointT >::Ptr &cloud, const pcl::IndicesPtr &indices, const Transform &pose, const cv::Point3f &viewPoint, pcl::IndicesPtr &groundIndices, pcl::IndicesPtr &obstaclesIndices, pcl::IndicesPtr *flatObstacles=0) const
Segments a point cloud into ground and obstacle indices.
pcl::IndicesPtr RTABMAP_CORE_EXPORT cropBox(const pcl::PCLPointCloud2::Ptr &cloud, const pcl::IndicesPtr &indices, const Eigen::Vector4f &min, const Eigen::Vector4f &max, const Transform &transform=Transform::getIdentity(), bool negative=false)
Performs crop box filtering on a point cloud of type pcl::PCLPointCloud2 and returns filtered indices...
pcl::IndicesPtr RTABMAP_CORE_EXPORT passThrough(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const pcl::IndicesPtr &indices, const std::string &axis, float min, float max, bool negative=false)
Performs pass-through filtering on a point cloud of type pcl::PointXYZ and returns filtered indices.