mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-03 16:27:46 +08:00
Segment ground/obstacles: added max ground height parameter
This commit is contained in:
@@ -27,7 +27,8 @@ void segmentObstaclesFromGround(
|
|||||||
float groundNormalAngle,
|
float groundNormalAngle,
|
||||||
float clusterRadius,
|
float clusterRadius,
|
||||||
int minClusterSize,
|
int minClusterSize,
|
||||||
bool segmentFlatObstacles)
|
bool segmentFlatObstacles,
|
||||||
|
float maxGroundHeight)
|
||||||
{
|
{
|
||||||
ground.reset(new std::vector<int>);
|
ground.reset(new std::vector<int>);
|
||||||
obstacles.reset(new std::vector<int>);
|
obstacles.reset(new std::vector<int>);
|
||||||
@@ -56,21 +57,32 @@ void segmentObstaclesFromGround(
|
|||||||
|
|
||||||
|
|
||||||
// cluster all surfaces for which the centroid is in the Z-range of the bigger surface
|
// cluster all surfaces for which the centroid is in the Z-range of the bigger surface
|
||||||
ground = clusteredFlatSurfaces.at(biggestFlatSurfaceIndex);
|
if(clusteredFlatSurfaces.size())
|
||||||
Eigen::Vector4f min,max;
|
|
||||||
pcl::getMinMax3D(*cloud, *clusteredFlatSurfaces.at(biggestFlatSurfaceIndex), min, max);
|
|
||||||
|
|
||||||
for(unsigned int i=0; i<clusteredFlatSurfaces.size(); ++i)
|
|
||||||
{
|
{
|
||||||
if((int)i!=biggestFlatSurfaceIndex)
|
ground = clusteredFlatSurfaces.at(biggestFlatSurfaceIndex);
|
||||||
|
Eigen::Vector4f min,max;
|
||||||
|
pcl::getMinMax3D(*cloud, *clusteredFlatSurfaces.at(biggestFlatSurfaceIndex), min, max);
|
||||||
|
|
||||||
|
if(maxGroundHeight <= 0 || min[2] < maxGroundHeight)
|
||||||
{
|
{
|
||||||
Eigen::Vector4f centroid;
|
for(unsigned int i=0; i<clusteredFlatSurfaces.size(); ++i)
|
||||||
pcl::compute3DCentroid(*cloud, *clusteredFlatSurfaces.at(i), centroid);
|
|
||||||
if(centroid[2] >= min[2] && centroid[2] <= max[2])
|
|
||||||
{
|
{
|
||||||
ground = util3d::concatenate(ground, clusteredFlatSurfaces.at(i));
|
if((int)i!=biggestFlatSurfaceIndex)
|
||||||
|
{
|
||||||
|
Eigen::Vector4f centroid;
|
||||||
|
pcl::compute3DCentroid(*cloud, *clusteredFlatSurfaces.at(i), centroid);
|
||||||
|
if(centroid[2] >= min[2] && centroid[2] <= max[2])
|
||||||
|
{
|
||||||
|
ground = util3d::concatenate(ground, clusteredFlatSurfaces.at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// reject ground!
|
||||||
|
ground.reset(new std::vector<int>);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -105,7 +117,8 @@ void segmentObstaclesFromGround(
|
|||||||
float groundNormalAngle,
|
float groundNormalAngle,
|
||||||
float clusterRadius,
|
float clusterRadius,
|
||||||
int minClusterSize,
|
int minClusterSize,
|
||||||
bool segmentFlatObstacles)
|
bool segmentFlatObstacles,
|
||||||
|
float maxGroundHeight)
|
||||||
{
|
{
|
||||||
pcl::IndicesPtr indices(new std::vector<int>);
|
pcl::IndicesPtr indices(new std::vector<int>);
|
||||||
segmentObstaclesFromGround<PointT>(
|
segmentObstaclesFromGround<PointT>(
|
||||||
@@ -117,7 +130,8 @@ void segmentObstaclesFromGround(
|
|||||||
groundNormalAngle,
|
groundNormalAngle,
|
||||||
clusterRadius,
|
clusterRadius,
|
||||||
minClusterSize,
|
minClusterSize,
|
||||||
segmentFlatObstacles);
|
segmentFlatObstacles,
|
||||||
|
maxGroundHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PointT>
|
template<typename PointT>
|
||||||
@@ -128,7 +142,9 @@ void occupancy2DFromCloud3D(
|
|||||||
cv::Mat & obstacles,
|
cv::Mat & obstacles,
|
||||||
float cellSize,
|
float cellSize,
|
||||||
float groundNormalAngle,
|
float groundNormalAngle,
|
||||||
int minClusterSize)
|
int minClusterSize,
|
||||||
|
bool segmentFlatObstacles,
|
||||||
|
float maxGroundHeight)
|
||||||
{
|
{
|
||||||
if(cloud->size() == 0)
|
if(cloud->size() == 0)
|
||||||
{
|
{
|
||||||
@@ -144,7 +160,9 @@ void occupancy2DFromCloud3D(
|
|||||||
20,
|
20,
|
||||||
groundNormalAngle,
|
groundNormalAngle,
|
||||||
cellSize*2.0f,
|
cellSize*2.0f,
|
||||||
minClusterSize);
|
minClusterSize,
|
||||||
|
segmentFlatObstacles,
|
||||||
|
maxGroundHeight);
|
||||||
|
|
||||||
pcl::PointCloud<pcl::PointXYZ>::Ptr groundCloud(new pcl::PointCloud<pcl::PointXYZ>);
|
pcl::PointCloud<pcl::PointXYZ>::Ptr groundCloud(new pcl::PointCloud<pcl::PointXYZ>);
|
||||||
pcl::PointCloud<pcl::PointXYZ>::Ptr obstaclesCloud(new pcl::PointCloud<pcl::PointXYZ>);
|
pcl::PointCloud<pcl::PointXYZ>::Ptr obstaclesCloud(new pcl::PointCloud<pcl::PointXYZ>);
|
||||||
@@ -197,10 +215,12 @@ void occupancy2DFromCloud3D(
|
|||||||
cv::Mat & obstacles,
|
cv::Mat & obstacles,
|
||||||
float cellSize,
|
float cellSize,
|
||||||
float groundNormalAngle,
|
float groundNormalAngle,
|
||||||
int minClusterSize)
|
int minClusterSize,
|
||||||
|
bool segmentFlatObstacles,
|
||||||
|
float maxGroundHeight)
|
||||||
{
|
{
|
||||||
pcl::IndicesPtr indices(new std::vector<int>);
|
pcl::IndicesPtr indices(new std::vector<int>);
|
||||||
occupancy2DFromCloud3D<PointT>(cloud, indices, ground, obstacles, cellSize, groundNormalAngle, minClusterSize);
|
occupancy2DFromCloud3D<PointT>(cloud, indices, ground, obstacles, cellSize, groundNormalAngle, minClusterSize, segmentFlatObstacles, maxGroundHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ void segmentObstaclesFromGround(
|
|||||||
float groundNormalAngle,
|
float groundNormalAngle,
|
||||||
float clusterRadius,
|
float clusterRadius,
|
||||||
int minClusterSize,
|
int minClusterSize,
|
||||||
bool segmentFlatObstacles = false);
|
bool segmentFlatObstacles = false,
|
||||||
|
float maxGroundHeight = 0.0f);
|
||||||
template<typename PointT>
|
template<typename PointT>
|
||||||
void segmentObstaclesFromGround(
|
void segmentObstaclesFromGround(
|
||||||
const typename pcl::PointCloud<PointT>::Ptr & cloud,
|
const typename pcl::PointCloud<PointT>::Ptr & cloud,
|
||||||
@@ -100,7 +101,8 @@ void segmentObstaclesFromGround(
|
|||||||
float groundNormalAngle,
|
float groundNormalAngle,
|
||||||
float clusterRadius,
|
float clusterRadius,
|
||||||
int minClusterSize,
|
int minClusterSize,
|
||||||
bool segmentFlatObstacles = false);
|
bool segmentFlatObstacles = false,
|
||||||
|
float maxGroundHeight = 0.0f);
|
||||||
|
|
||||||
template<typename PointT>
|
template<typename PointT>
|
||||||
void occupancy2DFromCloud3D(
|
void occupancy2DFromCloud3D(
|
||||||
@@ -109,7 +111,9 @@ void occupancy2DFromCloud3D(
|
|||||||
cv::Mat & obstacles,
|
cv::Mat & obstacles,
|
||||||
float cellSize = 0.05f,
|
float cellSize = 0.05f,
|
||||||
float groundNormalAngle = M_PI_4,
|
float groundNormalAngle = M_PI_4,
|
||||||
int minClusterSize = 20);
|
int minClusterSize = 20,
|
||||||
|
bool segmentFlatObstacles = false,
|
||||||
|
float maxGroundHeight = 0.0f);
|
||||||
template<typename PointT>
|
template<typename PointT>
|
||||||
void occupancy2DFromCloud3D(
|
void occupancy2DFromCloud3D(
|
||||||
const typename pcl::PointCloud<PointT>::Ptr & cloud,
|
const typename pcl::PointCloud<PointT>::Ptr & cloud,
|
||||||
@@ -118,7 +122,9 @@ void occupancy2DFromCloud3D(
|
|||||||
cv::Mat & obstacles,
|
cv::Mat & obstacles,
|
||||||
float cellSize = 0.05f,
|
float cellSize = 0.05f,
|
||||||
float groundNormalAngle = M_PI_4,
|
float groundNormalAngle = M_PI_4,
|
||||||
int minClusterSize = 20);
|
int minClusterSize = 20,
|
||||||
|
bool segmentFlatObstacles = false,
|
||||||
|
float maxGroundHeight = 0.0f);
|
||||||
|
|
||||||
} // namespace util3d
|
} // namespace util3d
|
||||||
} // namespace rtabmap
|
} // namespace rtabmap
|
||||||
|
|||||||
Reference in New Issue
Block a user