Apollo 10.0
自动驾驶开放平台
vcu_drive_report_52.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 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 neolix_edu {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Vcudrivereport52::ID = 0x52;
32
33void Vcudrivereport52::Parse(const std::uint8_t* bytes, int32_t length,
34 Neolix_edu* chassis) const {
35 chassis->mutable_vcu_drive_report_52()->set_drive_enable_resp(
36 drive_enable_resp(bytes, length));
37 chassis->mutable_vcu_drive_report_52()->set_control_mode_resp(
38 control_mode_resp(bytes, length));
39 chassis->mutable_vcu_drive_report_52()->set_vcu_real_shift(
40 vcu_real_shift(bytes, length));
41 chassis->mutable_vcu_drive_report_52()->set_vcu_real_shift_valid(
42 vcu_real_shift_valid(bytes, length));
43 chassis->mutable_vcu_drive_report_52()->set_vcu_real_torque_valid(
44 vcu_real_torque_valid(bytes, length));
45 chassis->mutable_vcu_drive_report_52()->set_vcu_real_torque(
46 vcu_real_torque(bytes, length));
47 chassis->mutable_vcu_drive_report_52()->set_vcu_limitedtorquemode(
48 vcu_limitedtorquemode(bytes, length));
49 chassis->mutable_vcu_drive_report_52()->set_vcu_driverept_alivecounter(
50 vcu_driverept_alivecounter(bytes, length));
51 chassis->mutable_vcu_drive_report_52()->set_vcu_driverept_checksum(
52 vcu_driverept_checksum(bytes, length));
53
54 chassis->mutable_safety()->set_driving_mode(Chassis::COMPLETE_AUTO_DRIVE);
55 chassis->mutable_gas()->set_gas_pedal_position(
56 vcu_real_torque(bytes, length));
57 chassis->mutable_gear()->set_gear_state(
58 (apollo::canbus::Chassis_GearPosition)vcu_real_shift(bytes, length));
59}
60
61// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
62// 'precision': 1.0, 'len': 1, 'name': 'drive_enable_resp', 'is_signed_var':
63// False, 'physical_range': '[0|0]', 'bit': 0, 'type': 'bool', 'order':
64// 'motorola', 'physical_unit': ''}
65bool Vcudrivereport52::drive_enable_resp(const std::uint8_t* bytes,
66 int32_t length) const {
67 Byte t0(bytes + 0);
68 int32_t x = t0.get_byte(0, 1);
69
70 bool ret = x;
71 return ret;
72}
73
74// config detail: {'description': '0x0:Standby;0x1:auto drive;0x2:net
75// drive;0x3:remote control;0x4:emergency brake;0x5~0x7:Reserved', 'enum': {0:
76// 'CONTROL_MODE_RESP_STANDBY', 1: 'CONTROL_MODE_RESP_AUTO_DRIVE', 2:
77// 'CONTROL_MODE_RESP_NET_DRIVE', 3: 'CONTROL_MODE_RESP_REMOTE_CONTROL', 4:
78// 'CONTROL_MODE_RESP_EMERGENCY_BRAKE'}, 'precision': 1.0, 'len': 3, 'name':
79// 'control_mode_resp', 'is_signed_var': False, 'offset': 0.0, 'physical_range':
80// '[0|7]', 'bit': 6, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
81Vcu_drive_report_52::Control_mode_respType Vcudrivereport52::control_mode_resp(
82 const std::uint8_t* bytes, int32_t length) const {
83 Byte t0(bytes + 0);
84 int32_t x = t0.get_byte(4, 3);
85
88 return ret;
89}
90
91// config detail: {'description':
92// '0x0:N\xe6\xa1\xa3;0x1:D\xe6\xa1\xa3;0x2:R\xe6\xa1\xa3;0x3:Reserved', 'enum':
93// {0: 'VCU_REAL_SHIFT_N', 1: 'VCU_REAL_SHIFT_D', 2: 'VCU_REAL_SHIFT_R', 3:
94// 'VCU_REAL_SHIFT_RESERVED'}, 'precision': 1.0, 'len': 2, 'name':
95// 'vcu_real_shift', 'is_signed_var': False, 'offset': 0.0, 'physical_range':
96// '[0|3]', 'bit': 9, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
97Vcu_drive_report_52::Vcu_real_shiftType Vcudrivereport52::vcu_real_shift(
98 const std::uint8_t* bytes, int32_t length) const {
99 Byte t0(bytes + 1);
100 int32_t x = t0.get_byte(0, 2);
101
104 return ret;
105}
106
107// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
108// 'precision': 1.0, 'len': 1, 'name': 'vcu_real_shift_valid', 'is_signed_var':
109// False, 'physical_range': '[0|0]', 'bit': 10, 'type': 'bool', 'order':
110// 'motorola', 'physical_unit': ''}
111bool Vcudrivereport52::vcu_real_shift_valid(const std::uint8_t* bytes,
112 int32_t length) const {
113 Byte t0(bytes + 1);
114 int32_t x = t0.get_byte(2, 1);
115
116 bool ret = x;
117 return ret;
118}
119
120// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
121// 'precision': 1.0, 'len': 1, 'name': 'vcu_real_torque_valid', 'is_signed_var':
122// False, 'physical_range': '[0|0]', 'bit': 11, 'type': 'bool', 'order':
123// 'motorola', 'physical_unit': ''}
124bool Vcudrivereport52::vcu_real_torque_valid(const std::uint8_t* bytes,
125 int32_t length) const {
126 Byte t0(bytes + 1);
127 int32_t x = t0.get_byte(3, 1);
128
129 bool ret = x;
130 return ret;
131}
132
133// config detail: {'name': 'vcu_real_torque', 'offset': -665.0, 'precision':
134// 0.02, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
135// 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'Nm'}
136double Vcudrivereport52::vcu_real_torque(const std::uint8_t* bytes,
137 int32_t length) const {
138 Byte t0(bytes + 2);
139 int32_t x = t0.get_byte(0, 8);
140
141 Byte t1(bytes + 3);
142 int32_t t = t1.get_byte(0, 8);
143 x <<= 8;
144 x |= t;
145
146 double ret = x * 0.020000 + -665.000000;
147 return ret;
148}
149
150// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
151// 'precision': 1.0, 'len': 1, 'name': 'vcu_limitedtorquemode', 'is_signed_var':
152// False, 'physical_range': '[0|0]', 'bit': 32, 'type': 'bool', 'order':
153// 'motorola', 'physical_unit': ''}
154bool Vcudrivereport52::vcu_limitedtorquemode(const std::uint8_t* bytes,
155 int32_t length) const {
156 Byte t0(bytes + 4);
157 int32_t x = t0.get_byte(0, 1);
158
159 bool ret = x;
160 return ret;
161}
162
163// config detail: {'name': 'vcu_driverept_alivecounter', 'offset': 0.0,
164// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
165// '[0|0]', 'bit': 51, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
166int Vcudrivereport52::vcu_driverept_alivecounter(const std::uint8_t* bytes,
167 int32_t length) const {
168 Byte t0(bytes + 6);
169 int32_t x = t0.get_byte(0, 4);
170
171 int ret = x;
172 return ret;
173}
174
175// config detail: {'name': 'vcu_driverept_checksum', 'offset': 0.0,
176// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
177// '[0|0]', 'bit': 63, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
178int Vcudrivereport52::vcu_driverept_checksum(const std::uint8_t* bytes,
179 int32_t length) const {
180 Byte t0(bytes + 7);
181 int32_t x = t0.get_byte(0, 8);
182
183 int ret = x;
184 return ret;
185}
186} // namespace neolix_edu
187} // namespace canbus
188} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Neolix_edu *chassis) const override
class register implement
Definition arena_queue.h:37