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