pbstream_migrate.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 }  // namespace io
00058 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35