Apollo 11.0
自动驾驶开放平台
proto_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 "cyber/common/file.h"
19#include "cyber/common/log.h"
22#include "modules/common_msgs/map_msgs/map.pb.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.xml";
37 apollo::hdmap::Map pb_map;
38 ACHECK(
40 << "fail to load data from : " << map_filename;
41
42 const std::string output_ascii_file = FLAGS_output_dir + "/base_map.txt";
43 ACHECK(apollo::cyber::common::SetProtoToASCIIFile(pb_map, output_ascii_file))
44 << "failed to output ASCII format base map";
45
46 const std::string output_bin_file = FLAGS_output_dir + "/base_map.bin";
48 << "failed to output binary format base map";
49
50 pb_map.Clear();
51 ACHECK(apollo::cyber::common::GetProtoFromFile(output_bin_file, &pb_map))
52 << "failed to load map";
53
54 AINFO << "load map success";
55
56 return 0;
57}
static bool LoadData(const std::string &filename, apollo::hdmap::Map *pb_map)
#define ACHECK(cond)
Definition log.h:80
#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
bool SetProtoToASCIIFile(const google::protobuf::Message &message, int file_descriptor)
Definition file.cc:43
DEFINE_string(output_dir, "/tmp", "output map directory")
A map tool to transform opendrive map to pb map
int main(int argc, char **argv)