Apollo 10.0
自动驾驶开放平台
brake_report_501.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 Brakereport501::ID = 0x501;
31
32void Brakereport501::Parse(const std::uint8_t* bytes, int32_t length,
33 Devkit* chassis) const {
34 chassis->mutable_brake_report_501()->set_brake_pedal_actual(
35 brake_pedal_actual(bytes, length));
36 chassis->mutable_brake_report_501()->set_brake_flt2(
37 brake_flt2(bytes, length));
38 chassis->mutable_brake_report_501()->set_brake_flt1(
39 brake_flt1(bytes, length));
40 chassis->mutable_brake_report_501()->set_brake_en_state(
41 brake_en_state(bytes, length));
42}
43
44// config detail: {'name': 'brake_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 Brakereport501::brake_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': 'Brake system communication fault', 'enum':
62// {0: 'BRAKE_FLT2_NO_FAULT', 1: 'BRAKE_FLT2_BRAKE_SYSTEM_COMUNICATION_FAULT'},
63// 'precision': 1.0, 'len': 8, 'name': 'brake_flt2', 'is_signed_var': False,
64// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 23, 'type': 'enum', 'order':
65// 'motorola', 'physical_unit': ''}
66Brake_report_501::Brake_flt2Type Brakereport501::brake_flt2(
67 const std::uint8_t* bytes, int32_t length) const {
68 Byte t0(bytes + 2);
69 int32_t x = t0.get_byte(0, 8);
70
73 return ret;
74}
75
76// config detail: {'description': 'Brake system hardware fault', 'enum': {0:
77// 'BRAKE_FLT1_NO_FAULT', 1: 'BRAKE_FLT1_BRAKE_SYSTEM_HARDWARE_FAULT'},
78// 'precision': 1.0, 'len': 8, 'name': 'brake_flt1', 'is_signed_var': False,
79// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', 'order':
80// 'motorola', 'physical_unit': ''}
81Brake_report_501::Brake_flt1Type Brakereport501::brake_flt1(
82 const std::uint8_t* bytes, int32_t length) const {
83 Byte t0(bytes + 1);
84 int32_t x = t0.get_byte(0, 8);
85
88 return ret;
89}
90
91// config detail: {'name': 'brake_en_state', 'enum': {0:
92// 'BRAKE_EN_STATE_MANUAL', 1: 'BRAKE_EN_STATE_AUTO', 2:
93// 'BRAKE_EN_STATE_TAKEOVER', 3: 'BRAKE_EN_STATE_STANDBY'}, 'precision': 1.0,
94// 'len': 2, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]',
95// 'bit': 1, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
96Brake_report_501::Brake_en_stateType Brakereport501::brake_en_state(
97 const std::uint8_t* bytes, int32_t length) const {
98 Byte t0(bytes + 0);
99 int32_t x = t0.get_byte(0, 2);
100
103 return ret;
104}
105} // namespace devkit
106} // namespace canbus
107} // 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