mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
Fixed unknown lines for octomap 2D grid projection. (https://github.com/introlab/rtabmap_ros/issues/684)
This commit is contained in:
@@ -106,6 +106,23 @@ bool RtabmapColorOcTreeNode::createChild(unsigned int i) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void RtabmapColorOcTreeNode::updateOccupancyTypeChildren()
|
||||
{
|
||||
if (children != NULL){
|
||||
int type = kTypeUnknown;
|
||||
for (int i=0; i<8 && type != kTypeObstacle; i++) {
|
||||
RtabmapColorOcTreeNode* child = static_cast<RtabmapColorOcTreeNode*>(children[i]);
|
||||
|
||||
if (child != NULL && child->getOccupancyType() >= kTypeEmpty) {
|
||||
if(type == kTypeUnknown) {
|
||||
type = child->getOccupancyType();
|
||||
}
|
||||
}
|
||||
}
|
||||
type_ = type;
|
||||
}
|
||||
}
|
||||
|
||||
RtabmapColorOcTree::RtabmapColorOcTree(double resolution)
|
||||
: OccupancyOcTreeBase<RtabmapColorOcTreeNode>(resolution) {
|
||||
RtabmapColorOcTreeMemberInit.ensureLinking();
|
||||
@@ -231,6 +248,7 @@ void RtabmapColorOcTree::updateInnerOccupancyRecurs(RtabmapColorOcTreeNode* node
|
||||
}
|
||||
node->updateOccupancyChildren();
|
||||
node->updateColorChildren();
|
||||
node->updateOccupancyTypeChildren();
|
||||
}
|
||||
#else
|
||||
// only recurse and update for inner nodes:
|
||||
@@ -245,6 +263,7 @@ void RtabmapColorOcTree::updateInnerOccupancyRecurs(RtabmapColorOcTreeNode* node
|
||||
}
|
||||
node->updateOccupancyChildren();
|
||||
node->updateColorChildren();
|
||||
node->updateOccupancyTypeChildren();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1209,21 +1228,23 @@ cv::Mat OctoMap::createProjectionMap(float & xMin, float & yMin, float & gridCel
|
||||
int oi=0;
|
||||
cv::Vec2f * oPtr = obstaclesMat.ptr<cv::Vec2f>(0,0);
|
||||
cv::Vec2f * gPtr = groundMat.ptr<cv::Vec2f>(0,0);
|
||||
float halfCellSize = octree_->getNodeSize(treeDepth)/2.0f;
|
||||
for (RtabmapColorOcTree::iterator it = octree_->begin(treeDepth); it != octree_->end(); ++it)
|
||||
{
|
||||
octomap::point3d pt = octree_->keyToCoord(it.getKey());
|
||||
if(octree_->isNodeOccupied(*it) && it->getOccupancyType() == RtabmapColorOcTreeNode::kTypeObstacle)
|
||||
if(octree_->isNodeOccupied(*it) &&
|
||||
it->getOccupancyType() == RtabmapColorOcTreeNode::kTypeObstacle)
|
||||
{
|
||||
// projected on ground
|
||||
oPtr[oi][0] = pt.x();
|
||||
oPtr[oi][1] = pt.y();
|
||||
oPtr[oi][0] = pt.x()-halfCellSize;
|
||||
oPtr[oi][1] = pt.y()-halfCellSize;
|
||||
++oi;
|
||||
}
|
||||
else
|
||||
{
|
||||
// projected on ground
|
||||
gPtr[gi][0] = pt.x();
|
||||
gPtr[gi][1] = pt.y();
|
||||
gPtr[gi][0] = pt.x()-halfCellSize;
|
||||
gPtr[gi][1] = pt.y()-halfCellSize;
|
||||
++gi;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,8 +330,8 @@ cv::Mat create2DMapFromOccupancyLocalMaps(
|
||||
{
|
||||
//Get map size
|
||||
float margin = cellSize*10.0f;
|
||||
xMin = minX-margin;
|
||||
yMin = minY-margin;
|
||||
xMin = minX-margin-cellSize/2.0f;
|
||||
yMin = minY-margin-cellSize/2.0f;
|
||||
float xMax = maxX+margin;
|
||||
float yMax = maxY+margin;
|
||||
if(fabs((yMax - yMin) / cellSize) > 30000 || // Max 1.5Km/1.5Km at 5 cm/cell -> 900MB
|
||||
|
||||
Reference in New Issue
Block a user