63 {
64 if (absl::EndsWith(base_map_file_path_, ".xml")) {
66 &pbmap_)) {
67 AERROR <<
"Failed to load base map file from " << base_map_file_path_;
68 return false;
69 }
70 } else {
72 AERROR <<
"Failed to load base map file from " << base_map_file_path_;
73 return false;
74 }
75 }
76
77 AINFO <<
"Number of lanes: " << pbmap_.lane_size();
78
81
82 node_index_map_.clear();
83 road_id_map_.clear();
84 showed_edge_id_set_.clear();
85
86 for (const auto& road : pbmap_.road()) {
87 for (const auto& section : road.section()) {
88 for (const auto& lane_id : section.lane_id()) {
89 road_id_map_[lane_id.id()] = road.id().id();
90 }
91 }
92 }
93
94 InitForbiddenLanes();
95 const double min_turn_radius =
97
98 for (const auto& lane : pbmap_.lane()) {
99 const auto& lane_id = lane.id().id();
100 if (forbidden_lane_id_set_.find(lane_id) != forbidden_lane_id_set_.end()) {
101 ADEBUG <<
"Ignored lane id: " << lane_id
102 << " because its type is NOT CITY_DRIVING.";
103 continue;
104 }
106 !IsValidUTurn(lane, min_turn_radius)) {
107 ADEBUG <<
"The u-turn lane radius is too small for the vehicle to turn";
108 continue;
109 }
110 AINFO <<
"Current lane id: " << lane_id;
111 node_index_map_[lane_id] = graph_.node_size();
112 const auto iter = road_id_map_.find(lane_id);
113 if (iter != road_id_map_.end()) {
115 graph_.add_node());
116 } else {
117 AWARN <<
"Failed to find road id of lane " << lane_id;
119 }
120 }
121
122 for (const auto& lane : pbmap_.lane()) {
123 const auto& lane_id = lane.id().id();
124 if (forbidden_lane_id_set_.find(lane_id) != forbidden_lane_id_set_.end()) {
125 ADEBUG <<
"Ignored lane id: " << lane_id
126 << " because its type is NOT CITY_DRIVING.";
127 continue;
128 }
129 const auto& from_node = graph_.
node(node_index_map_[lane_id]);
130
132 if (lane.length() < FLAGS_min_length_for_lane_change) {
133 continue;
134 }
135 if (lane.has_left_boundary() && IsAllowedToCross(lane.left_boundary())) {
136 AddEdge(from_node, lane.left_neighbor_forward_lane_id(),
Edge::LEFT);
137 }
138
139 if (lane.has_right_boundary() && IsAllowedToCross(lane.right_boundary())) {
140 AddEdge(from_node, lane.right_neighbor_forward_lane_id(),
Edge::RIGHT);
141 }
142 }
143
144 if (!absl::EndsWith(dump_topo_file_path_, ".bin") &&
145 !absl::EndsWith(dump_topo_file_path_, ".txt")) {
146 AERROR <<
"Failed to dump topo data into file, incorrect file type "
147 << dump_topo_file_path_;
148 return false;
149 }
150 auto type_pos = dump_topo_file_path_.find_last_of(".") + 1;
151 std::string bin_file = dump_topo_file_path_.replace(type_pos, 3, "bin");
152 std::string txt_file = dump_topo_file_path_.replace(type_pos, 3, "txt");
154 AERROR <<
"Failed to dump topo data into file " << txt_file;
155 return false;
156 }
157 AINFO <<
"Txt file is dumped successfully. Path: " << txt_file;
159 AERROR <<
"Failed to dump topo data into file " << bin_file;
160 return false;
161 }
162 AINFO <<
"Bin file is dumped successfully. Path: " << bin_file;
163 return true;
164}
static const VehicleConfig & GetConfig()
Get the current vehicle configuration.
static bool LoadData(const std::string &filename, apollo::hdmap::Map *pb_map)
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,...
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 ...
bool SetProtoToASCIIFile(const google::protobuf::Message &message, int file_descriptor)
void GetPbNode(const hdmap::Lane &lane, const std::string &road_id, const RoutingConfig &routingconfig, Node *const node)
optional VehicleParam vehicle_param
optional double min_turn_radius