Apollo 10.0
自动驾驶开放平台
ads_light_horn_command_310.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 Adslighthorncommand310::ID = 0x310;
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
39 set_p_turn_right_light_command(data, turn_right_light_command_);
40 set_p_turn_left_light_command(data, turn_left_light_command_);
41 set_p_horn_command(data, horn_command_);
42 set_p_beam_command(data, beam_command_);
43 ++auto_drivercmd_alivecounter_;
44 auto_drivercmd_alivecounter_ = (auto_drivercmd_alivecounter_) % 16;
45 set_p_auto_drivercmd_alivecounter(data, auto_drivercmd_alivecounter_);
46 auto_drivercmd_checksum_ =
47 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
48 set_p_auto_drivercmd_checksum(data, auto_drivercmd_checksum_);
49}
50
52 // TODO(All) : you should check this manually
53 turn_right_light_command_ = false;
54 turn_left_light_command_ = false;
55 horn_command_ = false;
56 beam_command_ = 0;
57 auto_drivercmd_alivecounter_ = 0;
58 auto_drivercmd_checksum_ = 0;
59}
60
62 bool turn_right_light_command) {
63 turn_right_light_command_ = turn_right_light_command;
64 return this;
65}
66
67// config detail: {'description': '0x0:disable ;0x1:enable', 'offset': 0.0,
68// 'precision': 1.0, 'len': 1, 'name': 'Turn_Right_Light_Command',
69// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 8, 'type': 'bool',
70// 'order': 'motorola', 'physical_unit': 'bit'}
71void Adslighthorncommand310::set_p_turn_right_light_command(
72 uint8_t* data, bool turn_right_light_command) {
73 int x = turn_right_light_command;
74
75 Byte to_set(data + 1);
76 to_set.set_value(x, 0, 1);
77}
78
80 bool turn_left_light_command) {
81 turn_left_light_command_ = turn_left_light_command;
82 return this;
83}
84
85// config detail: {'description': '0x0:disable ;0x1:enable ;0x2-0x3:Reserved ',
86// 'offset': 0.0, 'precision': 1.0, 'len': 1, 'name': 'Turn_Left_Light_Command',
87// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 9, 'type': 'bool',
88// 'order': 'motorola', 'physical_unit': 'bit'}
89void Adslighthorncommand310::set_p_turn_left_light_command(
90 uint8_t* data, bool turn_left_light_command) {
91 int x = turn_left_light_command;
92
93 Byte to_set(data + 1);
94 to_set.set_value(x, 1, 1);
95}
96
98 bool horn_command) {
99 horn_command_ = horn_command;
100 return this;
101}
102
103// config detail: {'name': 'Horn_Command', 'offset': 0.0, 'precision': 1.0,
104// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 10,
105// 'type': 'bool', 'order': 'motorola', 'physical_unit': 'bit'}
106void Adslighthorncommand310::set_p_horn_command(uint8_t* data,
107 bool horn_command) {
108 int x = horn_command;
109
110 Byte to_set(data + 1);
111 to_set.set_value(x, 2, 1);
112}
113
115 int beam_command) {
116 beam_command_ = beam_command;
117 return this;
118}
119
120// config detail: {'description': '0x0:Off;0x1:LowBeam;0x2:HighBeam', 'offset':
121// 0.0, 'precision': 1.0, 'len': 2, 'name': 'Beam_Command', 'is_signed_var':
122// False, 'physical_range': '[0|1]', 'bit': 13, 'type': 'int', 'order':
123// 'motorola', 'physical_unit': 'bit'}
124void Adslighthorncommand310::set_p_beam_command(uint8_t* data,
125 int beam_command) {
126 beam_command = ProtocolData::BoundedValue(0, 1, beam_command);
127 int x = beam_command;
128
129 Byte to_set(data + 1);
130 to_set.set_value(x, 4, 2);
131}
132
134 int auto_drivercmd_alivecounter) {
135 auto_drivercmd_alivecounter_ = auto_drivercmd_alivecounter;
136 return this;
137}
138
139// config detail: {'name': 'AUTO_DriverCmd_AliveCounter', 'offset': 0.0,
140// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
141// '[0|0]', 'bit': 51, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
142void Adslighthorncommand310::set_p_auto_drivercmd_alivecounter(
143 uint8_t* data, int auto_drivercmd_alivecounter) {
144 auto_drivercmd_alivecounter =
145 ProtocolData::BoundedValue(0, 15, auto_drivercmd_alivecounter);
146 int x = auto_drivercmd_alivecounter;
147
148 Byte to_set(data + 6);
149 to_set.set_value(x, 0, 4);
150}
151
153 int auto_drivercmd_checksum) {
154 auto_drivercmd_checksum_ = auto_drivercmd_checksum;
155 return this;
156}
157
158// config detail: {'name': 'AUTO_DriverCmd_CheckSum', 'offset': 0.0,
159// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
160// '[0|0]', 'bit': 63, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
161void Adslighthorncommand310::set_p_auto_drivercmd_checksum(
162 uint8_t* data, int auto_drivercmd_checksum) {
163 auto_drivercmd_checksum =
164 ProtocolData::BoundedValue(0, 255, auto_drivercmd_checksum);
165 int x = auto_drivercmd_checksum;
166
167 Byte to_set(data + 7);
168 to_set.set_value(x, 0, 8);
169}
170
171} // namespace neolix_edu
172} // namespace canbus
173} // namespace apollo
Defines the Byte class.
Adslighthorncommand310 * set_turn_left_light_command(bool turn_left_light_command)
Adslighthorncommand310 * set_horn_command(bool horn_command)
Adslighthorncommand310 * set_auto_drivercmd_checksum(int auto_drivercmd_checksum)
Adslighthorncommand310 * set_turn_right_light_command(bool turn_right_light_command)
Adslighthorncommand310 * set_beam_command(int beam_command)
Adslighthorncommand310 * set_auto_drivercmd_alivecounter(int auto_drivercmd_alivecounter)
class register implement
Definition arena_queue.h:37