Apollo 10.0
自动驾驶开放平台
edge_creator.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
18
19#include <cmath>
20
21namespace apollo {
22namespace routing {
23namespace edge_creator {
24
25void GetPbEdge(const Node& node_from, const Node& node_to,
26 const Edge::DirectionType& type,
27 const RoutingConfig& routing_config, Edge* edge) {
28 edge->set_from_lane_id(node_from.lane_id());
29 edge->set_to_lane_id(node_to.lane_id());
30 edge->set_direction_type(type);
31
32 edge->set_cost(0.0);
33 if (type == Edge::LEFT || type == Edge::RIGHT) {
34 const auto& target_range =
35 (type == Edge::LEFT) ? node_from.left_out() : node_from.right_out();
36 double changing_area_length = 0.0;
37 for (const auto& range : target_range) {
38 changing_area_length += range.end().s() - range.start().s();
39 }
40 double ratio = 1.0;
41 if (changing_area_length < routing_config.base_changing_length()) {
42 ratio = std::pow(
43 changing_area_length / routing_config.base_changing_length(), -1.5);
44 }
45 edge->set_cost(routing_config.change_penalty() * ratio);
46 }
47}
48
49} // namespace edge_creator
50} // namespace routing
51} // namespace apollo
void GetPbEdge(const Node &node_from, const Node &node_to, const Edge::DirectionType &type, const RoutingConfig &routing_config, Edge *edge)
class register implement
Definition arena_queue.h:37
optional CurvePoint end
repeated CurveRange left_out
optional string lane_id
repeated CurveRange right_out