Apollo 10.0
自动驾驶开放平台
steering_report_502.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 Steeringreport502::ID = 0x502;
32
33void Steeringreport502::Parse(const std::uint8_t* bytes, int32_t length,
34 Demo* chassis) const {
35 chassis->mutable_steering_report_502()->set_steer_angle_rear_actual(
36 steer_angle_rear_actual(bytes, length));
37 chassis->mutable_steering_report_502()->set_steer_angle_spd_actual(
38 steer_angle_spd_actual(bytes, length));
39 chassis->mutable_steering_report_502()->set_steer_flt2(
40 steer_flt2(bytes, length));
41 chassis->mutable_steering_report_502()->set_steer_flt1(
42 steer_flt1(bytes, length));
43 chassis->mutable_steering_report_502()->set_steer_en_state(
44 steer_en_state(bytes, length));
45 chassis->mutable_steering_report_502()->set_steer_angle_actual(
46 steer_angle_actual(bytes, length));
47}
48
49// config detail: {'bit': 47, 'is_signed_var': False, 'len': 16, 'name':
50// 'steer_angle_rear_actual', 'offset': -500.0, 'order': 'motorola',
51// 'physical_range': '[-500|500]', 'physical_unit': 'deg', 'precision': 1.0,
52// 'type': 'int'}
53int Steeringreport502::steer_angle_rear_actual(const std::uint8_t* bytes,
54 int32_t length) const {
55 Byte t0(bytes + 5);
56 int32_t x = t0.get_byte(0, 8);
57
58 Byte t1(bytes + 6);
59 int32_t t = t1.get_byte(0, 8);
60 x <<= 8;
61 x |= t;
62
63 int ret = x + -500.000000;
64 return ret;
65}
66
67// config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name':
68// 'steer_angle_spd_actual', 'offset': 0.0, 'order': 'motorola',
69// 'physical_range': '[0|0]', 'physical_unit': 'deg/s', 'precision': 1.0,
70// 'type': 'int'}
71int Steeringreport502::steer_angle_spd_actual(const std::uint8_t* bytes,
72 int32_t length) const {
73 Byte t0(bytes + 7);
74 int32_t x = t0.get_byte(0, 8);
75
76 int ret = x;
77 return ret;
78}
79
80// config detail: {'bit': 23, 'description': 'Steer system communication fault',
81// 'enum': {0: 'STEER_FLT2_NO_FAULT', 1:
82// 'STEER_FLT2_STEER_SYSTEM_COMUNICATION_FAULT'}, 'is_signed_var': False, 'len':
83// 8, 'name': 'steer_flt2', 'offset': 0.0, 'order': 'motorola',
84// 'physical_range': '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type':
85// 'enum'}
86Steering_report_502::Steer_flt2Type Steeringreport502::steer_flt2(
87 const std::uint8_t* bytes, int32_t length) const {
88 Byte t0(bytes + 2);
89 int32_t x = t0.get_byte(0, 8);
90
93 return ret;
94}
95
96// config detail: {'bit': 15, 'description': 'Steer system hardware fault',
97// 'enum': {0: 'STEER_FLT1_NO_FAULT', 1:
98// 'STEER_FLT1_STEER_SYSTEM_HARDWARE_FAULT'}, 'is_signed_var': False, 'len': 8,
99// 'name': 'steer_flt1', 'offset': 0.0, 'order': 'motorola', 'physical_range':
100// '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
101Steering_report_502::Steer_flt1Type Steeringreport502::steer_flt1(
102 const std::uint8_t* bytes, int32_t length) const {
103 Byte t0(bytes + 1);
104 int32_t x = t0.get_byte(0, 8);
105
108 return ret;
109}
110
111// config detail: {'bit': 1, 'description': 'enable', 'enum': {0:
112// 'STEER_EN_STATE_MANUAL', 1: 'STEER_EN_STATE_AUTO', 2:
113// 'STEER_EN_STATE_TAKEOVER', 3: 'STEER_EN_STATE_STANDBY'}, 'is_signed_var':
114// False, 'len': 2, 'name': 'steer_en_state', 'offset': 0.0, 'order':
115// 'motorola', 'physical_range': '[0|2]', 'physical_unit': '', 'precision': 1.0,
116// 'signal_type': 'enable', 'type': 'enum'}
117Steering_report_502::Steer_en_stateType Steeringreport502::steer_en_state(
118 const std::uint8_t* bytes, int32_t length) const {
119 Byte t0(bytes + 0);
120 int32_t x = t0.get_byte(0, 2);
121
124 return ret;
125}
126
127// config detail: {'bit': 31, 'description': 'command', 'is_signed_var': False,
128// 'len': 16, 'name': 'steer_angle_actual', 'offset': -500.0, 'order':
129// 'motorola', 'physical_range': '[-500|500]', 'physical_unit': 'deg',
130// 'precision': 1.0, 'signal_type': 'command', 'type': 'int'}
131int Steeringreport502::steer_angle_actual(const std::uint8_t* bytes,
132 int32_t length) const {
133 Byte t0(bytes + 3);
134 int32_t x = t0.get_byte(0, 8);
135
136 Byte t1(bytes + 4);
137 int32_t t = t1.get_byte(0, 8);
138 x <<= 8;
139 x |= t;
140
141 int ret = x + -500.000000;
142 return ret;
143}
144} // namespace demo
145} // namespace canbus
146} // 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