Apollo 10.0
自动驾驶开放平台
accel_rpt_200.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 lexus {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Accelrpt200::ID = 0x200;
32
33void Accelrpt200::Parse(const std::uint8_t* bytes, int32_t length,
34 Lexus* chassis) const {
35 chassis->mutable_accel_rpt_200()->set_vehicle_fault(
36 vehicle_fault(bytes, length));
37 chassis->mutable_accel_rpt_200()->set_pacmod_fault(
38 pacmod_fault(bytes, length));
39 chassis->mutable_accel_rpt_200()->set_output_reported_fault(
40 output_reported_fault(bytes, length));
41 chassis->mutable_accel_rpt_200()->set_input_output_fault(
42 input_output_fault(bytes, length));
43 chassis->mutable_accel_rpt_200()->set_command_output_fault(
44 command_output_fault(bytes, length));
45 chassis->mutable_accel_rpt_200()->set_override_active(
46 override_active(bytes, length));
47 chassis->mutable_accel_rpt_200()->set_enabled(
48 enabled(bytes, length));
49 chassis->mutable_accel_rpt_200()->set_manual_input(
50 manual_input(bytes, length));
51 chassis->mutable_accel_rpt_200()->set_commanded_value(
52 commanded_value(bytes, length));
53 chassis->mutable_accel_rpt_200()->set_output_value(
54 output_value(bytes, length));
55}
56
57// config detail: {'name': 'vehicle_fault', 'offset': 0.0, 'precision': 1.0,
58// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6,
59// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
60bool Accelrpt200::vehicle_fault(const std::uint8_t* bytes,
61 int32_t length) const {
62 Byte t0(bytes + 0);
63 int32_t x = t0.get_byte(6, 1);
64
65 bool ret = x;
66 return ret;
67}
68
69// config detail: {'name': 'pacmod_fault', 'offset': 0.0, 'precision': 1.0,
70// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5,
71// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
72bool Accelrpt200::pacmod_fault(const std::uint8_t* bytes,
73 int32_t length) const {
74 Byte t0(bytes + 0);
75 int32_t x = t0.get_byte(5, 1);
76
77 bool ret = x;
78 return ret;
79}
80
81// config detail: {'name': 'output_reported_fault', 'offset': 0.0,
82// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
83// '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
84bool Accelrpt200::output_reported_fault(const std::uint8_t* bytes,
85 int32_t length) const {
86 Byte t0(bytes + 0);
87 int32_t x = t0.get_byte(4, 1);
88
89 bool ret = x;
90 return ret;
91}
92
93// config detail: {'name': 'input_output_fault', 'offset': 0.0,
94// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
95// '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
96bool Accelrpt200::input_output_fault(const std::uint8_t* bytes,
97 int32_t length) const {
98 Byte t0(bytes + 0);
99 int32_t x = t0.get_byte(3, 1);
100
101 bool ret = x;
102 return ret;
103}
104
105// config detail: {'name': 'command_output_fault', 'offset': 0.0,
106// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
107// '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
108bool Accelrpt200::command_output_fault(const std::uint8_t* bytes,
109 int32_t length) const {
110 Byte t0(bytes + 0);
111 int32_t x = t0.get_byte(2, 1);
112
113 bool ret = x;
114 return ret;
115}
116
117// config detail: {'name': 'override_active', 'offset': 0.0, 'precision': 1.0,
118// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1,
119// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
120bool Accelrpt200::override_active(const std::uint8_t* bytes,
121 int32_t length) const {
122 Byte t0(bytes + 0);
123 int32_t x = t0.get_byte(1, 1);
124
125 bool ret = x;
126 return ret;
127}
128
129// config detail: {'name': 'enabled', 'offset': 0.0, 'precision': 1.0, 'len': 1,
130// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool',
131// 'order': 'motorola', 'physical_unit': ''}
132bool Accelrpt200::enabled(const std::uint8_t* bytes, int32_t length) const {
133 Byte t0(bytes + 0);
134 int32_t x = t0.get_byte(0, 1);
135
136 bool ret = x;
137 return ret;
138}
139
140// config detail: {'name': 'manual_input', 'offset': 0.0, 'precision': 0.001,
141// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 15,
142// 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
143double Accelrpt200::manual_input(const std::uint8_t* bytes,
144 int32_t length) const {
145 Byte t0(bytes + 1);
146 int32_t x = t0.get_byte(0, 8);
147
148 Byte t1(bytes + 2);
149 int32_t t = t1.get_byte(0, 8);
150 x <<= 8;
151 x |= t;
152
153 double ret = x * 0.001000;
154 return ret;
155}
156
157// config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 0.001,
158// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 31,
159// 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
160double Accelrpt200::commanded_value(const std::uint8_t* bytes,
161 int32_t length) const {
162 Byte t0(bytes + 3);
163 int32_t x = t0.get_byte(0, 8);
164
165 Byte t1(bytes + 4);
166 int32_t t = t1.get_byte(0, 8);
167 x <<= 8;
168 x |= t;
169
170 double ret = x * 0.001000;
171 return ret;
172}
173
174// config detail: {'name': 'output_value', 'offset': 0.0, 'precision': 0.001,
175// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 47,
176// 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
177double Accelrpt200::output_value(const std::uint8_t* bytes,
178 int32_t length) const {
179 Byte t0(bytes + 5);
180 int32_t x = t0.get_byte(0, 8);
181
182 Byte t1(bytes + 6);
183 int32_t t = t1.get_byte(0, 8);
184 x <<= 8;
185 x |= t;
186
187 double ret = x * 0.001000;
188 return ret;
189}
190} // namespace lexus
191} // namespace canbus
192} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Lexus *chassis) const override
class register implement
Definition arena_queue.h:37