Apollo 10.0
自动驾驶开放平台
misc_69.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
20
21namespace apollo {
22namespace canbus {
23namespace lincoln {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Misc69::ID = 0x69;
28
29void Misc69::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 int32_t turn_light_type = turn_signal_status(bytes, length);
32 switch (turn_light_type) {
33 case 0:
34 chassis_detail->mutable_light()->set_turn_light_type(
36 break;
37 case 1:
38 chassis_detail->mutable_light()->set_turn_light_type(Light::TURN_LEFT_ON);
39 break;
40 case 2:
41 chassis_detail->mutable_light()->set_turn_light_type(
43 break;
44 case 3:
45 break;
46 default:
47 break;
48 }
49
50 int32_t hi_beam_status = high_beam_status(bytes, length);
51 switch (hi_beam_status) {
52 case 0:
53 chassis_detail->mutable_light()->set_lincoln_lamp_type(Light::BEAM_NULL);
54 break;
55 case 1:
56 chassis_detail->mutable_light()->set_lincoln_lamp_type(
58 break;
59 case 2:
60 chassis_detail->mutable_light()->set_lincoln_lamp_type(Light::BEAM_HIGH);
61 break;
62 case 3:
63 default:
64 chassis_detail->mutable_light()->set_lincoln_lamp_type(
66 break;
67 }
68
69 // wiper status, non-compatible
70 int32_t wiper = wiper_status(bytes, length);
71 switch (wiper) {
72 case 0:
73 chassis_detail->mutable_light()->set_lincoln_wiper(Light::WIPER_OFF);
74 break;
75 case 1:
76 chassis_detail->mutable_light()->set_lincoln_wiper(Light::WIPER_AUTO_OFF);
77 break;
78 case 2:
79 chassis_detail->mutable_light()->set_lincoln_wiper(
81 break;
82 case 3:
83 chassis_detail->mutable_light()->set_lincoln_wiper(
85 break;
86 case 4:
87 chassis_detail->mutable_light()->set_lincoln_wiper(
89 break;
90 case 5:
91 chassis_detail->mutable_light()->set_lincoln_wiper(
93 break;
94 case 6:
95 chassis_detail->mutable_light()->set_lincoln_wiper(
97 break;
98 case 7:
99 chassis_detail->mutable_light()->set_lincoln_wiper(
101 break;
102 case 8:
103 chassis_detail->mutable_light()->set_lincoln_wiper(Light::WIPER_WASH);
104 break;
105 case 9:
106 chassis_detail->mutable_light()->set_lincoln_wiper(Light::WIPER_AUTO_LOW);
107 break;
108 case 10:
109 chassis_detail->mutable_light()->set_lincoln_wiper(
111 break;
112 case 11:
113 chassis_detail->mutable_light()->set_lincoln_wiper(
115 break;
116 case 12:
117 chassis_detail->mutable_light()->set_lincoln_wiper(
119 break;
120 case 13:
121 chassis_detail->mutable_light()->set_lincoln_wiper(Light::WIPER_RESERVED);
122 break;
123 case 14:
124 chassis_detail->mutable_light()->set_lincoln_wiper(Light::WIPER_STALLED);
125 break;
126 case 15:
127 chassis_detail->mutable_light()->set_lincoln_wiper(Light::WIPER_NO_DATA);
128 break;
129 }
130
131 int32_t ambient = ambient_light_status(bytes, length);
132 switch (ambient) {
133 case 0:
134 chassis_detail->mutable_light()->set_lincoln_ambient(Light::AMBIENT_DARK);
135 break;
136 case 1:
137 chassis_detail->mutable_light()->set_lincoln_ambient(
139 break;
140 case 2:
141 chassis_detail->mutable_light()->set_lincoln_ambient(
143 break;
144 case 3:
145 chassis_detail->mutable_light()->set_lincoln_ambient(
147 break;
148 case 4:
149 chassis_detail->mutable_light()->set_lincoln_ambient(
151 break;
152 case 7:
153 chassis_detail->mutable_light()->set_lincoln_ambient(
155 break;
156 default:
157 chassis_detail->mutable_light()->set_lincoln_ambient(
159 break;
160 }
161
162 // acc button related
163 chassis_detail->mutable_basic()->set_acc_on_button(
164 is_acc_on_pressed(bytes, length));
165 chassis_detail->mutable_basic()->set_acc_off_button(
166 is_acc_off_pressed(bytes, length));
167 chassis_detail->mutable_basic()->set_acc_res_button(
168 is_acc_resume_pressed(bytes, length));
169 chassis_detail->mutable_basic()->set_acc_cancel_button(
170 is_acc_cancel_pressed(bytes, length));
171 chassis_detail->mutable_basic()->set_acc_on_off_button(
172 is_acc_on_or_off_pressed(bytes, length));
173 chassis_detail->mutable_basic()->set_acc_res_cancel_button(
174 is_acc_resume_or_cancel_pressed(bytes, length));
175 chassis_detail->mutable_basic()->set_acc_inc_spd_button(
177 chassis_detail->mutable_basic()->set_acc_dec_spd_button(
179 chassis_detail->mutable_basic()->set_acc_inc_gap_button(
181 chassis_detail->mutable_basic()->set_acc_dec_gap_button(
183 chassis_detail->mutable_basic()->set_lka_button(
184 is_lka_on_or_off_pressed(bytes, length));
185 chassis_detail->mutable_basic()->set_canbus_fault(
186 is_canbus_fault(bytes, length));
187
188 // driver door
189 if (is_driver_door_open(bytes, length)) {
190 chassis_detail->mutable_safety()->set_is_driver_car_door_close(false);
191 } else {
192 chassis_detail->mutable_safety()->set_is_driver_car_door_close(true);
193 }
194
195 chassis_detail->mutable_safety()->set_is_passenger_door_open(
196 is_passenger_door_open(bytes, length));
197 chassis_detail->mutable_safety()->set_is_rearleft_door_open(
198 is_rear_left_door_open(bytes, length));
199 chassis_detail->mutable_safety()->set_is_rearright_door_open(
200 is_rear_right_door_open(bytes, length));
201 chassis_detail->mutable_safety()->set_is_hood_open(
202 is_hood_open(bytes, length));
203 chassis_detail->mutable_safety()->set_is_trunk_open(
204 is_trunk_open(bytes, length));
205 chassis_detail->mutable_safety()->set_is_passenger_detected(
206 is_passenger_detected(bytes, length));
207 chassis_detail->mutable_safety()->set_is_passenger_airbag_enabled(
208 is_passenger_airbag_enabled(bytes, length));
209
210 // airbag ? driver airbag?
211 // chassis_detail->mutable_basic()->set_is_air_bag_deployed(
212 // is_passenger_airbag_enabled(bytes, length));
213
214 // driver buckled
215 chassis_detail->mutable_safety()->set_is_driver_buckled(
216 is_driver_belt_buckled(bytes, length));
217 chassis_detail->mutable_safety()->set_is_passenger_buckled(
218 is_passenger_belt_buckled(bytes, length));
219
220 // has error?, non-compatible
221 // chassis_detail->mutable_safety()->set_has_error(
222 // is_canbus_fault(bytes, length));
223}
224
225int32_t Misc69::turn_signal_status(const std::uint8_t *bytes,
226 int32_t length) const {
227 Byte frame(bytes + 0);
228 int32_t x = frame.get_byte(0, 2);
229 return x;
230}
231
232int32_t Misc69::high_beam_status(const std::uint8_t *bytes,
233 int32_t length) const {
234 Byte frame(bytes + 0);
235 int32_t x = frame.get_byte(2, 2);
236 return x;
237}
238
239int32_t Misc69::wiper_status(const std::uint8_t *bytes, int32_t length) const {
240 Byte frame(bytes + 0);
241 int32_t x = frame.get_byte(4, 4);
242 return x;
243}
244
245int32_t Misc69::ambient_light_status(const std::uint8_t *bytes,
246 int32_t length) const {
247 Byte frame(bytes + 1);
248 int32_t x = frame.get_byte(0, 3);
249 return x;
250}
251
252bool Misc69::is_acc_on_pressed(const std::uint8_t *bytes,
253 int32_t length) const {
254 Byte frame(bytes + 1);
255 return frame.is_bit_1(3);
256}
257
258bool Misc69::is_acc_off_pressed(const std::uint8_t *bytes,
259 int32_t length) const {
260 Byte frame(bytes + 1);
261 return frame.is_bit_1(4);
262}
263
264bool Misc69::is_acc_resume_pressed(const std::uint8_t *bytes,
265 int32_t length) const {
266 Byte frame(bytes + 1);
267 return frame.is_bit_1(5);
268}
269
270bool Misc69::is_acc_cancel_pressed(const std::uint8_t *bytes,
271 int32_t length) const {
272 Byte frame(bytes + 1);
273 return frame.is_bit_1(6);
274}
275
276bool Misc69::is_acc_on_or_off_pressed(const std::uint8_t *bytes,
277 int32_t length) const {
278 Byte frame(bytes + 2);
279 return frame.is_bit_1(0);
280}
281
282bool Misc69::is_acc_resume_or_cancel_pressed(const std::uint8_t *bytes,
283 int32_t length) const {
284 Byte frame(bytes + 2);
285 return frame.is_bit_1(1);
286}
287
288bool Misc69::is_acc_increment_set_speed_pressed(const std::uint8_t *bytes,
289 int32_t length) const {
290 Byte frame(bytes + 2);
291 return frame.is_bit_1(2);
292}
293
294bool Misc69::is_acc_decrement_set_speed_pressed(const std::uint8_t *bytes,
295 int32_t length) const {
296 Byte frame(bytes + 2);
297 return frame.is_bit_1(3);
298}
299
301 int32_t length) const {
302 Byte frame(bytes + 2);
303 return frame.is_bit_1(4);
304}
305
307 int32_t length) const {
308 Byte frame(bytes + 2);
309 return frame.is_bit_1(5);
310}
311
312bool Misc69::is_lka_on_or_off_pressed(const std::uint8_t *bytes,
313 int32_t length) const {
314 Byte frame(bytes + 2);
315 return frame.is_bit_1(6);
316}
317
318bool Misc69::is_canbus_fault(const std::uint8_t *bytes, int32_t length) const {
319 Byte frame(bytes + 2);
320 return frame.is_bit_1(7);
321}
322
323bool Misc69::is_driver_door_open(const std::uint8_t *bytes,
324 int32_t length) const {
325 Byte frame(bytes + 3);
326 return frame.is_bit_1(0);
327}
328
329bool Misc69::is_passenger_door_open(const std::uint8_t *bytes,
330 int32_t length) const {
331 Byte frame(bytes + 3);
332 return frame.is_bit_1(1);
333}
334
335bool Misc69::is_rear_left_door_open(const std::uint8_t *bytes,
336 int32_t length) const {
337 Byte frame(bytes + 3);
338 return frame.is_bit_1(2);
339}
340
341bool Misc69::is_rear_right_door_open(const std::uint8_t *bytes,
342 int32_t length) const {
343 Byte frame(bytes + 3);
344 return frame.is_bit_1(3);
345}
346
347bool Misc69::is_hood_open(const std::uint8_t *bytes, int32_t length) const {
348 Byte frame(bytes + 3);
349 return frame.is_bit_1(4);
350}
351
352bool Misc69::is_trunk_open(const std::uint8_t *bytes, int32_t length) const {
353 Byte frame(bytes + 3);
354 return frame.is_bit_1(5);
355}
356
357bool Misc69::is_passenger_detected(const std::uint8_t *bytes,
358 int32_t length) const {
359 Byte frame(bytes + 3);
360 return frame.is_bit_1(6);
361}
362
363bool Misc69::is_passenger_airbag_enabled(const std::uint8_t *bytes,
364 int32_t length) const {
365 Byte frame(bytes + 3);
366 return frame.is_bit_1(7);
367}
368
369bool Misc69::is_driver_belt_buckled(const std::uint8_t *bytes,
370 int32_t length) const {
371 Byte frame(bytes + 4);
372 return frame.is_bit_1(0);
373}
374
375bool Misc69::is_passenger_belt_buckled(const std::uint8_t *bytes,
376 int32_t length) const {
377 Byte frame(bytes + 4);
378 return frame.is_bit_1(1);
379}
380
381} // namespace lincoln
382} // namespace canbus
383} // namespace apollo
Defines the Byte class.
bool is_passenger_airbag_enabled(const std::uint8_t *bytes, int32_t length) const
check the passenger airbag enabled bit based on byte array.
Definition misc_69.cc:363
bool is_acc_cancel_pressed(const std::uint8_t *bytes, int32_t length) const
check acc cancel pressed bit based on byte array.
Definition misc_69.cc:270
static const int32_t ID
Definition misc_69.h:43
bool is_rear_left_door_open(const std::uint8_t *bytes, int32_t length) const
check the passenger door open bit based on byte array.
Definition misc_69.cc:335
bool is_acc_off_pressed(const std::uint8_t *bytes, int32_t length) const
check acc off pressed bit based on byte array.
Definition misc_69.cc:258
bool is_hood_open(const std::uint8_t *bytes, int32_t length) const
check the hood open bit based on byte array.
Definition misc_69.cc:347
bool is_lka_on_or_off_pressed(const std::uint8_t *bytes, int32_t length) const
check the lka on or off pressed bit based on byte array.
Definition misc_69.cc:312
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
Definition misc_69.cc:29
bool is_passenger_belt_buckled(const std::uint8_t *bytes, int32_t length) const
check the passenger belt buckled bit based on byte array.
Definition misc_69.cc:375
bool is_acc_resume_or_cancel_pressed(const std::uint8_t *bytes, int32_t length) const
check acc resume or cancel pressed bit based on byte array.
Definition misc_69.cc:282
int32_t turn_signal_status(const std::uint8_t *bytes, int32_t length) const
calculate the turn signal status based on byte array.
Definition misc_69.cc:225
bool is_acc_decrement_following_gap_pressed(const std::uint8_t *bytes, int32_t length) const
check the acc decrement following gap pressed bit based on byte array.
Definition misc_69.cc:306
bool is_canbus_fault(const std::uint8_t *bytes, int32_t length) const
check the canbus fault bit based on byte array.
Definition misc_69.cc:318
bool is_driver_door_open(const std::uint8_t *bytes, int32_t length) const
check the driver door open bit based on byte array.
Definition misc_69.cc:323
int32_t ambient_light_status(const std::uint8_t *bytes, int32_t length) const
calculate the ambient light status based on byte array.
Definition misc_69.cc:245
bool is_driver_belt_buckled(const std::uint8_t *bytes, int32_t length) const
check the driver belt buckled bit based on byte array.
Definition misc_69.cc:369
bool is_acc_decrement_set_speed_pressed(const std::uint8_t *bytes, int32_t length) const
check the acc decrement set speed pressed bit based on byte array.
Definition misc_69.cc:294
bool is_trunk_open(const std::uint8_t *bytes, int32_t length) const
check the trunk open bit based on byte array.
Definition misc_69.cc:352
int32_t wiper_status(const std::uint8_t *bytes, int32_t length) const
calculate the wiper status based on byte array.
Definition misc_69.cc:239
int32_t high_beam_status(const std::uint8_t *bytes, int32_t length) const
calculate the high beam status based on byte array.
Definition misc_69.cc:232
bool is_passenger_door_open(const std::uint8_t *bytes, int32_t length) const
check the passenger door open bit based on byte array.
Definition misc_69.cc:329
bool is_acc_on_pressed(const std::uint8_t *bytes, int32_t length) const
check acc on pressed bit based on byte array.
Definition misc_69.cc:252
bool is_acc_increment_following_gap_pressed(const std::uint8_t *bytes, int32_t length) const
check the acc increment following gap pressed bit based on byte array.
Definition misc_69.cc:300
bool is_acc_on_or_off_pressed(const std::uint8_t *bytes, int32_t length) const
check acc on or off pressed bit based on byte array.
Definition misc_69.cc:276
bool is_acc_increment_set_speed_pressed(const std::uint8_t *bytes, int32_t length) const
check the acc increment set speed pressed bit based on byte array.
Definition misc_69.cc:288
bool is_rear_right_door_open(const std::uint8_t *bytes, int32_t length) const
check the rear right door open bit based on byte array.
Definition misc_69.cc:341
bool is_acc_resume_pressed(const std::uint8_t *bytes, int32_t length) const
check acc resume pressed bit based on byte array.
Definition misc_69.cc:264
bool is_passenger_detected(const std::uint8_t *bytes, int32_t length) const
check the passenger detected bit based on byte array.
Definition misc_69.cc:357
the class of Misc69 (for lincoln vehicle)
class register implement
Definition arena_queue.h:37