Apollo 10.0
自动驾驶开放平台
vehicle_mode_command_105.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 demo {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Vehiclemodecommand105::ID = 0x105;
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 Vehiclemodecommand105::Parse(const std::uint8_t* bytes, int32_t length,
39 Demo* chassis) const {
40 chassis->mutable_vehicle_mode_command_105()->set_heartbeat_105(
41 heartbeat_105(bytes, length));
42 chassis->mutable_vehicle_mode_command_105()->set_checksum_105(
43 checksum_105(bytes, length));
44 chassis->mutable_vehicle_mode_command_105()->set_turn_light_ctrl(
45 turn_light_ctrl(bytes, length));
46 chassis->mutable_vehicle_mode_command_105()->set_vin_req(
47 vin_req(bytes, length));
48 chassis->mutable_vehicle_mode_command_105()->set_drive_mode_ctrl(
49 drive_mode_ctrl(bytes, length));
50 chassis->mutable_vehicle_mode_command_105()->set_steer_mode_ctrl(
51 steer_mode_ctrl(bytes, length));
52}
53
55 // TODO(All) : you should add the heartbeat manually
56 ++heartbeat_105_;
57 heartbeat_105_ = (heartbeat_105_) % 16;
58 set_p_heartbeat_105(data, heartbeat_105_);
59 checksum_105_ =
60 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
61 set_p_checksum_105(data, checksum_105_);
62}
63
65 set_p_turn_light_ctrl(data, turn_light_ctrl_);
66 set_p_vin_req(data, vin_req_);
67 set_p_drive_mode_ctrl(data, drive_mode_ctrl_);
68 set_p_steer_mode_ctrl(data, steer_mode_ctrl_);
69}
70
72 // TODO(All) : you should check this manually
73 heartbeat_105_ = 0;
74 checksum_105_ = 0;
77 drive_mode_ctrl_ =
80}
81
83 int heartbeat_105) {
84 heartbeat_105_ = heartbeat_105;
85 return this;
86}
87
88// config detail: {'bit': 7, 'is_signed_var': False, 'len': 4, 'name':
89// 'Heartbeat_105', 'offset': 0.0, 'order': 'motorola', 'physical_range':
90// '[0|15]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
91void Vehiclemodecommand105::set_p_heartbeat_105(uint8_t* data,
92 int heartbeat_105) {
93 heartbeat_105 = ProtocolData::BoundedValue(0, 15, heartbeat_105);
94 int x = heartbeat_105;
95
96 Byte to_set(data + 0);
97 to_set.set_value(x, 4, 4);
98}
99
101 int checksum_105) {
102 checksum_105_ = checksum_105;
103 return this;
104}
105
106// config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name':
107// 'CheckSum_105', 'offset': 0.0, 'order': 'motorola', 'physical_range':
108// '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
109void Vehiclemodecommand105::set_p_checksum_105(uint8_t* data,
110 int checksum_105) {
111 checksum_105 = ProtocolData::BoundedValue(0, 255, checksum_105);
112 int x = checksum_105;
113
114 Byte to_set(data + 7);
115 to_set.set_value(x, 0, 8);
116}
117
120 turn_light_ctrl_ = turn_light_ctrl;
121 return this;
122}
123
124// config detail: {'bit': 17, 'enum': {0: 'TURN_LIGHT_CTRL_TURNLAMP_OFF', 1:
125// 'TURN_LIGHT_CTRL_LEFT_TURNLAMP_ON', 2: 'TURN_LIGHT_CTRL_RIGHT_TURNLAMP_ON',
126// 3: 'TURN_LIGHT_CTRL_HAZARD_WARNING_LAMPSTS_ON'}, 'is_signed_var': False,
127// 'len': 2, 'name': 'Turn_Light_CTRL', 'offset': 0.0, 'order': 'motorola',
128// 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type':
129// 'enum'}
130void Vehiclemodecommand105::set_p_turn_light_ctrl(
131 uint8_t* data,
133 int x = turn_light_ctrl;
134
135 Byte to_set(data + 2);
136 to_set.set_value(x, 0, 2);
137}
138
141 vin_req_ = vin_req;
142 return this;
143}
144
145// config detail: {'bit': 24, 'enum': {0: 'VIN_REQ_VIN_REQ_DISABLE', 1:
146// 'VIN_REQ_VIN_REQ_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name':
147// 'VIN_Req', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|1]',
148// 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
149void Vehiclemodecommand105::set_p_vin_req(
150 uint8_t* data, Vehicle_mode_command_105::Vin_reqType vin_req) {
151 int x = vin_req;
152
153 Byte to_set(data + 3);
154 to_set.set_value(x, 0, 1);
155}
156
159 drive_mode_ctrl_ = drive_mode_ctrl;
160 return this;
161}
162
163// config detail: {'bit': 10, 'enum': {0:
164// 'DRIVE_MODE_CTRL_THROTTLE_PADDLE_DRIVE', 1: 'DRIVE_MODE_CTRL_SPEED_DRIVE'},
165// 'is_signed_var': False, 'len': 3, 'name': 'Drive_Mode_CTRL', 'offset': 0.0,
166// 'order': 'motorola', 'physical_range': '[0|7]', 'physical_unit': '',
167// 'precision': 1.0, 'type': 'enum'}
168void Vehiclemodecommand105::set_p_drive_mode_ctrl(
169 uint8_t* data,
171 int x = drive_mode_ctrl;
172
173 Byte to_set(data + 1);
174 to_set.set_value(x, 0, 3);
175}
176
179 steer_mode_ctrl_ = steer_mode_ctrl;
180 return this;
181}
182
183// config detail: {'bit': 2, 'enum': {0: 'STEER_MODE_CTRL_STANDARD_STEER', 1:
184// 'STEER_MODE_CTRL_NON_DIRECTION_STEER', 2:
185// 'STEER_MODE_CTRL_SYNC_DIRECTION_STEER'}, 'is_signed_var': False, 'len': 3,
186// 'name': 'Steer_Mode_CTRL', 'offset': 0.0, 'order': 'motorola',
187// 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type':
188// 'enum'}
189void Vehiclemodecommand105::set_p_steer_mode_ctrl(
190 uint8_t* data,
192 int x = steer_mode_ctrl;
193
194 Byte to_set(data + 0);
195 to_set.set_value(x, 0, 3);
196}
197
198int Vehiclemodecommand105::heartbeat_105(const std::uint8_t* bytes,
199 int32_t length) const {
200 Byte t0(bytes + 0);
201 int32_t x = t0.get_byte(4, 4);
202
203 int ret = x;
204 return ret;
205}
206
207int Vehiclemodecommand105::checksum_105(const std::uint8_t* bytes,
208 int32_t length) const {
209 Byte t0(bytes + 7);
210 int32_t x = t0.get_byte(0, 8);
211
212 int ret = x;
213 return ret;
214}
215
217Vehiclemodecommand105::turn_light_ctrl(const std::uint8_t* bytes,
218 int32_t length) const {
219 Byte t0(bytes + 2);
220 int32_t x = t0.get_byte(0, 2);
221
224 return ret;
225}
226
227Vehicle_mode_command_105::Vin_reqType Vehiclemodecommand105::vin_req(
228 const std::uint8_t* bytes, int32_t length) const {
229 Byte t0(bytes + 3);
230 int32_t x = t0.get_byte(0, 1);
231
234 return ret;
235}
236
238Vehiclemodecommand105::drive_mode_ctrl(const std::uint8_t* bytes,
239 int32_t length) const {
240 Byte t0(bytes + 1);
241 int32_t x = t0.get_byte(0, 3);
242
245 return ret;
246}
247
249Vehiclemodecommand105::steer_mode_ctrl(const std::uint8_t* bytes,
250 int32_t length) const {
251 Byte t0(bytes + 0);
252 int32_t x = t0.get_byte(0, 3);
253
256 return ret;
257}
258} // namespace demo
259} // namespace canbus
260} // namespace apollo
Defines the Byte class.
Vehiclemodecommand105 * set_heartbeat_105(int heartbeat_105)
Vehiclemodecommand105 * set_vin_req(Vehicle_mode_command_105::Vin_reqType vin_req)
Vehiclemodecommand105 * set_steer_mode_ctrl(Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl)
Vehiclemodecommand105 * set_turn_light_ctrl(Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl)
Vehiclemodecommand105 * set_checksum_105(int checksum_105)
void Parse(const std::uint8_t *bytes, int32_t length, Demo *chassis) const override
Vehiclemodecommand105 * set_drive_mode_ctrl(Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl)
class register implement
Definition arena_queue.h:37