21 void WritePgm(const ::cartographer::io::Image& image,
const double resolution,
23 const std::string
header =
"P5\n# Cartographer map; " +
24 std::to_string(resolution) +
" m/pixel\n" +
25 std::to_string(image.width()) +
" " +
26 std::to_string(image.height()) +
"\n255\n";
27 file_writer->
Write(header.data(), header.size());
28 for (
int y = 0; y < image.height(); ++y) {
29 for (
int x = 0; x < image.width(); ++x) {
30 const char color = image.GetPixel(x, y)[0];
31 file_writer->
Write(&color, 1);
36 void WriteYaml(
const double resolution,
const Eigen::Vector2d& origin,
37 const std::string& pgm_filename,
41 const std::string output =
42 "image: " + pgm_filename +
"\n" +
43 "resolution: " + std::to_string(resolution) +
"\n" +
"origin: [" +
44 std::to_string(origin.x()) +
", " + std::to_string(origin.y()) +
45 ", 0.0]\nnegate: 0\noccupied_thresh: 0.65\nfree_thresh: 0.196\n";
46 file_writer->
Write(output.data(), output.size());
void WriteYaml(const double resolution, const Eigen::Vector2d &origin, const std::string &pgm_filename, ::cartographer::io::FileWriter *file_writer)
void WritePgm(const ::cartographer::io::Image &image, const double resolution, ::cartographer::io::FileWriter *file_writer)
virtual bool Write(const char *data, size_t len)=0