Apollo 10.0
自动驾驶开放平台
topo_test_utils.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
19namespace apollo {
20namespace routing {
21
22namespace {
23
25
26void AddCurve(Curve* curve) {
27 auto* curve_segment = curve->add_segment();
28 curve_segment->set_s(TEST_START_S);
29 curve_segment->mutable_start_position()->set_x(0.0);
30 curve_segment->mutable_start_position()->set_y(0.0);
31 curve_segment->set_heading(0.0);
32 curve_segment->set_length(TEST_LANE_LENGTH);
33 auto* lane_segment = curve_segment->mutable_line_segment();
34 auto* point1 = lane_segment->add_point();
35 point1->set_x(TEST_START_S);
36 point1->set_y(0.0);
37 auto* point21 = lane_segment->add_point();
38 point21->set_x(TEST_MIDDLE_S / 2);
39 point21->set_y(0.0);
40 auto* point2 = lane_segment->add_point();
41 point2->set_x(TEST_MIDDLE_S);
42 point2->set_y(0.0);
43 auto* point22 = lane_segment->add_point();
44 point22->set_x(TEST_MIDDLE_S + TEST_MIDDLE_S / 2);
45 point22->set_y(0.0);
46 auto* point3 = lane_segment->add_point();
47 point3->set_x(TEST_END_S);
48 point3->set_y(0.0);
49}
50
51} // namespace
52
53void GetNodeDetailForTest(Node* const node, const std::string& lane_id,
54 const std::string& road_id) {
55 node->set_lane_id(lane_id);
56 node->set_length(TEST_LANE_LENGTH);
57 node->set_road_id(road_id);
58 node->set_cost(TEST_LANE_COST);
59 AddCurve(node->mutable_central_curve());
60 auto* left_out = node->add_left_out();
61 left_out->mutable_start()->set_s(TEST_START_S);
62 left_out->mutable_end()->set_s(TEST_END_S);
63 auto* right_out = node->add_right_out();
64 right_out->mutable_start()->set_s(TEST_START_S);
65 right_out->mutable_end()->set_s(TEST_END_S);
66}
67
68void GetNodeForTest(Node* const node, const std::string& lane_id,
69 const std::string& road_id) {
70 node->set_lane_id(lane_id);
71 node->set_length(TEST_LANE_LENGTH);
72 node->set_road_id(road_id);
73 node->set_cost(TEST_LANE_COST);
74 auto* left_out = node->add_left_out();
75 left_out->mutable_start()->set_s(TEST_START_S);
76 left_out->mutable_end()->set_s(TEST_END_S);
77 auto* right_out = node->add_right_out();
78 right_out->mutable_start()->set_s(TEST_START_S);
79 right_out->mutable_end()->set_s(TEST_END_S);
80}
81
82void GetEdgeForTest(Edge* const edge, const std::string& lane_id_1,
83 const std::string& lane_id_2,
84 const Edge::DirectionType& type) {
85 edge->set_from_lane_id(lane_id_1);
86 edge->set_to_lane_id(lane_id_2);
87 edge->set_cost(TEST_EDGE_COST);
88 edge->set_direction_type(type);
89}
90
91void GetGraphForTest(Graph* graph) {
92 graph->set_hdmap_version(TEST_MAP_VERSION);
93 graph->set_hdmap_district(TEST_MAP_DISTRICT);
94 GetNodeForTest(graph->add_node(), TEST_L1, TEST_R1);
95 GetNodeForTest(graph->add_node(), TEST_L2, TEST_R1);
96 GetNodeForTest(graph->add_node(), TEST_L3, TEST_R2);
97 GetNodeForTest(graph->add_node(), TEST_L4, TEST_R2);
98
99 GetEdgeForTest(graph->add_edge(), TEST_L1, TEST_L2, Edge::RIGHT);
100 GetEdgeForTest(graph->add_edge(), TEST_L2, TEST_L1, Edge::LEFT);
101 GetEdgeForTest(graph->add_edge(), TEST_L3, TEST_L4, Edge::RIGHT);
102 GetEdgeForTest(graph->add_edge(), TEST_L4, TEST_L3, Edge::LEFT);
103 GetEdgeForTest(graph->add_edge(), TEST_L1, TEST_L3, Edge::FORWARD);
104 GetEdgeForTest(graph->add_edge(), TEST_L2, TEST_L4, Edge::FORWARD);
105}
106
108 graph->set_hdmap_version(TEST_MAP_VERSION);
109 graph->set_hdmap_district(TEST_MAP_DISTRICT);
110 GetNodeForTest(graph->add_node(), TEST_L1, TEST_R1);
111 GetNodeForTest(graph->add_node(), TEST_L2, TEST_R1);
112 GetNodeForTest(graph->add_node(), TEST_L3, TEST_R2);
113 GetNodeForTest(graph->add_node(), TEST_L4, TEST_R2);
114 GetNodeForTest(graph->add_node(), TEST_L5, TEST_R2);
115 GetNodeForTest(graph->add_node(), TEST_L6, TEST_R3);
116
117 GetEdgeForTest(graph->add_edge(), TEST_L1, TEST_L2, Edge::RIGHT);
118 GetEdgeForTest(graph->add_edge(), TEST_L2, TEST_L1, Edge::LEFT);
119 GetEdgeForTest(graph->add_edge(), TEST_L3, TEST_L4, Edge::RIGHT);
120 GetEdgeForTest(graph->add_edge(), TEST_L4, TEST_L3, Edge::LEFT);
121 GetEdgeForTest(graph->add_edge(), TEST_L4, TEST_L5, Edge::RIGHT);
122 GetEdgeForTest(graph->add_edge(), TEST_L5, TEST_L4, Edge::LEFT);
123 GetEdgeForTest(graph->add_edge(), TEST_L1, TEST_L3, Edge::FORWARD);
124 GetEdgeForTest(graph->add_edge(), TEST_L2, TEST_L4, Edge::FORWARD);
125 GetEdgeForTest(graph->add_edge(), TEST_L5, TEST_L6, Edge::FORWARD);
126}
127
129 graph->set_hdmap_version(TEST_MAP_VERSION);
130 graph->set_hdmap_district(TEST_MAP_DISTRICT);
131 GetNodeForTest(graph->add_node(), TEST_L1, TEST_R1);
132 GetNodeForTest(graph->add_node(), TEST_L2, TEST_R1);
133 GetNodeForTest(graph->add_node(), TEST_L3, TEST_R2);
134 GetNodeForTest(graph->add_node(), TEST_L4, TEST_R2);
135 GetNodeForTest(graph->add_node(), TEST_L5, TEST_R3);
136 GetNodeForTest(graph->add_node(), TEST_L6, TEST_R3);
137
138 GetEdgeForTest(graph->add_edge(), TEST_L1, TEST_L2, Edge::RIGHT);
139 GetEdgeForTest(graph->add_edge(), TEST_L2, TEST_L1, Edge::LEFT);
140 GetEdgeForTest(graph->add_edge(), TEST_L3, TEST_L4, Edge::RIGHT);
141 GetEdgeForTest(graph->add_edge(), TEST_L4, TEST_L3, Edge::LEFT);
142 GetEdgeForTest(graph->add_edge(), TEST_L5, TEST_L6, Edge::RIGHT);
143 GetEdgeForTest(graph->add_edge(), TEST_L6, TEST_L5, Edge::LEFT);
144 GetEdgeForTest(graph->add_edge(), TEST_L1, TEST_L3, Edge::FORWARD);
145 GetEdgeForTest(graph->add_edge(), TEST_L3, TEST_L5, Edge::FORWARD);
146 GetEdgeForTest(graph->add_edge(), TEST_L2, TEST_L4, Edge::FORWARD);
147 GetEdgeForTest(graph->add_edge(), TEST_L4, TEST_L6, Edge::FORWARD);
148}
149
150} // namespace routing
151} // namespace apollo
const char TEST_R3[]
void GetGraph2ForTest(Graph *graph)
const double TEST_EDGE_COST
const char TEST_L3[]
const double TEST_START_S
void GetNodeDetailForTest(Node *const node, const std::string &lane_id, const std::string &road_id)
const double TEST_MIDDLE_S
const char TEST_L4[]
const char TEST_L5[]
void GetNodeForTest(Node *const node, const std::string &lane_id, const std::string &road_id)
void GetGraph3ForTest(Graph *graph)
const double TEST_LANE_LENGTH
void GetGraphForTest(Graph *graph)
const double TEST_END_S
const double TEST_LANE_COST
const char TEST_L2[]
const char TEST_L1[]
const char TEST_MAP_DISTRICT[]
const char TEST_R2[]
const char TEST_R1[]
const char TEST_MAP_VERSION[]
void GetEdgeForTest(Edge *const edge, const std::string &lane_id_1, const std::string &lane_id_2, const Edge::DirectionType &type)
const char TEST_L6[]
class register implement
Definition arena_queue.h:37