Apollo 10.0
自动驾驶开放平台
apollo::v2x::ProtoAdapter类 参考final

#include <proto_adapter.h>

apollo::v2x::ProtoAdapter 的协作图:

静态 Public 成员函数

static OSLightype LightTypeObu2Sys (int32_t type)
 
static bool LightObu2Sys (const ObuLight &obu_light, std::shared_ptr< OSLight > *os_light)
 
static bool RsiObu2Sys (const ObuRsi *obu_rsi, std::shared_ptr< OSRsi > *os_rsi)
 
static bool JunctionHd2obu (const HDJunction &hd_junction, std::shared_ptr< ObuJunction > *obu_junction)
 

详细描述

在文件 proto_adapter.h63 行定义.

成员函数说明

◆ JunctionHd2obu()

bool apollo::v2x::ProtoAdapter::JunctionHd2obu ( const HDJunction hd_junction,
std::shared_ptr< ObuJunction > *  obu_junction 
)
static

在文件 proto_adapter.cc209 行定义.

210 {
211 if (nullptr == obu_junction) {
212 return false;
213 }
214 auto res = std::make_shared<ObuJunction>();
215 if (nullptr == res) {
216 return false;
217 }
218 res->mutable_id()->set_id(hd_junction->id().id());
219 for (const auto &point : hd_junction->polygon().points()) {
220 auto res_point = res->mutable_polygon()->add_point();
221 res_point->set_x(point.x());
222 res_point->set_y(point.y());
223 res_point->set_z(0);
224 }
225 *obu_junction = res;
226 return true;
227}

◆ LightObu2Sys()

bool apollo::v2x::ProtoAdapter::LightObu2Sys ( const ObuLight obu_light,
std::shared_ptr< OSLight > *  os_light 
)
static

在文件 proto_adapter.cc41 行定义.

42 {
43 if (nullptr == os_light) {
44 return false;
45 }
46 auto res = std::make_shared<OSLight>();
47 if (nullptr == res) {
48 return false;
49 }
50 if (!obu_light.has_header()) {
51 return false;
52 }
53 if (obu_light.header().has_timestamp_sec()) {
54 res->mutable_header()->set_timestamp_sec(
55 obu_light.header().timestamp_sec());
56 }
57 if (obu_light.header().has_module_name()) {
58 res->mutable_header()->set_module_name(obu_light.header().module_name());
59 }
60 if (0 == obu_light.road_traffic_light_size()) {
61 return false;
62 }
63 bool flag_has_data = false;
64 for (int idx_road = 0; idx_road < obu_light.road_traffic_light_size();
65 idx_road++) {
66 const auto &obu_road_light1 = obu_light.road_traffic_light(idx_road);
67 // Set the road index for lane
69 switch (obu_road_light1.road_direction()) {
70 case 1:
72 break;
73 case 2:
75 break;
76 case 3:
78 break;
79 case 4:
81 break;
82 default:
83 AINFO << "Road direction=" << obu_road_light1.road_direction()
84 << " is invalid.";
85 }
86 // FOR-EACH LANE
87 for (int idx_lane = 0; idx_lane < obu_road_light1.lane_traffic_light_size();
88 idx_lane++) {
89 const auto &obu_lane_light1 =
90 obu_road_light1.lane_traffic_light(idx_lane);
91 if (!obu_lane_light1.has_gps_x_m() || !obu_lane_light1.has_gps_y_m()) {
92 AWARN << "Invalid lane_traffic_light: [" << idx_road << "][" << idx_lane
93 << "]: no gps info here.";
94 continue;
95 }
96 flag_has_data = true;
97 auto *res_light1 = res->add_road_traffic_light();
98 res_light1->set_gps_x_m(obu_lane_light1.gps_x_m());
99 res_light1->set_gps_y_m(obu_lane_light1.gps_y_m());
100 res_light1->set_road_attribute(tl_attr);
101 // single traffic light
102 for (int j = 0; j < obu_lane_light1.single_traffic_light_size(); j++) {
103 auto *res_single1 = res_light1->add_single_traffic_light();
104 const auto &obu_single1 = obu_lane_light1.single_traffic_light(j);
105 if (obu_single1.has_id()) {
106 res_single1->set_id(obu_single1.id());
107 }
108 if (obu_single1.has_color_remaining_time_s()) {
109 res_single1->set_color_remaining_time_s(
110 obu_single1.color_remaining_time_s());
111 }
112 if (obu_single1.has_next_remaining_time()) {
113 res_single1->set_next_remaining_time_s(
114 obu_single1.next_remaining_time());
115 }
116 if (obu_single1.has_right_turn_light()) {
117 res_single1->set_right_turn_light(obu_single1.right_turn_light());
118 }
119 if (obu_single1.has_color()) {
120 res_single1->set_color(obu_single1.color());
121 }
122 if (obu_single1.has_next_color()) {
123 res_single1->set_next_color(obu_single1.next_color());
124 }
125 if (obu_single1.has_traffic_light_type()) {
126 res_single1->add_traffic_light_type(
127 LightTypeObu2Sys(obu_single1.traffic_light_type()));
128 }
129 }
130 }
131 }
132 *os_light = res;
133 return flag_has_data;
134}
static OSLightype LightTypeObu2Sys(int32_t type)
#define AINFO
Definition log.h:42
#define AWARN
Definition log.h:43

