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