Apollo 10.0
自动驾驶开放平台
brake_report_501.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 Brakereport501::ID = 0x501;
32
33void Brakereport501::Parse(const std::uint8_t* bytes, int32_t length,
34 Demo* chassis) const {
35 chassis->mutable_brake_report_501()->set_brake_pedal_actual(
36 brake_pedal_actual(bytes, length));
37 chassis->mutable_brake_report_501()->set_brake_flt2(
38 brake_flt2(bytes, length));
39 chassis->mutable_brake_report_501()->set_brake_flt1(
40 brake_flt1(bytes, length));
41 chassis->mutable_brake_report_501()->set_brake_en_state(
42 brake_en_state(bytes, length));
43}
44
45// config detail: {'bit': 31, 'description': 'command', 'is_signed_var': False,
46// 'len': 16, 'name': 'brake_pedal_actual', 'offset': 0.0, 'order': 'motorola',
47// 'physical_range': '[0|100]', 'physical_unit': '%', 'precision': 0.1,
48// 'signal_type': 'command', 'type': 'double'}
49double Brakereport501::brake_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': 'Brake system communication fault',
64// 'enum': {0: 'BRAKE_FLT2_NO_FAULT', 1:
65// 'BRAKE_FLT2_BRAKE_SYSTEM_COMUNICATION_FAULT'}, 'is_signed_var': False, 'len':
66// 8, 'name': 'brake_flt2', 'offset': 0.0, 'order': 'motorola',
67// 'physical_range': '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type':
68// 'enum'}
69Brake_report_501::Brake_flt2Type Brakereport501::brake_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': 'Brake system hardware fault',
80// 'enum': {0: 'BRAKE_FLT1_NO_FAULT', 1:
81// 'BRAKE_FLT1_BRAKE_SYSTEM_HARDWARE_FAULT'}, 'is_signed_var': False, 'len': 8,
82// 'name': 'brake_flt1', 'offset': 0.0, 'order': 'motorola', 'physical_range':
83// '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
84Brake_report_501::Brake_flt1Type Brakereport501::brake_flt1(
85 const std::uint8_t* bytes, int32_t length) const {
86 Byte t0(bytes + 1);
87 int32_t x = t0.get_byte(0, 8);
88
91 return ret;
92}
93
94// config detail: {'bit': 1, 'description': 'enable', 'enum': {0:
95// 'BRAKE_EN_STATE_MANUAL', 1: 'BRAKE_EN_STATE_AUTO', 2:
96// 'BRAKE_EN_STATE_TAKEOVER', 3: 'BRAKE_EN_STATE_STANDBY'}, 'is_signed_var':
97// False, 'len': 2, 'name': 'brake_en_state', 'offset': 0.0, 'order':
98// 'motorola', 'physical_range': '[0|2]', 'physical_unit': '', 'precision': 1.0,
99// 'signal_type': 'enable', 'type': 'enum'}
100Brake_report_501::Brake_en_stateType Brakereport501::brake_en_state(
101 const std::uint8_t* bytes, int32_t length) const {
102 Byte t0(bytes + 0);
103 int32_t x = t0.get_byte(0, 2);
104
107 return ret;
108}
109} // namespace demo
110} // namespace canbus
111} // 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