Apollo 10.0
自动驾驶开放平台
llc_diag_brakecontrol_721.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
20
21namespace apollo {
22namespace canbus {
23namespace transit {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Llcdiagbrakecontrol721::ID = 0x721;
28
29// public
31
33 // TODO(All) : modify every protocol's period manually
34 static const uint32_t PERIOD = 10 * 1000;
35 return PERIOD;
36}
37
39 set_p_llc_dbg_brakepidcontribution_p(data, llc_dbg_brakepidcontribution_p_);
40 set_p_llc_dbg_brakepidcontribution_i(data, llc_dbg_brakepidcontribution_i_);
41 set_p_llc_dbg_brakepidcontribution_d(data, llc_dbg_brakepidcontribution_d_);
42 set_p_llc_dbg_brakepid_output(data, llc_dbg_brakepid_output_);
43 set_p_llc_dbg_brakepid_error(data, llc_dbg_brakepid_error_);
44 set_p_llc_dbg_brakefeedforward(data, llc_dbg_brakefeedforward_);
45}
46
48 // TODO(All) : you should check this manually
49 llc_dbg_brakepidcontribution_p_ = 0.0;
50 llc_dbg_brakepidcontribution_i_ = 0.0;
51 llc_dbg_brakepidcontribution_d_ = 0.0;
52 llc_dbg_brakepid_output_ = 0.0;
53 llc_dbg_brakepid_error_ = 0;
54 llc_dbg_brakefeedforward_ = 0.0;
55}
56
59 double llc_dbg_brakepidcontribution_p) {
60 llc_dbg_brakepidcontribution_p_ = llc_dbg_brakepidcontribution_p;
61 return this;
62}
63
64// config detail: {'description': 'Brake control loop P contribution', 'offset':
65// 0.0, 'precision': 0.1, 'len': 10, 'name': 'LLC_DBG_BrakePidContribution_P',
66// 'is_signed_var': True, 'physical_range': '[-51.2|51.1]', 'bit': 34, 'type':
67// 'double', 'order': 'intel', 'physical_unit': 'mrev'}
68void Llcdiagbrakecontrol721::set_p_llc_dbg_brakepidcontribution_p(
69 uint8_t* data, double llc_dbg_brakepidcontribution_p) {
70 llc_dbg_brakepidcontribution_p =
71 ProtocolData::BoundedValue(-51.2, 51.1, llc_dbg_brakepidcontribution_p);
72 int x = static_cast<int>(llc_dbg_brakepidcontribution_p / 0.100000);
73 uint8_t t = 0;
74
75 t = static_cast<uint8_t>(x & 0x3F);
76 Byte to_set0(data + 4);
77 to_set0.set_value(t, 2, 6);
78 x >>= 6;
79
80 t = static_cast<uint8_t>(x & 0xF);
81 Byte to_set1(data + 5);
82 to_set1.set_value(t, 0, 4);
83}
84
85Llcdiagbrakecontrol721*
87 double llc_dbg_brakepidcontribution_i) {
88 llc_dbg_brakepidcontribution_i_ = llc_dbg_brakepidcontribution_i;
89 return this;
90}
91
92// config detail: {'description': 'Brake control loop I contribution', 'offset':
93// 0.0, 'precision': 0.1, 'len': 10, 'name': 'LLC_DBG_BrakePidContribution_I',
94// 'is_signed_var': True, 'physical_range': '[-51.2|51.1]', 'bit': 44, 'type':
95// 'double', 'order': 'intel', 'physical_unit': 'mrev'}
96void Llcdiagbrakecontrol721::set_p_llc_dbg_brakepidcontribution_i(
97 uint8_t* data, double llc_dbg_brakepidcontribution_i) {
98 llc_dbg_brakepidcontribution_i =
99 ProtocolData::BoundedValue(-51.2, 51.1, llc_dbg_brakepidcontribution_i);
100 int x = static_cast<int>(llc_dbg_brakepidcontribution_i / 0.100000);
101 uint8_t t = 0;
102
103 t = static_cast<uint8_t>(x & 0xF);
104 Byte to_set0(data + 5);
105 to_set0.set_value(t, 4, 4);
106 x >>= 4;
107
108 t = static_cast<uint8_t>(x & 0x3F);
109 Byte to_set1(data + 6);
110 to_set1.set_value(t, 0, 6);
111}
112
113Llcdiagbrakecontrol721*
115 double llc_dbg_brakepidcontribution_d) {
116 llc_dbg_brakepidcontribution_d_ = llc_dbg_brakepidcontribution_d;
117 return this;
118}
119
120// config detail: {'description': 'Brake control loop D contribution', 'offset':
121// 0.0, 'precision': 0.1, 'len': 10, 'name': 'LLC_DBG_BrakePidContribution_D',
122// 'is_signed_var': True, 'physical_range': '[-51.2|51.1]', 'bit': 54, 'type':
123// 'double', 'order': 'intel', 'physical_unit': 'mrev'}
124void Llcdiagbrakecontrol721::set_p_llc_dbg_brakepidcontribution_d(
125 uint8_t* data, double llc_dbg_brakepidcontribution_d) {
126 llc_dbg_brakepidcontribution_d =
127 ProtocolData::BoundedValue(-51.2, 51.1, llc_dbg_brakepidcontribution_d);
128 int x = static_cast<int>(llc_dbg_brakepidcontribution_d / 0.100000);
129 uint8_t t = 0;
130
131 t = static_cast<uint8_t>(x & 0x3);
132 Byte to_set0(data + 6);
133 to_set0.set_value(t, 6, 2);
134 x >>= 2;
135
136 t = static_cast<uint8_t>(x & 0xFF);
137 Byte to_set1(data + 7);
138 to_set1.set_value(t, 0, 8);
139}
140
142 double llc_dbg_brakepid_output) {
143 llc_dbg_brakepid_output_ = llc_dbg_brakepid_output;
144 return this;
145}
146
147// config detail: {'description': 'Brake control loop output', 'offset': 0.0,
148// 'precision': 0.1, 'len': 10, 'name': 'LLC_DBG_BrakePID_Output',
149// 'is_signed_var': True, 'physical_range': '[-51.2|51.1]', 'bit': 12, 'type':
150// 'double', 'order': 'intel', 'physical_unit': 'mrev'}
151void Llcdiagbrakecontrol721::set_p_llc_dbg_brakepid_output(
152 uint8_t* data, double llc_dbg_brakepid_output) {
153 llc_dbg_brakepid_output =
154 ProtocolData::BoundedValue(-51.2, 51.1, llc_dbg_brakepid_output);
155 int x = static_cast<int>(llc_dbg_brakepid_output / 0.100000);
156 uint8_t t = 0;
157
158 t = static_cast<uint8_t>(x & 0xF);
159 Byte to_set0(data + 1);
160 to_set0.set_value(t, 4, 4);
161 x >>= 4;
162
163 t = static_cast<uint8_t>(x & 0x3F);
164 Byte to_set1(data + 2);
165 to_set1.set_value(t, 0, 6);
166}
167
169 int llc_dbg_brakepid_error) {
170 llc_dbg_brakepid_error_ = llc_dbg_brakepid_error;
171 return this;
172}
173
174// config detail: {'description': 'Brake control loop error', 'offset': 0.0,
175// 'precision': 1.0, 'len': 12, 'name': 'LLC_DBG_BrakePID_Error',
176// 'is_signed_var': True, 'physical_range': '[-2048|2047]', 'bit': 0, 'type':
177// 'int', 'order': 'intel', 'physical_unit': 'psi'}
178void Llcdiagbrakecontrol721::set_p_llc_dbg_brakepid_error(
179 uint8_t* data, int llc_dbg_brakepid_error) {
180 llc_dbg_brakepid_error =
181 ProtocolData::BoundedValue(-2048, 2047, llc_dbg_brakepid_error);
182 int x = llc_dbg_brakepid_error;
183 uint8_t t = 0;
184
185 t = static_cast<uint8_t>(x & 0xFF);
186 Byte to_set0(data + 0);
187 to_set0.set_value(t, 0, 8);
188 x >>= 8;
189
190 t = static_cast<uint8_t>(x & 0xF);
191 Byte to_set1(data + 1);
192 to_set1.set_value(t, 0, 4);
193}
194
196 double llc_dbg_brakefeedforward) {
197 llc_dbg_brakefeedforward_ = llc_dbg_brakefeedforward;
198 return this;
199}
200
201// config detail: {'description': 'Brake control feedforward contribution',
202// 'offset': 0.0, 'precision': 0.5, 'len': 12, 'name':
203// 'LLC_DBG_BrakeFeedforward', 'is_signed_var': True, 'physical_range':
204// '[-1024|1023.5]', 'bit': 22, 'type': 'double', 'order': 'intel',
205// 'physical_unit': 'mrev'}
206void Llcdiagbrakecontrol721::set_p_llc_dbg_brakefeedforward(
207 uint8_t* data, double llc_dbg_brakefeedforward) {
208 llc_dbg_brakefeedforward =
209 ProtocolData::BoundedValue(-1024.0, 1023.5, llc_dbg_brakefeedforward);
210 int x = static_cast<int>(llc_dbg_brakefeedforward / 0.500000);
211 uint8_t t = 0;
212
213 t = static_cast<uint8_t>(x & 0x3);
214 Byte to_set0(data + 2);
215 to_set0.set_value(t, 6, 2);
216 x >>= 2;
217
218 t = static_cast<uint8_t>(x & 0xFF);
219 Byte to_set1(data + 3);
220 to_set1.set_value(t, 0, 8);
221 x >>= 8;
222
223 t = static_cast<uint8_t>(x & 0x3);
224 Byte to_set2(data + 4);
225 to_set2.set_value(t, 0, 2);
226}
227
228} // namespace transit
229} // namespace canbus
230} // namespace apollo
Defines the Byte class.
Llcdiagbrakecontrol721 * set_llc_dbg_brakepid_output(double llc_dbg_brakepid_output)
Llcdiagbrakecontrol721 * set_llc_dbg_brakepid_error(int llc_dbg_brakepid_error)
Llcdiagbrakecontrol721 * set_llc_dbg_brakepidcontribution_p(double llc_dbg_brakepidcontribution_p)
Llcdiagbrakecontrol721 * set_llc_dbg_brakefeedforward(double llc_dbg_brakefeedforward)
Llcdiagbrakecontrol721 * set_llc_dbg_brakepidcontribution_i(double llc_dbg_brakepidcontribution_i)
Llcdiagbrakecontrol721 * set_llc_dbg_brakepidcontribution_d(double llc_dbg_brakepidcontribution_d)
class register implement
Definition arena_queue.h:37