Apollo 11.0
自动驾驶开放平台
bin_map_generator.cc
浏览该文件的文档.
1/* Copyright 2017 The Apollo Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14=========================================================================*/
15
16#include "gflags/gflags.h"
17
18#include "modules/common_msgs/map_msgs/map.pb.h"
19
20#include "cyber/common/file.h"
21#include "cyber/common/log.h"
23
28DEFINE_string(output_dir, "/tmp", "output map directory");
29
30int main(int argc, char *argv[]) {
31 google::InitGoogleLogging(argv[0]);
32 FLAGS_alsologtostderr = true;
33
34 google::ParseCommandLineFlags(&argc, &argv, true);
35
36 const auto map_filename = FLAGS_map_dir + "/base_map.txt";
37 apollo::hdmap::Map pb_map;
38 if (!apollo::cyber::common::GetProtoFromFile(map_filename, &pb_map)) {
39 AERROR << "Failed to load txt map from " << map_filename;
40 return -1;
41 } else {
42 AINFO << "Loaded txt map from " << map_filename;
43 }
44
45 const std::string output_bin_file = FLAGS_output_dir + "/base_map.bin";
46 if (!apollo::cyber::common::SetProtoToBinaryFile(pb_map, output_bin_file)) {
47 AERROR << "Failed to generate binary base map";
48 return -1;
49 }
50
51 pb_map.Clear();
52 ACHECK(apollo::cyber::common::GetProtoFromFile(output_bin_file, &pb_map))
53 << "Failed to load generated binary base map";
54
55 AINFO << "Successfully converted .txt map to .bin map: " << output_bin_file;
56
57 return 0;
58}
int main(int argc, char *argv[])
DEFINE_string(output_dir, "/tmp", "output map directory")
A map tool to transform .txt map to .bin map
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
bool SetProtoToBinaryFile(const google::protobuf::Message &message, const std::string &file_name)
Sets the content of the file specified by the file_name to be the binary representation of the input ...
Definition file.cc:111