Apollo 11.0
自动驾驶开放平台
map_tool.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#include "gflags/gflags.h"
18
19#include "cyber/common/file.h"
20#include "cyber/common/log.h"
23#include "modules/common_msgs/map_msgs/map.pb.h"
24
25DEFINE_double(x_offset, 587318.4866268333, "x offset");
26DEFINE_double(y_offset, 4141146.110116891, "y offset");
27DEFINE_string(output_dir, "/tmp/", "output map directory");
28
30
31static void ShiftMap(Map* map_pb) {
32 for (auto& lane : *(map_pb->mutable_lane())) {
33 for (auto& segment : *(lane.mutable_central_curve()->mutable_segment())) {
34 for (auto& point : *(segment.mutable_line_segment()->mutable_point())) {
35 point.set_x(point.x() + FLAGS_x_offset);
36 point.set_y(point.y() + FLAGS_y_offset);
37 }
38 }
39 for (auto& segment :
40 *(lane.mutable_left_boundary()->mutable_curve()->mutable_segment())) {
41 for (auto& point : *(segment.mutable_line_segment()->mutable_point())) {
42 point.set_x(point.x() + FLAGS_x_offset);
43 point.set_y(point.y() + FLAGS_y_offset);
44 }
45 }
46 for (auto& segment :
47 *(lane.mutable_right_boundary()->mutable_curve()->mutable_segment())) {
48 for (auto& point : *(segment.mutable_line_segment()->mutable_point())) {
49 point.set_x(point.x() + FLAGS_x_offset);
50 point.set_y(point.y() + FLAGS_y_offset);
51 }
52 }
53 }
54 for (auto& stop_sign : *(map_pb->mutable_stop_sign())) {
55 for (auto& stop_line : *(stop_sign.mutable_stop_line())) {
56 for (auto& segment : *(stop_line.mutable_segment())) {
57 for (auto& point : *(segment.mutable_line_segment()->mutable_point())) {
58 point.set_x(point.x() + FLAGS_x_offset);
59 point.set_y(point.y() + FLAGS_y_offset);
60 }
61 }
62 }
63 }
64}
65
66static void OutputMap(const Map& map_pb) {
67 const std::string txt_file = FLAGS_output_dir + "/base_map.txt";
68 const std::string bin_file = FLAGS_output_dir + "/base_map.bin";
71}
72
73int main(int32_t argc, char** argv) {
74 google::InitGoogleLogging(argv[0]);
75 FLAGS_alsologtostderr = true;
76 FLAGS_v = 3;
77
78 google::ParseCommandLineFlags(&argc, &argv, true);
79
80 Map map_pb;
81 const auto map_file = apollo::hdmap::BaseMapFile();
83 << "Fail to open:" << map_file;
84 ShiftMap(&map_pb);
85 OutputMap(map_pb);
86 AINFO << "modified map at:" << FLAGS_output_dir;
87}
#define ACHECK(cond)
Definition log.h:80
#define AINFO
Definition log.h:42
DEFINE_double(x_offset, 587318.4866268333, "x offset")
DEFINE_string(output_dir, "/tmp/", "output map directory")
int main(int32_t argc, char **argv)
Definition map_tool.cc:73
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
std::string BaseMapFile()
get base map file path from flags.
Definition hdmap_util.cc:47