Fixed holes in 2d occupancy grids created from scans. Fixed grid map in 3D view not updated.

This commit is contained in:
matlabbe
2016-08-26 16:32:09 -04:00
parent e93ef025a1
commit 5542918b04
2 changed files with 6 additions and 6 deletions

View File

@@ -88,10 +88,10 @@ void occupancy2DFromLaserScan(
int i=0; int i=0;
for(std::list<int>::iterator iter=groundIndices.begin();iter!=groundIndices.end(); ++iter) for(std::list<int>::iterator iter=groundIndices.begin();iter!=groundIndices.end(); ++iter)
{ {
int x = *iter / map8S.cols; int y = *iter / map8S.cols;
int y = *iter - x*map8S.cols; int x = *iter - y*map8S.cols;
ground.at<cv::Vec2f>(i)[0] = (float(y)+0.5)*cellSize + xMin; ground.at<cv::Vec2f>(i)[0] = (float(x))*cellSize + xMin;
ground.at<cv::Vec2f>(i)[1] = (float(x)+0.5)*cellSize + yMin; ground.at<cv::Vec2f>(i)[1] = (float(y))*cellSize + yMin;
++i; ++i;
} }
} }

View File

@@ -1148,9 +1148,9 @@ bool CloudViewer::addOccupancyGridMap(
float ySize = float(map8U.rows) * resolution; float ySize = float(map8U.rows) * resolution;
UDEBUG("resolution=%f, xSize=%f, ySize=%f, xMin=%f, yMin=%f", resolution, xSize, ySize, xMin, yMin); UDEBUG("resolution=%f, xSize=%f, ySize=%f, xMin=%f, yMin=%f", resolution, xSize, ySize, xMin, yMin);
if(_visualizer->getCloudActorMap()->find("map") == _visualizer->getCloudActorMap()->end()) if(_visualizer->getCloudActorMap()->find("map") != _visualizer->getCloudActorMap()->end())
{ {
_visualizer->removeShape("map"); _visualizer->removePointCloud("map");
} }
if(xSize > 0.0f && ySize > 0.0f) if(xSize > 0.0f && ySize > 0.0f)