Apollo 10.0
自动驾驶开放平台
vcu_eps_report_57.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 Vcuepsreport57::ID = 0x57;
32
33void Vcuepsreport57::Parse(const std::uint8_t* bytes, int32_t length,
34 Neolix_edu* chassis) const {
35 chassis->mutable_vcu_eps_report_57()->set_drive_enable_resp(
36 drive_enable_resp(bytes, length));
37 chassis->mutable_vcu_eps_report_57()->set_control_mode_resp(
38 control_mode_resp(bytes, length));
39 chassis->mutable_vcu_eps_report_57()->set_vcu_eps_report(
40 vcu_eps_report(bytes, length));
41 chassis->mutable_vcu_eps_report_57()->set_vcu_real_angle(
42 vcu_real_angle(bytes, length));
43 chassis->mutable_vcu_eps_report_57()->set_vcu_real_angle_valid(
44 vcu_real_angle_valid(bytes, length));
45 chassis->mutable_vcu_eps_report_57()->set_vcu_target_angle_valid(
46 vcu_target_angle_valid(bytes, length));
47 chassis->mutable_vcu_eps_report_57()->set_vcu_target_angle(
48 vcu_target_angle(bytes, length));
49 chassis->mutable_vcu_eps_report_57()->set_vcu_eps_rept_alivecounter(
50 vcu_eps_rept_alivecounter(bytes, length));
51 chassis->mutable_vcu_eps_report_57()->set_vcu_eps_rept_checksum(
52 vcu_eps_rept_checksum(bytes, length));
53
54 chassis->mutable_eps()->set_steering_angle(vcu_real_angle(bytes, length));
55}
56
57// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
58// 'precision': 1.0, 'len': 1, 'name': 'drive_enable_resp', 'is_signed_var':
59// False, 'physical_range': '[0|0]', 'bit': 0, 'type': 'bool', 'order':
60// 'motorola', 'physical_unit': ''}
61bool Vcuepsreport57::drive_enable_resp(const std::uint8_t* bytes,
62 int32_t length) const {
63 Byte t0(bytes + 0);
64 int32_t x = t0.get_byte(0, 1);
65
66 bool ret = x;
67 return ret;
68}
69
70// config detail: {'description': '0x0:Standby;0x1:auto drive;0x2:net
71// drive;0x3:remote control;0x4:emergency brake;0x5~0x7:Reserved', 'enum': {0:
72// 'CONTROL_MODE_RESP_STANDBY', 1: 'CONTROL_MODE_RESP_AUTO_DRIVE', 2:
73// 'CONTROL_MODE_RESP_NET_DRIVE', 3: 'CONTROL_MODE_RESP_REMOTE_CONTROL', 4:
74// 'CONTROL_MODE_RESP_EMERGENCY_BRAKE'}, 'precision': 1.0, 'len': 3, 'name':
75// 'control_mode_resp', 'is_signed_var': False, 'offset': 0.0, 'physical_range':
76// '[0|7]', 'bit': 6, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
77Vcu_eps_report_57::Control_mode_respType Vcuepsreport57::control_mode_resp(
78 const std::uint8_t* bytes, int32_t length) const {
79 Byte t0(bytes + 0);
80 int32_t x = t0.get_byte(4, 3);
81
84 return ret;
85}
86
87// config detail: {'description': '0x0:not overflow;0x1:overflow', 'offset':
88// 0.0, 'precision': 1.0, 'len': 1, 'name': 'vcu_eps_report', 'is_signed_var':
89// False, 'physical_range': '[0|0]', 'bit': 7, 'type': 'bool', 'order':
90// 'motorola', 'physical_unit': ''}
91bool Vcuepsreport57::vcu_eps_report(const std::uint8_t* bytes,
92 int32_t length) const {
93 Byte t0(bytes + 0);
94 int32_t x = t0.get_byte(7, 1);
95
96 bool ret = x;
97 return ret;
98}
99
100// config detail: {'description': ';', 'offset': -2048.0, 'precision': 0.0625,
101// 'len': 16, 'name': 'vcu_real_angle', 'is_signed_var': False,
102// 'physical_range': '[0|0]', 'bit': 23, 'type': 'double', 'order': 'motorola',
103// 'physical_unit': ''}
104double Vcuepsreport57::vcu_real_angle(const std::uint8_t* bytes,
105 int32_t length) const {
106 Byte t0(bytes + 2);
107 int32_t x = t0.get_byte(0, 8);
108
109 Byte t1(bytes + 3);
110 int32_t t = t1.get_byte(0, 8);
111 x <<= 8;
112 x |= t;
113
114 double ret = x * 0.062500 + -2048.000000;
115 return -ret;
116}
117
118// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
119// 'precision': 1.0, 'len': 1, 'name': 'vcu_real_angle_valid', 'is_signed_var':
120// False, 'physical_range': '[0|0]', 'bit': 32, 'type': 'bool', 'order':
121// 'motorola', 'physical_unit': ''}
122bool Vcuepsreport57::vcu_real_angle_valid(const std::uint8_t* bytes,
123 int32_t length) const {
124 Byte t0(bytes + 4);
125 int32_t x = t0.get_byte(0, 1);
126
127 bool ret = x;
128 return ret;
129}
130
131// config detail: {'description': '0x0:disable;0x1:enable;', 'offset': 0.0,
132// 'precision': 1.0, 'len': 1, 'name': 'vcu_target_angle_valid',
133// 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 33, 'type': 'bool',
134// 'order': 'motorola', 'physical_unit': ''}
135bool Vcuepsreport57::vcu_target_angle_valid(const std::uint8_t* bytes,
136 int32_t length) const {
137 Byte t0(bytes + 4);
138 int32_t x = t0.get_byte(1, 1);
139
140 bool ret = x;
141 return ret;
142}
143
144// config detail: {'name': 'vcu_target_angle', 'offset': -512.0, 'precision':
145// 0.25, 'len': 12, 'is_signed_var': False, 'physical_range': '[-380|380]',
146// 'bit': 47, 'type': 'double', 'order': 'motorola', 'physical_unit': 'deg'}
147double Vcuepsreport57::vcu_target_angle(const std::uint8_t* bytes,
148 int32_t length) const {
149 Byte t0(bytes + 5);
150 int32_t x = t0.get_byte(0, 8);
151
152 Byte t1(bytes + 6);
153 int32_t t = t1.get_byte(4, 4);
154 x <<= 4;
155 x |= t;
156
157 double ret = x * 0.250000 + -512.000000;
158 return ret;
159}
160
161// config detail: {'name': 'vcu_eps_rept_alivecounter', 'offset': 0.0,
162// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
163// '[0|0]', 'bit': 51, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
164int Vcuepsreport57::vcu_eps_rept_alivecounter(const std::uint8_t* bytes,
165 int32_t length) const {
166 Byte t0(bytes + 6);
167 int32_t x = t0.get_byte(0, 4);
168
169 int ret = x;
170 return ret;
171}
172
173// config detail: {'name': 'vcu_eps_rept_checksum', 'offset': 0.0,
174// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
175// '[0|0]', 'bit': 63, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
176int Vcuepsreport57::vcu_eps_rept_checksum(const std::uint8_t* bytes,
177 int32_t length) const {
178 Byte t0(bytes + 7);
179 int32_t x = t0.get_byte(0, 8);
180
181 int ret = x;
182 return ret;
183}
184} // namespace neolix_edu
185} // namespace canbus
186} // 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