Apollo 10.0
自动驾驶开放平台
brakeinfo_74.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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 lincoln {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Brakeinfo74::ID = 0x74;
28
29void Brakeinfo74::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 chassis_detail->mutable_brake()->set_brake_torque_req(
32 braking_torque_request(bytes, length));
33 switch (hill_start_assist_status(bytes, length)) {
34 case 0:
35 chassis_detail->mutable_brake()->set_hsa_status(Brake::HSA_INACTIVE);
36 break;
37 case 1:
38 chassis_detail->mutable_brake()->set_hsa_status(
40 break;
41 case 2:
42 chassis_detail->mutable_brake()->set_hsa_status(
44 break;
45 case 3:
46 chassis_detail->mutable_brake()->set_hsa_status(
48 break;
49 case 4:
50 chassis_detail->mutable_brake()->set_hsa_status(Brake::HSA_FAST_RELEASE);
51 break;
52 case 5:
53 chassis_detail->mutable_brake()->set_hsa_status(Brake::HSA_SLOW_RELEASE);
54 break;
55 case 6:
56 chassis_detail->mutable_brake()->set_hsa_status(Brake::HSA_FAILED);
57 break;
58 case 7:
59 chassis_detail->mutable_brake()->set_hsa_status(Brake::HSA_UNDEFINED);
60 break;
61 }
62 chassis_detail->mutable_vehicle_spd()->set_is_vehicle_standstill(
63 is_vehicle_stationary(bytes, length));
64 chassis_detail->mutable_brake()->set_brake_torque_act(
65 braking_torque_actual(bytes, length));
66 switch (hill_start_assist_mode(bytes, length)) {
67 case 0:
68 chassis_detail->mutable_brake()->set_hsa_mode(Brake::HSA_OFF);
69 break;
70 case 1:
71 chassis_detail->mutable_brake()->set_hsa_mode(Brake::HSA_AUTO);
72 break;
73 case 2:
74 chassis_detail->mutable_brake()->set_hsa_mode(Brake::HSA_MANUAL);
75 break;
76 case 3:
77 chassis_detail->mutable_brake()->set_hsa_mode(Brake::HSA_MODE_UNDEFINED);
78 break;
79 }
80 switch (parking_brake_status(bytes, length)) {
81 case 0:
82 chassis_detail->mutable_epb()->set_parking_brake_status(Epb::PBRAKE_OFF);
83 break;
84 case 1:
85 chassis_detail->mutable_epb()->set_parking_brake_status(
87 break;
88 case 2:
89 chassis_detail->mutable_epb()->set_parking_brake_status(Epb::PBRAKE_ON);
90 break;
91 case 3:
92 chassis_detail->mutable_epb()->set_parking_brake_status(
94 break;
95 }
96 chassis_detail->mutable_brake()->set_wheel_torque_act(
97 wheel_torque_actual(bytes, length));
98 chassis_detail->mutable_vehicle_spd()->set_acc_est(
99 acceleration_over_ground(bytes, length));
100 chassis_detail->mutable_esp()->set_is_abs_active(
101 is_abs_active(bytes, length));
102 chassis_detail->mutable_esp()->set_is_abs_enabled(
103 is_abs_enabled(bytes, length));
104 chassis_detail->mutable_esp()->set_is_stab_active(
105 is_stability_control_active(bytes, length));
106 chassis_detail->mutable_esp()->set_is_stab_enabled(
107 is_stability_control_enabled(bytes, length));
108 chassis_detail->mutable_esp()->set_is_trac_active(
109 is_traction_control_active(bytes, length));
110 chassis_detail->mutable_esp()->set_is_trac_enabled(
111 is_traction_control_enabled(bytes, length));
112}
113
114double Brakeinfo74::braking_torque_request(const std::uint8_t *bytes,
115 int32_t length) const {
116 Byte frame_high(bytes + 1);
117 int32_t high = frame_high.get_byte(0, 4);
118 Byte frame_low(bytes + 0);
119 int32_t low = frame_low.get_byte(0, 8);
120 int32_t value = (high << 8) | low;
121 return value * 4.000000;
122}
123
124int32_t Brakeinfo74::hill_start_assist_status(const std::uint8_t *bytes,
125 int32_t length) const {
126 // see table for status code
127 Byte frame(bytes + 1);
128 int32_t x = frame.get_byte(4, 3);
129 return x;
130}
131
132bool Brakeinfo74::is_vehicle_stationary(const std::uint8_t *bytes,
133 int32_t length) const {
134 // false for moving, true for stationary
135 Byte frame(bytes + 1);
136 return frame.is_bit_1(7);
137}
138
139double Brakeinfo74::braking_torque_actual(const std::uint8_t *bytes,
140 int32_t length) const {
141 Byte frame_high(bytes + 3);
142 int32_t high = frame_high.get_byte(0, 4);
143 Byte frame_low(bytes + 2);
144 int32_t low = frame_low.get_byte(0, 8);
145 int32_t value = (high << 8) | low;
146 return value * 4.000000;
147}
148
149int32_t Brakeinfo74::hill_start_assist_mode(const std::uint8_t *bytes,
150 int32_t length) const {
151 // see table for status code
152 Byte frame(bytes + 3);
153 int32_t x = frame.get_byte(4, 2);
154 return x;
155}
156
157int32_t Brakeinfo74::parking_brake_status(const std::uint8_t *bytes,
158 int32_t length) const {
159 // see table for status code
160 Byte frame(bytes + 3);
161 int32_t x = frame.get_byte(6, 2);
162 return x;
163}
164
165double Brakeinfo74::wheel_torque_actual(const std::uint8_t *bytes,
166 int32_t length) const {
167 Byte frame_high(bytes + 5);
168 int32_t high = frame_high.get_byte(0, 6);
169 Byte frame_low(bytes + 4);
170 int32_t low = frame_low.get_byte(0, 8);
171 int32_t value = (high << 8) | low;
172 if (value > 0x1FFF) {
173 value -= 0x4000;
174 }
175 return value * 4.000000;
176}
177
178double Brakeinfo74::acceleration_over_ground(const std::uint8_t *bytes,
179 int32_t length) const {
180 // vehicle acceleration over ground estimate
181 Byte frame_high(bytes + 7);
182 int32_t high = frame_high.get_byte(0, 2);
183 Byte frame_low(bytes + 6);
184 int32_t low = frame_low.get_byte(0, 8);
185 int32_t value = (high << 8) | low;
186 if (value > 0x1FF) {
187 value -= 0x400;
188 }
189 return value * 0.035000;
190}
191
192bool Brakeinfo74::is_abs_active(const std::uint8_t *bytes,
193 int32_t length) const {
194 Byte frame(bytes + 7);
195 return frame.is_bit_1(2);
196}
197
198bool Brakeinfo74::is_abs_enabled(const std::uint8_t *bytes,
199 int32_t length) const {
200 Byte frame(bytes + 7);
201 return frame.is_bit_1(3);
202}
203
204bool Brakeinfo74::is_stability_control_active(const std::uint8_t *bytes,
205 int32_t length) const {
206 Byte frame(bytes + 7);
207 return frame.is_bit_1(4);
208}
209
210bool Brakeinfo74::is_stability_control_enabled(const std::uint8_t *bytes,
211 int32_t length) const {
212 Byte frame(bytes + 7);
213 return frame.is_bit_1(5);
214}
215
216bool Brakeinfo74::is_traction_control_active(const std::uint8_t *bytes,
217 int32_t length) const {
218 Byte frame(bytes + 7);
219 return frame.is_bit_1(6);
220}
221
222bool Brakeinfo74::is_traction_control_enabled(const std::uint8_t *bytes,
223 int32_t length) const {
224 Byte frame(bytes + 7);
225 return frame.is_bit_1(7);
226}
227
228} // namespace lincoln
229} // namespace canbus
230} // namespace apollo
the class of Brakeinfo74 (for lincoln vehicle)
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const override
class register implement
Definition arena_queue.h:37