Apollo 10.0
自动驾驶开放平台
throttle_report_500.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
19#include "glog/logging.h"
22
23namespace apollo {
24namespace canbus {
25namespace devkit {
26
27using ::apollo::drivers::canbus::Byte;
28
30const int32_t Throttlereport500::ID = 0x500;
31
32void Throttlereport500::Parse(const std::uint8_t* bytes, int32_t length,
33 Devkit* chassis) const {
34 chassis->mutable_throttle_report_500()->set_throttle_pedal_actual(
35 throttle_pedal_actual(bytes, length));
36 chassis->mutable_throttle_report_500()->set_throttle_flt2(
37 throttle_flt2(bytes, length));
38 chassis->mutable_throttle_report_500()->set_throttle_flt1(
39 throttle_flt1(bytes, length));
40 chassis->mutable_throttle_report_500()->set_throttle_en_state(
41 throttle_en_state(bytes, length));
42}
43
44// config detail: {'name': 'throttle_pedal_actual', 'offset': 0.0, 'precision':
45// 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit':
46// 31, 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
47double Throttlereport500::throttle_pedal_actual(const std::uint8_t* bytes,
48 int32_t length) const {
49 Byte t0(bytes + 3);
50 int32_t x = t0.get_byte(0, 8);
51
52 Byte t1(bytes + 4);
53 int32_t t = t1.get_byte(0, 8);
54 x <<= 8;
55 x |= t;
56
57 double ret = x * 0.100000;
58 return ret;
59}
60
61// config detail: {'description': 'Drive system communication fault', 'enum':
62// {0: 'THROTTLE_FLT2_NO_FAULT', 1:
63// 'THROTTLE_FLT2_DRIVE_SYSTEM_COMUNICATION_FAULT'}, 'precision': 1.0, 'len': 8,
64// 'name': 'throttle_flt2', 'is_signed_var': False, 'offset': 0.0,
65// 'physical_range': '[0|1]', 'bit': 23, 'type': 'enum', 'order': 'motorola',
66// 'physical_unit': ''}
67Throttle_report_500::Throttle_flt2Type Throttlereport500::throttle_flt2(
68 const std::uint8_t* bytes, int32_t length) const {
69 Byte t0(bytes + 2);
70 int32_t x = t0.get_byte(0, 8);
71
74 return ret;
75}
76
77// config detail: {'description': 'Drive system hardware fault', 'enum': {0:
78// 'THROTTLE_FLT1_NO_FAULT', 1: 'THROTTLE_FLT1_DRIVE_SYSTEM_HARDWARE_FAULT'},
79// 'precision': 1.0, 'len': 8, 'name': 'throttle_flt1', 'is_signed_var': False,
80// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', 'order':
81// 'motorola', 'physical_unit': ''}
82Throttle_report_500::Throttle_flt1Type Throttlereport500::throttle_flt1(
83 const std::uint8_t* bytes, int32_t length) const {
84 Byte t0(bytes + 1);
85 int32_t x = t0.get_byte(0, 8);
86
89 return ret;
90}
91
92// config detail: {'name': 'throttle_en_state', 'enum': {0:
93// 'THROTTLE_EN_STATE_MANUAL', 1: 'THROTTLE_EN_STATE_AUTO', 2:
94// 'THROTTLE_EN_STATE_TAKEOVER', 3: 'THROTTLE_EN_STATE_STANDBY'},
95// 'precision': 1.0, 'len': 2, 'is_signed_var': False, 'offset': 0.0,
96// 'physical_range': '[0|2]', 'bit': 1, 'type': 'enum', 'order': 'motorola',
97// 'physical_unit': ''}
98Throttle_report_500::Throttle_en_stateType Throttlereport500::throttle_en_state(
99 const std::uint8_t* bytes, int32_t length) const {
100 Byte t0(bytes + 0);
101 int32_t x = t0.get_byte(0, 2);
102
105 return ret;
106}
107} // namespace devkit
108} // namespace canbus
109} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Devkit *chassis) const override
class register implement
Definition arena_queue.h:37