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
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
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
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(
128 }
129 }
130 }
131 }
132 *os_light = res;
133 return flag_has_data;
134}
static OSLightype LightTypeObu2Sys(int32_t type)