Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <sstream>
00018
00019 #include "cartographer/io/proto_stream.h"
00020 #include "cartographer/io/serialization_format_migration.h"
00021 #include "gflags/gflags.h"
00022 #include "glog/logging.h"
00023
00024 DEFINE_bool(migrate_grid_format, false,
00025 "Set if the submap data of the input pbstream uses the old "
00026 "probability grid format.");
00027
00028 namespace cartographer {
00029 namespace io {
00030
00031 int pbstream_migrate(int argc, char** argv) {
00032 std::stringstream ss;
00033 ss << "\n\nTool for migrating files that use the serialization output of "
00034 "Cartographer 0.3, to the new serialization format, which includes a "
00035 "header (Version 1). You may need to specify the '--migrate_grid_format"
00036 " flag if the input file contains submaps with the legacy grid format."
00037 << "\nUsage: " << argv[0] << " " << argv[1]
00038 << " <input_filename> <output_filename> [flags]";
00039 google::SetUsageMessage(ss.str());
00040
00041 if (argc < 4) {
00042 google::ShowUsageWithFlagsRestrict(argv[0], "pbstream_migrate");
00043 return EXIT_FAILURE;
00044 }
00045 cartographer::io::ProtoStreamReader input(argv[2]);
00046 cartographer::io::ProtoStreamWriter output(argv[3]);
00047 LOG(INFO) << "Migrating old serialization format in \"" << argv[2]
00048 << "\" to new serialization format in \"" << argv[3] << "\"";
00049 cartographer::io::MigrateStreamFormatToVersion1(&input, &output,
00050 FLAGS_migrate_grid_format);
00051 CHECK(output.Close()) << "Could not write migrated pbstream file to: "
00052 << argv[3];
00053
00054 return EXIT_SUCCESS;
00055 }
00056
00057 }
00058 }