Apollo 10.0
自动驾驶开放平台
ads_brake_command_46.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
20
21namespace apollo {
22namespace canbus {
23namespace neolix_edu {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Adsbrakecommand46::ID = 0x46;
28
29// public
31
33 // TODO(All) : modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Adsbrakecommand46::Parse(const std::uint8_t* bytes, int32_t length,
39 Neolix_edu* chassis) const {
40 chassis->mutable_ads_brake_command_46()->set_drive_enable(
41 drive_enable(bytes, length));
42 chassis->mutable_ads_brake_command_46()->set_auto_brake_command(
43 auto_brake_command(bytes, length));
44 chassis->mutable_ads_brake_command_46()->set_auto_parking_command(
45 auto_parking_command(bytes, length));
46}
47
48void Adsbrakecommand46::UpdateData(uint8_t* data) {
49 set_p_drive_enable(data, drive_enable_);
50 set_p_auto_brake_command(data, auto_brake_command_);
51 set_p_auto_parking_command(data, auto_parking_command_);
52 set_p_epb_rampauxiliarycommand(data, epb_rampauxiliarycommand_);
53 ++auto_drivercmd_alivecounter_;
54 auto_drivercmd_alivecounter_ = (auto_drivercmd_alivecounter_) % 16;
55 set_p_auto_drivercmd_alivecounter(data, auto_drivercmd_alivecounter_);
56 auto_drivercmd_checksum_ =
57 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
58 set_p_auto_drivercmd_checksum(data, auto_drivercmd_checksum_);
59}
60
62 // TODO(All) : you should check this manually
63 drive_enable_ = false;
64 auto_brake_command_ = 0;
65 auto_parking_command_ = false;
66 epb_rampauxiliarycommand_ = false;
67 auto_drivercmd_alivecounter_ = 0;
68 auto_drivercmd_checksum_ = 0;
69}
70
72 drive_enable_ = drive_enable;
73 return this;
74}
75
76// config detail: {'description': '0x0:disable ;0x1:enable', 'offset': 0.0,
77// 'precision': 1.0, 'len': 1, 'name': 'Drive_Enable', 'is_signed_var': False,
78// 'physical_range': '[0|0]', 'bit': 0, 'type': 'bool', 'order': 'motorola',
79// 'physical_unit': ''}
80void Adsbrakecommand46::set_p_drive_enable(uint8_t* data, bool drive_enable) {
81 int x = drive_enable;
82
83 Byte to_set(data + 0);
84 to_set.set_value(x, 0, 1);
85}
86
87bool Adsbrakecommand46::drive_enable(const std::uint8_t* bytes,
88 int32_t length) const {
89 Byte t0(bytes + 0);
90 int32_t x = t0.get_byte(0, 1);
91
92 bool ret = x;
93 return ret;
94}
95
97 int auto_brake_command) {
98 auto_brake_command_ = auto_brake_command;
99 return this;
100}
101
102// config detail: {'name': 'AUTO_Brake_Command', 'offset': 0.0,
103// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
104// '[0|0]', 'bit': 23, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
105void Adsbrakecommand46::set_p_auto_brake_command(uint8_t* data,
106 int auto_brake_command) {
107 auto_brake_command = ProtocolData::BoundedValue(0, 100, auto_brake_command);
108 int x = auto_brake_command;
109
110 Byte to_set(data + 2);
111 to_set.set_value(x, 0, 8);
112}
113
114int32_t Adsbrakecommand46::auto_brake_command(const std::uint8_t* bytes,
115 int32_t length) const {
116 Byte t0(bytes + 2);
117 int32_t x = t0.get_byte(0, 8);
118
119 int32_t ret = x;
120 return ret;
121}
122
124 bool auto_parking_command) {
125 auto_parking_command_ = auto_parking_command;
126 return this;
127}
128
129// config detail: {'description': '0x0:Release ;0x1:Apply ', 'offset': 0.0,
130// 'precision': 1.0, 'len': 1, 'name': 'AUTO_Parking_Command', 'is_signed_var':
131// False, 'physical_range': '[0|0]', 'bit': 24, 'type': 'bool', 'order':
132// 'motorola', 'physical_unit': ''}
133void Adsbrakecommand46::set_p_auto_parking_command(uint8_t* data,
134 bool auto_parking_command) {
135 int x = auto_parking_command;
136
137 Byte to_set(data + 3);
138 to_set.set_value(x, 0, 1);
139}
140
141bool Adsbrakecommand46::auto_parking_command(const std::uint8_t* bytes,
142 int32_t length) const {
143 Byte t0(bytes + 3);
144 int32_t x = t0.get_byte(0, 1);
145
146 bool ret = x;
147 return ret;
148}
149
151 bool epb_rampauxiliarycommand) {
152 epb_rampauxiliarycommand_ = epb_rampauxiliarycommand;
153 return this;
154}
155
156// config detail: {'description': '0x0:off;0x1:on', 'offset': 0.0,
157// 'precision': 1.0, 'len': 1, 'name': 'EPB_RampAuxiliaryCommand',
158// 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 25, 'type': 'bool',
159// 'order': 'motorola', 'physical_unit': ''}
160void Adsbrakecommand46::set_p_epb_rampauxiliarycommand(
161 uint8_t* data, bool epb_rampauxiliarycommand) {
162 int x = epb_rampauxiliarycommand;
163
164 Byte to_set(data + 3);
165 to_set.set_value(x, 1, 1);
166}
167
169 int auto_drivercmd_alivecounter) {
170 auto_drivercmd_alivecounter_ = auto_drivercmd_alivecounter;
171 return this;
172}
173
174// config detail: {'name': 'AUTO_DriverCmd_AliveCounter', 'offset': 0.0,
175// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
176// '[0|0]', 'bit': 51, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
177void Adsbrakecommand46::set_p_auto_drivercmd_alivecounter(
178 uint8_t* data, int auto_drivercmd_alivecounter) {
179 auto_drivercmd_alivecounter =
180 ProtocolData::BoundedValue(0, 15, auto_drivercmd_alivecounter);
181 int x = auto_drivercmd_alivecounter;
182
183 Byte to_set(data + 6);
184 to_set.set_value(x, 0, 4);
185}
186
188 int auto_drivercmd_checksum) {
189 auto_drivercmd_checksum_ = auto_drivercmd_checksum;
190 return this;
191}
192
193// config detail: {'name': 'AUTO_DriverCmd_CheckSum', 'offset': 0.0,
194// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
195// '[0|0]', 'bit': 63, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
196void Adsbrakecommand46::set_p_auto_drivercmd_checksum(
197 uint8_t* data, int auto_drivercmd_checksum) {
198 auto_drivercmd_checksum =
199 ProtocolData::BoundedValue(0, 255, auto_drivercmd_checksum);
200 int x = auto_drivercmd_checksum;
201
202 Byte to_set(data + 7);
203 to_set.set_value(x, 0, 8);
204}
205
206} // namespace neolix_edu
207} // namespace canbus
208} // namespace apollo
Defines the Byte class.
Adsbrakecommand46 * set_auto_drivercmd_alivecounter(int auto_drivercmd_alivecounter)
Adsbrakecommand46 * set_auto_brake_command(int auto_brake_command)
Adsbrakecommand46 * set_epb_rampauxiliarycommand(bool epb_rampauxiliarycommand)
Adsbrakecommand46 * set_drive_enable(bool drive_enable)
Adsbrakecommand46 * set_auto_parking_command(bool auto_parking_command)
void Parse(const std::uint8_t *bytes, int32_t length, Neolix_edu *chassis) const override
Adsbrakecommand46 * set_auto_drivercmd_checksum(int auto_drivercmd_checksum)
class register implement
Definition arena_queue.h:37