39 const typename pcl::PointCloud<PointT>::Ptr & cloudIn,
40 const pcl::IndicesPtr & indicesIn,
42 const cv::Point3f & viewPoint,
43 pcl::IndicesPtr & groundIndices,
44 pcl::IndicesPtr & obstaclesIndices,
45 pcl::IndicesPtr * flatObstacles)
const
47 groundIndices.reset(
new std::vector<int>);
48 obstaclesIndices.reset(
new std::vector<int>);
51 flatObstacles->reset(
new std::vector<int>);
61 typename pcl::PointCloud<PointT>::Ptr cloud(
new pcl::PointCloud<PointT>);
62 pcl::IndicesPtr indices(
new std::vector<int>);
64 if(preVoxelFiltering_)
69 indices->resize(cloud->size());
70 for(
unsigned int i=0; i<indices->size(); ++i)
78 if(indicesIn->empty() && cloud->is_dense)
80 indices->resize(cloud->size());
81 for(
unsigned int i=0; i<indices->size(); ++i)
98 float roll, pitch, yaw;
100 UDEBUG(
"node.getPose()=%s projMapFrame_=%d", pose.
prettyPrint().c_str(), projMapFrame_?1:0);
104 if(footprintLength_ > 0.0f || footprintWidth_ > 0.0f || footprintHeight_ > 0.0f)
110 footprintLength_>0.0f?-footprintLength_/2.0f:std::numeric_limits<int>::min(),
111 footprintWidth_>0.0f&&footprintLength_>0.0f?-footprintWidth_/2.0f:std::numeric_limits<int>::min(),
115 footprintLength_>0.0f?footprintLength_/2.0f:std::numeric_limits<int>::max(),
116 footprintWidth_>0.0f&&footprintLength_>0.0f?footprintWidth_/2.0f:std::numeric_limits<int>::max(),
117 footprintHeight_>0.0f&&footprintLength_>0.0f&&footprintWidth_>0.0f?footprintHeight_:std::numeric_limits<int>::max(),
124 if(minGroundHeight_ != 0.0f || maxObstacleHeight_ != 0.0f)
127 minGroundHeight_!=0.0f?minGroundHeight_:std::numeric_limits<int>::min(),
128 maxObstacleHeight_>0.0f?maxObstacleHeight_:std::numeric_limits<int>::max());
129 UDEBUG(
"indices after max obstacles height filtering = %d", (
int)indices->size());
134 if(normalsSegmentation_ && !groundIsObstacle_)
136 UDEBUG(
"normalKSearch=%d", normalKSearch_);
137 UDEBUG(
"maxGroundAngle=%f", maxGroundAngle_);
138 UDEBUG(
"Cluster radius=%f", clusterRadius_);
139 UDEBUG(
"flatObstaclesDetected=%d", flatObstaclesDetected_?1:0);
140 UDEBUG(
"maxGroundHeight=%f", maxGroundHeight_);
141 UDEBUG(
"groundNormalsUp=%f", groundNormalsUp_);
142 util3d::segmentObstaclesFromGround<PointT>(
151 flatObstaclesDetected_,
154 Eigen::Vector4f(viewPoint.x, viewPoint.y, viewPoint.z+(projMapFrame_?pose.
z():0), 1),
156 UDEBUG(
"viewPoint=%f,%f,%f", viewPoint.x, viewPoint.y, viewPoint.z+(projMapFrame_?pose.
z():0));
166 minGroundHeight_!=0.0f?minGroundHeight_:std::numeric_limits<int>::min(),
167 maxGroundHeight_!=0.0f?maxGroundHeight_:std::numeric_limits<int>::max());
169 pcl::IndicesPtr notObstacles = groundIndices;
178 UDEBUG(
"groundIndices=%d obstaclesIndices=%d", (
int)groundIndices->size(), (
int)obstaclesIndices->size());
181 if(noiseFilteringRadius_ > 0.0 && noiseFilteringMinNeighbors_ > 0)
183 UDEBUG(
"Radius filtering (%ld ground %ld obstacles, radius=%f k=%d)",
184 groundIndices->size(),
185 obstaclesIndices->size()+(flatObstacles?(*flatObstacles)->size():0),
186 noiseFilteringRadius_,
187 noiseFilteringMinNeighbors_);
188 if(groundIndices->size())
190 pcl::IndicesPtr farIndices;
194 pcl::IndicesPtr closeIndices;
196 groundIndices = closeIndices;
204 if(obstaclesIndices->size())
206 pcl::IndicesPtr farIndices;
210 pcl::IndicesPtr closeIndices;
212 obstaclesIndices = closeIndices;
220 if(flatObstacles && (*flatObstacles)->size())
222 pcl::IndicesPtr farIndices;
226 pcl::IndicesPtr closeIndices;
228 *flatObstacles = closeIndices;
236 UDEBUG(
"Radius filtering end (%ld ground %ld obstacles)",
237 groundIndices->size(),
238 obstaclesIndices->size()+(flatObstacles?(*flatObstacles)->size():0));
240 if(groundIndices->empty() && obstaclesIndices->empty())
242 UWARN(
"Cloud (with %d points) is empty after noise "
243 "filtering. Occupancy grid cannot be "