Apollo 10.0
自动驾驶开放平台
hdmap_util.h
浏览该文件的文档.
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#pragma once
17
18#include <memory>
19#include <string>
20
21#include "absl/strings/str_cat.h"
22#include "modules/common_msgs/map_msgs/map_id.pb.h"
23#include "modules/common_msgs/planning_msgs/navigation.pb.h"
26
31namespace apollo {
32namespace hdmap {
33
38std::string BaseMapFile();
39
44std::string SimMapFile();
45
50std::string RoutingMapFile();
51
56inline std::string EndWayPointFile() {
57 if (FLAGS_use_navigation_mode) {
58 return absl::StrCat(FLAGS_navigation_mode_end_way_point_file);
59 } else {
60 return absl::StrCat(FLAGS_map_dir, "/", FLAGS_end_way_point_filename);
61 }
62}
63
68inline std::string DefaultRoutingFile() {
69 return absl::StrCat(FLAGS_map_dir, "_", FLAGS_default_routing_filename);
70}
71
76inline std::string ParkGoRoutingFile() {
77 return absl::StrCat(FLAGS_map_dir, "_", FLAGS_park_go_routing_filename);
78}
79
85inline apollo::hdmap::Id MakeMapId(const std::string& id) {
86 apollo::hdmap::Id map_id;
87 map_id.set_id(id);
88 return map_id;
89}
90
91std::unique_ptr<HDMap> CreateMap(const std::string& map_file_path);
92
93class HDMapUtil {
94 public:
95 // Get default base map from the file specified by global flags.
96 // Return nullptr if failed to load.
97 static const HDMap* BaseMapPtr();
98 static const HDMap* BaseMapPtr(const relative_map::MapMsg& map_msg);
99 // Guarantee to return a valid base_map, or else raise fatal error.
100 static const HDMap& BaseMap();
101
102 // Get default sim_map from the file specified by global flags.
103 // Return nullptr if failed to load.
104 static const HDMap* SimMapPtr();
105
106 // Guarantee to return a valid sim_map, or else raise fatal error.
107 static const HDMap& SimMap();
108
109 // Reload maps from the file specified by global flags.
110 static bool ReloadMaps();
111
112 static bool ReloadBaseMap();
113
114 private:
115 HDMapUtil() = delete;
116
117 static std::unique_ptr<HDMap> base_map_;
118 static uint64_t base_map_seq_;
119 static std::mutex base_map_mutex_;
120
121 static std::unique_ptr<HDMap> sim_map_;
122 static std::mutex sim_map_mutex_;
123};
124
125} // namespace hdmap
126} // namespace apollo
static const HDMap * BaseMapPtr()
static const HDMap & BaseMap()
static const HDMap & SimMap()
static bool ReloadBaseMap()
static const HDMap * SimMapPtr()
High-precision map loader interface.
Definition hdmap.h:54
std::unique_ptr< HDMap > CreateMap(const std::string &map_file_path)
Definition hdmap_util.cc:71
std::string DefaultRoutingFile()
get default routing file path from flags.
Definition hdmap_util.h:68
std::string EndWayPointFile()
get end way point file path from flags.
Definition hdmap_util.h:56
apollo::hdmap::Id MakeMapId(const std::string &id)
create a Map ID given a string.
Definition hdmap_util.h:85
std::string SimMapFile()
get simulation map file path from flags.
Definition hdmap_util.cc:56
std::string RoutingMapFile()
get routing map file path from flags.
Definition hdmap_util.cc:63
std::string ParkGoRoutingFile()
get park and go routings file path from flags.
Definition hdmap_util.h:76
std::string BaseMapFile()
get base map file path from flags.
Definition hdmap_util.cc:47
class register implement
Definition arena_queue.h:37