DbViewer: exporting map info in yaml file when exporting 2d occupancy grid (#978)

This commit is contained in:
matlabbe
2023-02-25 17:12:51 -08:00
parent e6e6630d54
commit 70cbe52fcf

View File

@@ -3135,7 +3135,26 @@ void DatabaseViewer::exportSaved2DMap()
path += ".pgm";
}
cv::imwrite(path.toStdString(), map8U);
QMessageBox::information(this, tr("Export 2D map"), tr("Exported %1!").arg(path));
QFileInfo info(path);
QString yaml = info.absolutePath() + "/" + info.baseName() + ".yaml";
float occupancyThr = Parameters::defaultGridGlobalOccupancyThr();
Parameters::parse(ui_->parameters_toolbox->getParameters(), Parameters::kGridGlobalOccupancyThr(), occupancyThr);
std::ofstream file;
file.open (yaml.toStdString());
file << "image: " << info.baseName().toStdString() << ".pgm" << std::endl;
file << "resolution: " << cellSize << std::endl;
file << "origin: [" << xMin << ", " << yMin << ", 0.0]" << std::endl;
file << "negate: 0" << std::endl;
file << "occupied_thresh: " << occupancyThr << std::endl;
file << "free_thresh: 0.196" << std::endl;
file << std::endl;
file.close();
QMessageBox::information(this, tr("Export 2D map"), tr("Exported %1 and %2!").arg(path).arg(yaml));
}
}
}