Apollo  6.0
Open source self driving car software
graph_creator.h
Go to the documentation of this file.
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 #pragma once
18 
19 #include <string>
20 #include <unordered_map>
21 #include <unordered_set>
22 
23 #include "modules/map/proto/map.pb.h"
24 #include "modules/routing/proto/routing_config.pb.h"
25 #include "modules/routing/proto/topo_graph.pb.h"
26 
27 namespace apollo {
28 namespace routing {
29 
30 class GraphCreator {
31  public:
32  GraphCreator(const std::string& base_map_file_path,
33  const std::string& dump_topo_file_path,
34  const RoutingConfig& routing_conf);
35 
36  ~GraphCreator() = default;
37 
38  bool Create();
39 
40  private:
41  void InitForbiddenLanes();
42  std::string GetEdgeID(const std::string& from_id, const std::string& to_id);
43 
44  void AddEdge(
45  const Node& from_node,
46  const ::google::protobuf::RepeatedPtrField<hdmap::Id>& to_node_vec,
47  const Edge::DirectionType& type);
48 
49  static bool IsValidUTurn(const hdmap::Lane& lane, const double radius);
50 
51  private:
52  std::string base_map_file_path_;
53  std::string dump_topo_file_path_;
54  hdmap::Map pbmap_;
55  Graph graph_;
56  std::unordered_map<std::string, int> node_index_map_;
57  std::unordered_map<std::string, std::string> road_id_map_;
58  std::unordered_set<std::string> showed_edge_id_set_;
59  std::unordered_set<std::string> forbidden_lane_id_set_;
60 
61  const RoutingConfig& routing_conf_;
62 };
63 
64 } // namespace routing
65 } // namespace apollo
Definition: node.h:31
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
GraphCreator(const std::string &base_map_file_path, const std::string &dump_topo_file_path, const RoutingConfig &routing_conf)
Definition: graph_creator.h:30