◆ LightTypeObu2Sys()

OSLightype apollo::v2x::ProtoAdapter::LightTypeObu2Sys ( int32_t  type)
static

在文件 proto_adapter.cc27 行定义.

27 {
28 switch (type) {
29 case 2:
30 return OSLightype::SingleTrafficLight_Type_LEFT;
31 case 3:
32 return OSLightype::SingleTrafficLight_Type_RIGHT;
33 case 4:
34 return OSLightype::SingleTrafficLight_Type_U_TURN;
35 case 1:
36 default:
37 return OSLightype::SingleTrafficLight_Type_STRAIGHT;
38 }
39}

◆ RsiObu2Sys()

bool apollo::v2x::ProtoAdapter::RsiObu2Sys ( const ObuRsi obu_rsi,
std::shared_ptr< OSRsi > *  os_rsi 
)
static

在文件 proto_adapter.cc136 行定义.

137 {
138 if (nullptr == obu_rsi) {
139 return false;
140 }
141 if (nullptr == os_rsi) {
142 return false;
143 }
144 auto res = std::make_shared<OSRsi>();
145 if (nullptr == res) {
146 return false;
147 }
148 if (!obu_rsi->has_alter_type()) {
149 return false;
150 }
151 res->set_radius(obu_rsi->radius());
152 res->set_rsi_type(obu_rsi->alter_type());
153 if (obu_rsi->has_header()) {
154 auto header = res->mutable_header();
155 header->set_sequence_num(obu_rsi->header().sequence_num());
156 header->set_timestamp_sec(obu_rsi->header().timestamp_sec());
157 header->set_module_name("v2x");
158 }
159 switch (obu_rsi->alter_type()) {
163 for (int index = 0; index < obu_rsi->points_size(); index++) {
164 auto point = res->add_points();
165 point->set_x(obu_rsi->points(index).x());
166 point->set_y(obu_rsi->points(index).y());
167 res->set_speed(std::atof(obu_rsi->description().c_str()));
168 }
169 break;
170 case RsiAlterType::CONSTRUCTION_AHEAD: // Construction Ahead
171 case RsiAlterType::BUS_LANE: // Bus Lane
172 case RsiAlterType::TIDAL_LANE: // tidal Lane
173 case RsiAlterType::TRAFFIC_JAM: // traffic jam
174 case RsiAlterType::TRAFFIC_ACCIDENT: // traffic accident
175 for (int index = 0; index < obu_rsi->points_size(); index++) {
176 auto point = res->add_points();
177 point->set_x(obu_rsi->points(index).x());
178 point->set_y(obu_rsi->points(index).y());
179 }
180 break;
181 case RsiAlterType::NO_HONKING: // No Honking
182 case RsiAlterType::SLOW_DOWN_SECTION: // slow down section
183 case RsiAlterType::ACCIDENT_PRONE: // Accident Prone
184 case RsiAlterType::OVERSPEED_VEHICLE: // overspeed vehicle
185 case RsiAlterType::EMERGENCY_BRAKING: // emergency braking
186 case RsiAlterType::ANTIDROMIC_VEHICLE: // antidromic vehicle
187 case RsiAlterType::ZOMBIES_VEHICLE: { // zombies vehicle
188 auto point = res->add_points();
189 point->set_x(obu_rsi->points(0).x());
190 point->set_y(obu_rsi->points(0).y());
191 break;
192 }
193 case RsiAlterType::CONTROLLOSS_VEHICLE: // controlloss vehicle
194 case RsiAlterType::SPECIAL_VEHICLE: { // special vehicle
195 auto point = res->add_points();
196 point->set_x(obu_rsi->points(0).x());
197 point->set_y(obu_rsi->points(0).y());
198 res->set_speed(std::atof(obu_rsi->description().c_str()));
199 break;
200 }
201 default:
202 AINFO << "RSI type:" << obu_rsi->alter_type();
203 break;
204 }
205 *os_rsi = res;
206 return true;
207}

该类的文档由以下文件生成: