Apollo  6.0
Open source self driving car software
hdmap_util.h
Go to the documentation of this file.
1 /* Copyright 2017 The Apollo Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7  http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 =========================================================================*/
15 
16 #pragma once
17 
18 #include <memory>
19 #include <string>
20 
21 #include "absl/strings/str_cat.h"
24 #include "modules/map/proto/map_id.pb.h"
25 #include "modules/map/relative_map/proto/navigation.pb.h"
26 
31 namespace apollo {
32 namespace hdmap {
33 
38 std::string BaseMapFile();
39 
44 std::string SimMapFile();
45 
50 std::string RoutingMapFile();
51 
56 inline 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 
68 inline std::string DefaultRoutingFile() {
69  return absl::StrCat(FLAGS_map_dir, "_", FLAGS_default_routing_filename);
70 }
71 
77 inline apollo::hdmap::Id MakeMapId(const std::string& id) {
78  apollo::hdmap::Id map_id;
79  map_id.set_id(id);
80  return map_id;
81 }
82 
83 std::unique_ptr<HDMap> CreateMap(const std::string& map_file_path);
84 
85 class HDMapUtil {
86  public:
87  // Get default base map from the file specified by global flags.
88  // Return nullptr if failed to load.
89  static const HDMap* BaseMapPtr();
90  static const HDMap* BaseMapPtr(const relative_map::MapMsg& map_msg);
91  // Guarantee to return a valid base_map, or else raise fatal error.
92  static const HDMap& BaseMap();
93 
94  // Get default sim_map from the file specified by global flags.
95  // Return nullptr if failed to load.
96  static const HDMap* SimMapPtr();
97 
98  // Guarantee to return a valid sim_map, or else raise fatal error.
99  static const HDMap& SimMap();
100 
101  // Reload maps from the file specified by global flags.
102  static bool ReloadMaps();
103 
104  private:
105  HDMapUtil() = delete;
106 
107  static std::unique_ptr<HDMap> base_map_;
108  static uint64_t base_map_seq_;
109  static std::mutex base_map_mutex_;
110 
111  static std::unique_ptr<HDMap> sim_map_;
112  static std::mutex sim_map_mutex_;
113 };
114 
115 } // namespace hdmap
116 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::string EndWayPointFile()
get end way point file path from flags.
Definition: hdmap_util.h:56
static bool ReloadMaps()
std::string BaseMapFile()
get base map file path from flags.
apollo::hdmap::Id MakeMapId(const std::string &id)
create a Map ID given a string.
Definition: hdmap_util.h:77
static const HDMap * SimMapPtr()
static const HDMap * BaseMapPtr()
std::string SimMapFile()
get simulation map file path from flags.
static const HDMap & BaseMap()
static const HDMap & SimMap()
std::string RoutingMapFile()
get routing map file path from flags.
High-precision map loader interface.
Definition: hdmap.h:53
std::string DefaultRoutingFile()
get default routing file path from flags.
Definition: hdmap_util.h:68
std::unique_ptr< HDMap > CreateMap(const std::string &map_file_path)
Definition: hdmap_util.h:85