Apollo 10.0
自动驾驶开放平台
throttleinfo_75.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 Throttleinfo75::ID = 0x75;
28
29void Throttleinfo75::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 chassis_detail->mutable_ems()->set_engine_rpm(engine_rpm(bytes, length));
32 chassis_detail->mutable_gas()->set_accelerator_pedal(
33 acc_pedal_percent(bytes, length));
34 chassis_detail->mutable_gas()->set_accelerator_pedal_rate(
35 acc_pedal_rate(bytes, length));
36}
37
38double Throttleinfo75::engine_rpm(const std::uint8_t *bytes,
39 int32_t length) const {
40 Byte frame_high(bytes + 1);
41 int32_t high = frame_high.get_byte(0, 8);
42 Byte frame_low(bytes + 0);
43 int32_t low = frame_low.get_byte(0, 8);
44 int32_t value = (high << 8) | low;
45 return value * 0.25;
46}
47
48double Throttleinfo75::acc_pedal_percent(const std::uint8_t *bytes,
49 int32_t length) const {
50 Byte frame_high(bytes + 3);
51 int32_t high = frame_high.get_byte(0, 2);
52 Byte frame_low(bytes + 2);
53 int32_t low = frame_low.get_byte(0, 8);
54 int32_t value = (high << 8) | low;
55 return value * 0.1;
56}
57
58double Throttleinfo75::acc_pedal_rate(const std::uint8_t *bytes,
59 int32_t length) const {
60 Byte frame(bytes + 4);
61 int32_t x = frame.get_byte(0, 8);
62 if (x > 0x3F) {
63 x -= 0x100;
64 }
65 return x * 0.04;
66}
67
68} // namespace lincoln
69} // namespace canbus
70} // namespace apollo
Defines the Byte class.
double acc_pedal_percent(const std::uint8_t *bytes, int32_t length) const
calculate acc pedal percent based on byte array.
double acc_pedal_rate(const std::uint8_t *bytes, int32_t length) const
calculate acc pedal rate based on byte array.
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
double engine_rpm(const std::uint8_t *bytes, int32_t length) const
calculate engine rpm based on byte array.
class register implement
Definition arena_queue.h:37
the class of Throttleinfo75 (for lincoln vehicle)