Apollo 10.0
自动驾驶开放平台
vcu_report_505.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 "glog/logging.h"
20
23
24namespace apollo {
25namespace canbus {
26namespace demo {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Vcureport505::ID = 0x505;
32
33void Vcureport505::Parse(const std::uint8_t* bytes, int32_t length,
34 Demo* chassis) const {
35 chassis->mutable_vcu_report_505()->set_vehicle_mode_state(
36 vehicle_mode_state(bytes, length));
37 chassis->mutable_vcu_report_505()->set_aeb_mode(aeb_mode(bytes, length));
38 chassis->mutable_vcu_report_505()->set_brake_light_actual(
39 brake_light_actual(bytes, length));
40 chassis->mutable_vcu_report_505()->set_turn_light_actual(
41 turn_light_actual(bytes, length));
42 chassis->mutable_vcu_report_505()->set_chassis_errcode(
43 chassis_errcode(bytes, length));
44 chassis->mutable_vcu_report_505()->set_drive_mode_sts(
45 drive_mode_sts(bytes, length));
46 chassis->mutable_vcu_report_505()->set_steer_mode_sts(
47 steer_mode_sts(bytes, length));
48 chassis->mutable_vcu_report_505()->set_frontcrash_state(
49 frontcrash_state(bytes, length));
50 chassis->mutable_vcu_report_505()->set_backcrash_state(
51 backcrash_state(bytes, length));
52 chassis->mutable_vcu_report_505()->set_aeb_brake_state(
53 aeb_brake_state(bytes, length));
54 chassis->mutable_vcu_report_505()->set_acc(acc(bytes, length));
55 chassis->mutable_vcu_report_505()->set_speed(speed(bytes, length));
56}
57
58// config detail: {'bit': 36, 'enum': {0:
59// 'VEHICLE_MODE_STATE_MANUAL_REMOTE_MODE', 1: 'VEHICLE_MODE_STATE_AUTO_MODE',
60// 2: 'VEHICLE_MODE_STATE_EMERGENCY_MODE', 3:
61// 'VEHICLE_MODE_STATE_STANDBY_MODE'}, 'is_signed_var': False, 'len': 2, 'name':
62// 'vehicle_mode_state', 'offset': 0.0, 'order': 'motorola', 'physical_range':
63// '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
64Vcu_report_505::Vehicle_mode_stateType Vcureport505::vehicle_mode_state(
65 const std::uint8_t* bytes, int32_t length) const {
66 Byte t0(bytes + 4);
67 int32_t x = t0.get_byte(3, 2);
68
71 return ret;
72}
73
74// config detail: {'bit': 58, 'description': 'describle the vehicle AEB mode
75// whether was set', 'enum': {0: 'AEB_MODE_DISABLE', 1: 'AEB_MODE_ENABLE'},
76// 'is_signed_var': False, 'len': 1, 'name': 'aeb_mode', 'offset': 0.0, 'order':
77// 'motorola', 'physical_range': '[0|1]', 'physical_unit': '', 'precision': 1.0,
78// 'type': 'enum'}
79Vcu_report_505::Aeb_modeType Vcureport505::aeb_mode(const std::uint8_t* bytes,
80 int32_t length) const {
81 Byte t0(bytes + 7);
82 int32_t x = t0.get_byte(2, 1);
83
85 static_cast<Vcu_report_505::Aeb_modeType>(x);
86 return ret;
87}
88
89// config detail: {'bit': 11, 'enum': {0: 'BRAKE_LIGHT_ACTUAL_BRAKELIGHT_OFF',
90// 1: 'BRAKE_LIGHT_ACTUAL_BRAKELIGHT_ON'}, 'is_signed_var': False, 'len': 1,
91// 'name': 'brake_light_actual', 'offset': 0.0, 'order': 'motorola',
92// 'physical_range': '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type':
93// 'enum'}
94Vcu_report_505::Brake_light_actualType Vcureport505::brake_light_actual(
95 const std::uint8_t* bytes, int32_t length) const {
96 Byte t0(bytes + 1);
97 int32_t x = t0.get_byte(3, 1);
98
101 return ret;
102}
103
104// config detail: {'bit': 57, 'enum': {0: 'TURN_LIGHT_ACTUAL_TURNLAMPSTS_OFF',
105// 1: 'TURN_LIGHT_ACTUAL_LEFT_TURNLAMPSTS_ON', 2:
106// 'TURN_LIGHT_ACTUAL_RIGHT_TURNLAMPSTS_ON', 3:
107// 'TURN_LIGHT_ACTUAL_HAZARD_WARNING_LAMPSTS_ON'}, 'is_signed_var': False,
108// 'len': 2, 'name': 'turn_light_actual', 'offset': 0.0, 'order': 'motorola',
109// 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type':
110// 'enum'}
111Vcu_report_505::Turn_light_actualType Vcureport505::turn_light_actual(
112 const std::uint8_t* bytes, int32_t length) const {
113 Byte t0(bytes + 7);
114 int32_t x = t0.get_byte(0, 2);
115
118 return ret;
119}
120
121// config detail: {'bit': 47, 'is_signed_var': False, 'len': 8, 'name':
122// 'chassis_errcode', 'offset': 0.0, 'order': 'motorola', 'physical_range':
123// '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
124int Vcureport505::chassis_errcode(const std::uint8_t* bytes,
125 int32_t length) const {
126 Byte t0(bytes + 5);
127 int32_t x = t0.get_byte(0, 8);
128
129 int ret = x;
130 return ret;
131}
132
133// config detail: {'bit': 39, 'enum': {0:
134// 'DRIVE_MODE_STS_THROTTLE_PADDLE_DRIVE_MODE', 1:
135// 'DRIVE_MODE_STS_SPEED_DRIVE_MODE'}, 'is_signed_var': False, 'len': 3, 'name':
136// 'drive_mode_sts', 'offset': 0.0, 'order': 'motorola', 'physical_range':
137// '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
138Vcu_report_505::Drive_mode_stsType Vcureport505::drive_mode_sts(
139 const std::uint8_t* bytes, int32_t length) const {
140 Byte t0(bytes + 4);
141 int32_t x = t0.get_byte(5, 3);
142
145 return ret;
146}
147
148// config detail: {'bit': 10, 'enum': {0: 'STEER_MODE_STS_STANDARD_STEER_MODE',
149// 1: 'STEER_MODE_STS_NON_DIRECTION_STEER_MODE', 2:
150// 'STEER_MODE_STS_SYNC_DIRECTION_STEER_MODE'}, 'is_signed_var': False, 'len':
151// 3, 'name': 'steer_mode_sts', 'offset': 0.0, 'order': 'motorola',
152// 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type':
153// 'enum'}
154Vcu_report_505::Steer_mode_stsType Vcureport505::steer_mode_sts(
155 const std::uint8_t* bytes, int32_t length) const {
156 Byte t0(bytes + 1);
157 int32_t x = t0.get_byte(0, 3);
158
161 return ret;
162}
163
164// config detail: {'bit': 33, 'enum': {0: 'FRONTCRASH_STATE_NO_EVENT', 1:
165// 'FRONTCRASH_STATE_CRASH_EVENT'}, 'is_signed_var': False, 'len': 1, 'name':
166// 'frontcrash_state', 'offset': 0.0, 'order': 'motorola', 'physical_range':
167// '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
168Vcu_report_505::Frontcrash_stateType Vcureport505::frontcrash_state(
169 const std::uint8_t* bytes, int32_t length) const {
170 Byte t0(bytes + 4);
171 int32_t x = t0.get_byte(1, 1);
172
175 return ret;
176}
177
178// config detail: {'bit': 34, 'enum': {0: 'BACKCRASH_STATE_NO_EVENT', 1:
179// 'BACKCRASH_STATE_CRASH_EVENT'}, 'is_signed_var': False, 'len': 1, 'name':
180// 'backcrash_state', 'offset': 0.0, 'order': 'motorola', 'physical_range':
181// '[0|0]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
182Vcu_report_505::Backcrash_stateType Vcureport505::backcrash_state(
183 const std::uint8_t* bytes, int32_t length) const {
184 Byte t0(bytes + 4);
185 int32_t x = t0.get_byte(2, 1);
186
189 return ret;
190}
191
192// config detail: {'bit': 32, 'description': 'describe the vehicle e-brake
193// command whether was triggered by AEB', 'enum': {0:
194// 'AEB_BRAKE_STATE_INACTIVE', 1: 'AEB_BRAKE_STATE_ACTIVE'}, 'is_signed_var':
195// False, 'len': 1, 'name': 'aeb_brake_state', 'offset': 0.0, 'order':
196// 'motorola', 'physical_range': '[0|0]', 'physical_unit': '', 'precision': 1.0,
197// 'signal_type': 'command', 'type': 'enum'}
198Vcu_report_505::Aeb_brake_stateType Vcureport505::aeb_brake_state(
199 const std::uint8_t* bytes, int32_t length) const {
200 Byte t0(bytes + 4);
201 int32_t x = t0.get_byte(0, 1);
202
205 return ret;
206}
207
208// config detail: {'bit': 7, 'is_signed_var': True, 'len': 12, 'name': 'acc',
209// 'offset': 0.0, 'order': 'motorola', 'physical_range': '[-10|10]',
210// 'physical_unit': 'm/s^2', 'precision': 0.01, 'type': 'double'}
211double Vcureport505::acc(const std::uint8_t* bytes, int32_t length) const {
212 Byte t0(bytes + 0);
213 int32_t x = t0.get_byte(0, 8);
214
215 Byte t1(bytes + 1);
216 int32_t t = t1.get_byte(4, 4);
217 x <<= 4;
218 x |= t;
219
220 x <<= 20;
221 x >>= 20;
222
223 double ret = x * 0.010000;
224 return ret;
225}
226
227// config detail: {'bit': 23, 'description': 'speed', 'is_signed_var': True,
228// 'len': 16, 'name': 'speed', 'offset': 0.0, 'order': 'motorola',
229// 'physical_range': '[-32.768|32.767]', 'physical_unit': 'm/s', 'precision':
230// 0.001, 'signal_type': 'speed', 'type': 'double'}
231double Vcureport505::speed(const std::uint8_t* bytes, int32_t length) const {
232 Byte t0(bytes + 2);
233 int32_t x = t0.get_byte(0, 8);
234
235 Byte t1(bytes + 3);
236 int32_t t = t1.get_byte(0, 8);
237 x <<= 8;
238 x |= t;
239
240 x <<= 16;
241 x >>= 16;
242
243 double ret = x * 0.001000;
244 return ret;
245}
246} // namespace demo
247} // namespace canbus
248} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Demo *chassis) const override
class register implement
Definition arena_queue.h:37