Skip to content

Commit

Permalink
DbViewer: exporting map info in yaml file when exporting 2d occupancy…
Browse files Browse the repository at this point in the history
… grid (#978)
  • Loading branch information
matlabbe committed Feb 26, 2023
1 parent e6e6630 commit 70cbe52
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion guilib/src/DatabaseViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down

0 comments on commit 70cbe52

Please sign in to comment.