Apollo 11.0
自动驾驶开放平台
ecu_status_1_515.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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#include "glog/logging.h"
21
22namespace apollo {
23namespace canbus {
24namespace ch {
25
26using ::apollo::drivers::canbus::Byte;
27
29const int32_t Ecustatus1515::ID = 0x515;
30
31void Ecustatus1515::Parse(const std::uint8_t* bytes, int32_t length,
32 Ch* chassis) const {
33 chassis->mutable_ecu_status_1_515()->set_chassis_mcu_err(
34 chassis_mcu_err(bytes, length));
35 chassis->mutable_ecu_status_1_515()->set_chassis_mcu_can(
36 chassis_mcu_can(bytes, length));
37 chassis->mutable_ecu_status_1_515()->set_chassis_hw_lost(
38 chassis_hw_lost(bytes, length));
39 chassis->mutable_ecu_status_1_515()->set_chassis_eps_err(
40 chassis_eps_err(bytes, length));
41 chassis->mutable_ecu_status_1_515()->set_chassis_eps_can(
42 chassis_eps_can(bytes, length));
43 chassis->mutable_ecu_status_1_515()->set_chassis_ehb_err(
44 chassis_ehb_err(bytes, length));
45 chassis->mutable_ecu_status_1_515()->set_chassis_ehb_can(
46 chassis_ehb_can(bytes, length));
47 chassis->mutable_ecu_status_1_515()->set_chassis_bms_can(
48 chassis_bms_can(bytes, length));
49 chassis->mutable_ecu_status_1_515()->set_speed(
50 speed(bytes, length));
51 chassis->mutable_ecu_status_1_515()->set_acc_speed(
52 acc_speed(bytes, length));
53 chassis->mutable_ecu_status_1_515()->set_ctrl_sts(
54 ctrl_sts(bytes, length));
55 chassis->mutable_ecu_status_1_515()->set_chassis_sts(
56 chassis_sts(bytes, length));
57 chassis->mutable_ecu_status_1_515()->set_chassis_err(
58 chassis_err(bytes, length));
59 chassis->mutable_ecu_status_1_515()->set_chassis_ads_err(
60 chassis_ads_err(bytes, length));
61}
62
63// config detail: {'bit': 0, 'description': 'Current speed (Steering status)',
64// 'is_signed_var': True, 'len': 16, 'name': 'speed', 'offset': 0.0, 'order':
65// 'intel', 'physical_range': '[-327.68|327.67]', 'physical_unit': 'm/s',
66// 'precision': 0.01, 'type': 'double'}
67double Ecustatus1515::speed(const std::uint8_t* bytes, int32_t length) const {
68 Byte t0(bytes + 1);
69 int32_t x = t0.get_byte(0, 8);
70
71 Byte t1(bytes + 0);
72 int32_t t = t1.get_byte(0, 8);
73 x <<= 8;
74 x |= t;
75
76 x <<= 16;
77 x >>= 16;
78
79 double ret = x * 0.010000;
80 return ret;
81}
82
83// config detail: {'bit': 16, 'description': 'Current acceleration (Steering
84// status)', 'is_signed_var': True, 'len': 16, 'name': 'acc_speed', 'offset':
85// 0.0, 'order': 'intel', 'physical_range': '[0|0]', 'physical_unit': 'm/s^2',
86// 'precision': 0.001, 'type': 'double'}
87double Ecustatus1515::acc_speed(const std::uint8_t* bytes,
88 int32_t length) const {
89 Byte t0(bytes + 3);
90 int32_t x = t0.get_byte(0, 8);
91
92 Byte t1(bytes + 2);
93 int32_t t = t1.get_byte(0, 8);
94 x <<= 8;
95 x |= t;
96
97 x <<= 16;
98 x >>= 16;
99
100 double ret = x * 0.001000;
101 return ret;
102}
103
104// config detail: {'bit': 32, 'description': 'Current Auto-mode state (Chassis
105// status)', 'enum': {0: 'CTRL_STS_OUT_OF_CONTROL', 1:
106// 'CTRL_STS_UNDER_CONTROL'}, 'is_signed_var': False, 'len': 8, 'name':
107// 'ctrl_sts', 'offset': 0.0, 'order': 'intel', 'physical_range': '[0|1]',
108// 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
109Ecu_status_1_515::Ctrl_stsType Ecustatus1515::ctrl_sts(
110 const std::uint8_t* bytes, int32_t length) const {
111 Byte t0(bytes + 4);
112 int32_t x = t0.get_byte(0, 8);
113
115 static_cast<Ecu_status_1_515::Ctrl_stsType>(x);
116 return ret;
117}
118
119// config detail: {'bit': 40, 'description': 'Current chassis state (Chassis
120// status)', 'is_signed_var': False, 'len': 8, 'name': 'chassis_sts', 'offset':
121// 0.0, 'order': 'intel', 'physical_range': '[0|255]', 'physical_unit': '',
122// 'precision': 1.0, 'type': 'int'}
123int Ecustatus1515::chassis_sts(const std::uint8_t* bytes,
124 int32_t length) const {
125 Byte t0(bytes + 5);
126 int32_t x = t0.get_byte(0, 8);
127
128 int ret = x;
129 return ret;
130}
131
132// config detail: {'bit': 48, 'description': 'Chassis error code (Chassis
133// status)', 'is_signed_var': False, 'len': 16, 'name': 'chassis_err', 'offset':
134// 0.0, 'order': 'intel', 'physical_range': '[0|65535]', 'physical_unit': '',
135// 'precision': 1.0, 'type': 'int'}
136int Ecustatus1515::chassis_err(const std::uint8_t* bytes,
137 int32_t length) const {
138 Byte t0(bytes + 7);
139 int32_t x = t0.get_byte(0, 8);
140
141 Byte t1(bytes + 6);
142 int32_t t = t1.get_byte(0, 8);
143 x <<= 8;
144 x |= t;
145
146 int ret = x;
147 return ret;
148}
149
150// config detail: {'bit': 48, 'description': 'Chassis error code (Chassis
151// status)', 'enum': {0: 'CHASSIS_ADS_ERR_NOMAL', 1:
152// 'CHASSIS_ADS_ERR_ADS_CAN_LOST', 2: 'CHASSIS_ADS_ERR_ADS_CAN_RECOVERY'},
153// 'is_signed_var': False, 'len': 2, 'name': 'chassis_ads_err', 'offset': 0.0,
154// 'order': 'intel', 'physical_range': '[0|2]', 'physical_unit': '',
155// 'precision': 1.0, 'type': 'enum'}
156Ecu_status_1_515::Chassis_ads_errType Ecustatus1515::chassis_ads_err(
157 const std::uint8_t* bytes, int32_t length) const {
158 Byte t0(bytes + 6);
159 int32_t x = t0.get_byte(0, 2);
160
163 return ret;
164}
165
166// config detail: {'bit': 50, 'enum': {0: 'CHASSIS_BMS_CAN_NORMAL', 1:
167// 'CHASSIS_BMS_CAN_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
168// 'chassis_bms_can', 'offset': 0.0, 'order': 'intel', 'physical_range':
169// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
170Ecu_status_1_515::Chassis_bms_canType Ecustatus1515::chassis_bms_can(
171 const std::uint8_t* bytes, int32_t length) const {
172 Byte t0(bytes + 6);
173 int32_t x = t0.get_byte(2, 1);
174
177 return ret;
178}
179
180// config detail: {'bit': 51, 'enum': {0: 'CHASSIS_EHB_CAN_NORMAL', 1:
181// 'CHASSIS_EHB_CAN_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
182// 'chassis_ehb_can', 'offset': 0.0, 'order': 'intel', 'physical_range':
183// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
184Ecu_status_1_515::Chassis_ehb_canType Ecustatus1515::chassis_ehb_can(
185 const std::uint8_t* bytes, int32_t length) const {
186 Byte t0(bytes + 6);
187 int32_t x = t0.get_byte(3, 1);
188
191 return ret;
192}
193
194// config detail: {'bit': 52, 'enum': {0: 'CHASSIS_EHB_ERR_NORMAL', 1:
195// 'CHASSIS_EHB_ERR_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
196// 'chassis_ehb_err', 'offset': 0.0, 'order': 'intel', 'physical_range':
197// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
198Ecu_status_1_515::Chassis_ehb_errType Ecustatus1515::chassis_ehb_err(
199 const std::uint8_t* bytes, int32_t length) const {
200 Byte t0(bytes + 6);
201 int32_t x = t0.get_byte(4, 1);
202
205 return ret;
206}
207
208// config detail: {'bit': 53, 'enum': {0: 'CHASSIS_EPS_CAN_NORMAL', 1:
209// 'CHASSIS_EPS_CAN_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
210// 'chassis_eps_can', 'offset': 0.0, 'order': 'intel', 'physical_range':
211// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
212Ecu_status_1_515::Chassis_eps_canType Ecustatus1515::chassis_eps_can(
213 const std::uint8_t* bytes, int32_t length) const {
214 Byte t0(bytes + 6);
215 int32_t x = t0.get_byte(5, 1);
216
219 return ret;
220}
221
222// config detail: {'bit': 54, 'enum': {0: 'CHASSIS_EPS_ERR_NORMAL', 1:
223// 'CHASSIS_EPS_ERR_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
224// 'chassis_eps_err', 'offset': 0.0, 'order': 'intel', 'physical_range':
225// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
226Ecu_status_1_515::Chassis_eps_errType Ecustatus1515::chassis_eps_err(
227 const std::uint8_t* bytes, int32_t length) const {
228 Byte t0(bytes + 6);
229 int32_t x = t0.get_byte(6, 1);
230
233 return ret;
234}
235
236// config detail: {'bit': 55, 'enum': {0: 'CHASSIS_HW_LOST_NORMAL', 1:
237// 'CHASSIS_HW_LOST_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
238// 'chassis_hw_lost', 'offset': 0.0, 'order': 'intel', 'physical_range':
239// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
240Ecu_status_1_515::Chassis_hw_lostType Ecustatus1515::chassis_hw_lost(
241 const std::uint8_t* bytes, int32_t length) const {
242 Byte t0(bytes + 6);
243 int32_t x = t0.get_byte(7, 1);
244
247 return ret;
248}
249
250// config detail: {'bit': 56, 'enum': {0: 'CHASSIS_MCU_CAN_NORMAL', 1:
251// 'CHASSIS_MCU_CAN_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
252// 'chassis_mcu_can', 'offset': 0.0, 'order': 'intel', 'physical_range':
253// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
254Ecu_status_1_515::Chassis_mcu_canType Ecustatus1515::chassis_mcu_can(
255 const std::uint8_t* bytes, int32_t length) const {
256 Byte t0(bytes + 7);
257 int32_t x = t0.get_byte(0, 1);
258
261 return ret;
262}
263
264// config detail: {'bit': 57, 'enum': {0: 'CHASSIS_MCU_ERR_NORMAL', 1:
265// 'CHASSIS_MCU_ERR_ERROR'}, 'is_signed_var': False, 'len': 1, 'name':
266// 'chassis_mcu_err', 'offset': 0.0, 'order': 'intel', 'physical_range':
267// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
268Ecu_status_1_515::Chassis_mcu_errType Ecustatus1515::chassis_mcu_err(
269 const std::uint8_t* bytes, int32_t length) const {
270 Byte t0(bytes + 7);
271 int32_t x = t0.get_byte(1, 1);
272
275 return ret;
276}
277} // namespace ch
278} // namespace canbus
279} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Ch *chassis) const override
class register implement
Definition arena_queue.h:37