Apollo 10.0
自动驾驶开放平台
vehicle_mode_command_105.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 devkit {
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 Devkit* chassis) const {
40 chassis->mutable_vehicle_mode_command_105()->set_turn_light_ctrl(
41 turn_light_ctrl(bytes, length));
42 chassis->mutable_vehicle_mode_command_105()->set_vin_req(
43 vin_req(bytes, length));
44 chassis->mutable_vehicle_mode_command_105()->set_drive_mode_ctrl(
45 drive_mode_ctrl(bytes, length));
46 chassis->mutable_vehicle_mode_command_105()->set_steer_mode_ctrl(
47 steer_mode_ctrl(bytes, length));
48 chassis->mutable_vehicle_mode_command_105()->set_checksum_105(
49 checksum_105(bytes, length));
50}
51
53 set_p_turn_light_ctrl(data, turn_light_ctrl_);
54 set_p_vin_req(data, vin_req_);
55 set_p_drive_mode_ctrl(data, drive_mode_ctrl_);
56 set_p_steer_mode_ctrl(data, steer_mode_ctrl_);
57 checksum_105_ =
58 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
59 set_p_checksum_105(data, checksum_105_);
60}
61
63 // TODO(All) : you should check this manually
64 checksum_105_ = 0;
67 drive_mode_ctrl_ =
70}
71
73 int checksum_105) {
74 checksum_105_ = checksum_105;
75 return this;
76}
77
78// config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name':
79// 'CheckSum_105', 'offset': 0.0, 'order': 'motorola', 'physical_range':
80// '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
81void Vehiclemodecommand105::set_p_checksum_105(uint8_t* data,
82 int checksum_105) {
83 checksum_105 = ProtocolData::BoundedValue(0, 255, checksum_105);
84 int x = checksum_105;
85
86 Byte to_set(data + 7);
87 to_set.set_value(x, 0, 8);
88}
89
92 turn_light_ctrl_ = turn_light_ctrl;
93 return this;
94}
95
96// config detail: {'bit': 17, 'enum': {0: 'TURN_LIGHT_CTRL_TURNLAMP_OFF', 1:
97// 'TURN_LIGHT_CTRL_LEFT_TURNLAMP_ON', 2: 'TURN_LIGHT_CTRL_RIGHT_TURNLAMP_ON',
98// 3: 'TURN_LIGHT_CTRL_HAZARD_WARNING_LAMPSTS_ON'}, 'is_signed_var': False,
99// 'len': 2, 'name': 'Turn_Light_CTRL', 'offset': 0.0, 'order': 'motorola',
100// 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type':
101// 'enum'}
102void Vehiclemodecommand105::set_p_turn_light_ctrl(
103 uint8_t* data,
105 int x = turn_light_ctrl;
106
107 Byte to_set(data + 2);
108 to_set.set_value(x, 0, 2);
109}
110
113 vin_req_ = vin_req;
114 return this;
115}
116
117// config detail: {'bit': 24, 'enum': {0: 'VIN_REQ_VIN_REQ_DISABLE', 1:
118// 'VIN_REQ_VIN_REQ_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name':
119// 'VIN_Req', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|1]',
120// 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
121void Vehiclemodecommand105::set_p_vin_req(
122 uint8_t* data, Vehicle_mode_command_105::Vin_reqType vin_req) {
123 int x = vin_req;
124
125 Byte to_set(data + 3);
126 to_set.set_value(x, 0, 1);
127}
128
131 drive_mode_ctrl_ = drive_mode_ctrl;
132 return this;
133}
134
135// config detail: {'bit': 10, 'enum': {0:
136// 'DRIVE_MODE_CTRL_THROTTLE_PADDLE_DRIVE', 1: 'DRIVE_MODE_CTRL_SPEED_DRIVE'},
137// 'is_signed_var': False, 'len': 3, 'name': 'Drive_Mode_CTRL', 'offset': 0.0,
138// 'order': 'motorola', 'physical_range': '[0|7]', 'physical_unit': '',
139// 'precision': 1.0, 'type': 'enum'}
140void Vehiclemodecommand105::set_p_drive_mode_ctrl(
141 uint8_t* data,
143 int x = drive_mode_ctrl;
144
145 Byte to_set(data + 1);
146 to_set.set_value(x, 0, 3);
147}
148
151 steer_mode_ctrl_ = steer_mode_ctrl;
152 return this;
153}
154
155// config detail: {'bit': 2, 'enum': {0: 'STEER_MODE_CTRL_STANDARD_STEER', 1:
156// 'STEER_MODE_CTRL_NON_DIRECTION_STEER', 2:
157// 'STEER_MODE_CTRL_SYNC_DIRECTION_STEER'}, 'is_signed_var': False, 'len': 3,
158// 'name': 'Steer_Mode_CTRL', 'offset': 0.0, 'order': 'motorola',
159// 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type':
160// 'enum'}
161void Vehiclemodecommand105::set_p_steer_mode_ctrl(
162 uint8_t* data,
164 int x = steer_mode_ctrl;
165
166 Byte to_set(data + 0);
167 to_set.set_value(x, 0, 3);
168}
169
171Vehiclemodecommand105::turn_light_ctrl(const std::uint8_t* bytes,
172 int32_t length) const {
173 Byte t0(bytes + 2);
174 int32_t x = t0.get_byte(0, 2);
175
178 return ret;
179}
180
181Vehicle_mode_command_105::Vin_reqType Vehiclemodecommand105::vin_req(
182 const std::uint8_t* bytes, int32_t length) const {
183 Byte t0(bytes + 3);
184 int32_t x = t0.get_byte(0, 1);
185
188 return ret;
189}
190
192Vehiclemodecommand105::drive_mode_ctrl(const std::uint8_t* bytes,
193 int32_t length) const {
194 Byte t0(bytes + 1);
195 int32_t x = t0.get_byte(0, 3);
196
199 return ret;
200}
201
203Vehiclemodecommand105::steer_mode_ctrl(const std::uint8_t* bytes,
204 int32_t length) const {
205 Byte t0(bytes + 0);
206 int32_t x = t0.get_byte(0, 3);
207
210 return ret;
211}
212
213int Vehiclemodecommand105::checksum_105(const std::uint8_t* bytes,
214 int32_t length) const {
215 Byte t0(bytes + 7);
216 int32_t x = t0.get_byte(0, 8);
217
218 int ret = x;
219 return ret;
220}
221
222} // namespace devkit
223} // namespace canbus
224} // namespace apollo
Defines the Byte class.
Vehiclemodecommand105 * set_drive_mode_ctrl(Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl)
Vehiclemodecommand105 * set_steer_mode_ctrl(Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl)
void Parse(const std::uint8_t *bytes, int32_t length, Devkit *chassis) const override
Vehiclemodecommand105 * set_vin_req(Vehicle_mode_command_105::Vin_reqType vin_req)
Vehiclemodecommand105 * set_turn_light_ctrl(Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl)
Vehiclemodecommand105 * set_checksum_105(int checksum_105)
class register implement
Definition arena_queue.h:37