Apollo 10.0
自动驾驶开放平台
steering_aux_rpt_32c.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 lexus {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Steeringauxrpt32c::ID = 0x32C;
32
33void Steeringauxrpt32c::Parse(const std::uint8_t* bytes, int32_t length,
34 Lexus* chassis) const {
35 chassis->mutable_steering_aux_rpt_32c()->set_user_interaction_is_valid(
36 user_interaction_is_valid(bytes, length));
37 chassis->mutable_steering_aux_rpt_32c()->set_user_interaction(
38 user_interaction(bytes, length));
39 chassis->mutable_steering_aux_rpt_32c()->set_rotation_rate_is_valid(
40 rotation_rate_is_valid(bytes, length));
41 chassis->mutable_steering_aux_rpt_32c()->set_rotation_rate(
42 rotation_rate(bytes, length));
43 chassis->mutable_steering_aux_rpt_32c()->set_raw_torque_is_valid(
44 raw_torque_is_valid(bytes, length));
45 chassis->mutable_steering_aux_rpt_32c()->set_raw_torque(
46 raw_torque(bytes, length));
47 chassis->mutable_steering_aux_rpt_32c()->set_raw_position_is_valid(
48 raw_position_is_valid(bytes, length));
49 chassis->mutable_steering_aux_rpt_32c()->set_raw_position(
50 raw_position(bytes, length));
51}
52
53// config detail: {'name': 'user_interaction_is_valid', 'offset': 0.0,
54// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
55// '[0|1]', 'bit': 59, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
56bool Steeringauxrpt32c::user_interaction_is_valid(const std::uint8_t* bytes,
57 int32_t length) const {
58 Byte t0(bytes + 7);
59 int32_t x = t0.get_byte(3, 1);
60
61 bool ret = x;
62 return ret;
63}
64
65// config detail: {'name': 'user_interaction', 'offset': 0.0, 'precision': 1.0,
66// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 48,
67// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
68bool Steeringauxrpt32c::user_interaction(const std::uint8_t* bytes,
69 int32_t length) const {
70 Byte t0(bytes + 6);
71 int32_t x = t0.get_byte(0, 1);
72
73 bool ret = x;
74 return ret;
75}
76
77// config detail: {'name': 'rotation_rate_is_valid', 'offset': 0.0,
78// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
79// '[0|1]', 'bit': 58, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
80bool Steeringauxrpt32c::rotation_rate_is_valid(const std::uint8_t* bytes,
81 int32_t length) const {
82 Byte t0(bytes + 7);
83 int32_t x = t0.get_byte(2, 1);
84
85 bool ret = x;
86 return ret;
87}
88
89// config detail: {'name': 'rotation_rate', 'offset': 0.0, 'precision': 0.001,
90// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 39,
91// 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'}
92double Steeringauxrpt32c::rotation_rate(const std::uint8_t* bytes,
93 int32_t length) const {
94 Byte t0(bytes + 4);
95 int32_t x = t0.get_byte(0, 8);
96
97 Byte t1(bytes + 5);
98 int32_t t = t1.get_byte(0, 8);
99 x <<= 8;
100 x |= t;
101
102 double ret = x * 0.001000;
103 return ret;
104}
105
106// config detail: {'name': 'raw_torque_is_valid', 'offset': 0.0,
107// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
108// '[0|1]', 'bit': 57, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
109bool Steeringauxrpt32c::raw_torque_is_valid(const std::uint8_t* bytes,
110 int32_t length) const {
111 Byte t0(bytes + 7);
112 int32_t x = t0.get_byte(1, 1);
113
114 bool ret = x;
115 return ret;
116}
117
118// config detail: {'name': 'raw_torque', 'offset': 0.0, 'precision': 0.001,
119// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
120// 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
121double Steeringauxrpt32c::raw_torque(const std::uint8_t* bytes,
122 int32_t length) const {
123 Byte t0(bytes + 2);
124 int32_t x = t0.get_byte(0, 8);
125
126 Byte t1(bytes + 3);
127 int32_t t = t1.get_byte(0, 8);
128 x <<= 8;
129 x |= t;
130
131 x <<= 16;
132 x >>= 16;
133
134 double ret = x * 0.001000;
135 return ret;
136}
137
138// config detail: {'name': 'raw_position_is_valid', 'offset': 0.0,
139// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
140// '[0|1]', 'bit': 56, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
141bool Steeringauxrpt32c::raw_position_is_valid(const std::uint8_t* bytes,
142 int32_t length) const {
143 Byte t0(bytes + 7);
144 int32_t x = t0.get_byte(0, 1);
145
146 bool ret = x;
147 return ret;
148}
149
150// config detail: {'name': 'raw_position', 'offset': 0.0, 'precision': 0.001,
151// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
152// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
153double Steeringauxrpt32c::raw_position(const std::uint8_t* bytes,
154 int32_t length) const {
155 Byte t0(bytes + 0);
156 int32_t x = t0.get_byte(0, 8);
157
158 Byte t1(bytes + 1);
159 int32_t t = t1.get_byte(0, 8);
160 x <<= 8;
161 x |= t;
162
163 x <<= 16;
164 x >>= 16;
165
166 double ret = x * 0.001000;
167 return ret;
168}
169} // namespace lexus
170} // namespace canbus
171} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Lexus *chassis) const override
class register implement
Definition arena_queue.h:37