Apollo 10.0
自动驾驶开放平台
llc_motionfeedback2_21.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 transit {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Llcmotionfeedback221::ID = 0x21;
32
33void Llcmotionfeedback221::Parse(const std::uint8_t* bytes, int32_t length,
34 Transit* chassis) const {
35 chassis->mutable_llc_motionfeedback2_21()->set_llc_fbk_vehiclespeed(
36 llc_fbk_vehiclespeed(bytes, length));
37 chassis->mutable_llc_motionfeedback2_21()->set_llc_motionfeedback2_counter(
38 llc_motionfeedback2_counter(bytes, length));
39 chassis->mutable_llc_motionfeedback2_21()->set_llc_motionfeedback2_checksum(
40 llc_motionfeedback2_checksum(bytes, length));
41 chassis->mutable_llc_motionfeedback2_21()->set_llc_fbk_steeringrate(
42 llc_fbk_steeringrate(bytes, length));
43 chassis->mutable_llc_motionfeedback2_21()->set_llc_fbk_steeringangle(
44 llc_fbk_steeringangle(bytes, length));
45}
46
47// config detail: {'name': 'llc_fbk_vehiclespeed', 'offset': 0.0, 'precision':
48// 0.01, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|655.35]',
49// 'bit': 32, 'type': 'double', 'order': 'intel', 'physical_unit': 'm/s'}
50double Llcmotionfeedback221::llc_fbk_vehiclespeed(const std::uint8_t* bytes,
51 int32_t length) const {
52 Byte t0(bytes + 5);
53 int32_t x = t0.get_byte(0, 8);
54
55 Byte t1(bytes + 4);
56 int32_t t = t1.get_byte(0, 8);
57 x <<= 8;
58 x |= t;
59
60 double ret = x * 0.010000;
61 return ret;
62}
63
64// config detail: {'description': 'Motion feedback 2 heartbeat counter',
65// 'offset': 0.0, 'precision': 1.0, 'len': 2, 'name':
66// 'llc_motionfeedback2_counter', 'is_signed_var': False, 'physical_range':
67// '[0|3]', 'bit': 54, 'type': 'int', 'order': 'intel', 'physical_unit': ''}
68int Llcmotionfeedback221::llc_motionfeedback2_counter(const std::uint8_t* bytes,
69 int32_t length) const {
70 Byte t0(bytes + 6);
71 int32_t x = t0.get_byte(6, 2);
72
73 int ret = x;
74 return ret;
75}
76
77// config detail: {'description': 'Motion feedback 2 checksum', 'offset': 0.0,
78// 'precision': 1.0, 'len': 8, 'name': 'llc_motionfeedback2_checksum',
79// 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 56, 'type':
80// 'int', 'order': 'intel', 'physical_unit': ''}
81int Llcmotionfeedback221::llc_motionfeedback2_checksum(
82 const std::uint8_t* bytes, int32_t length) const {
83 Byte t0(bytes + 7);
84 int32_t x = t0.get_byte(0, 8);
85
86 int ret = x;
87 return ret;
88}
89
90// config detail: {'description': 'Steer wheel angle feedback from SbW motor (?
91// rate)', 'offset': 0.0, 'precision': 0.05, 'len': 16, 'name':
92// 'llc_fbk_steeringrate', 'is_signed_var': True, 'physical_range':
93// '[-1638.4|1638.3]', 'bit': 16, 'type': 'double', 'order': 'intel',
94// 'physical_unit': 'deg/s'}
95double Llcmotionfeedback221::llc_fbk_steeringrate(const std::uint8_t* bytes,
96 int32_t length) const {
97 Byte t0(bytes + 3);
98 int32_t x = t0.get_byte(0, 8);
99
100 Byte t1(bytes + 2);
101 int32_t t = t1.get_byte(0, 8);
102 x <<= 8;
103 x |= t;
104
105 x <<= 16;
106 x >>= 16;
107
108 double ret = x * 0.050000;
109 return ret;
110}
111
112// config detail: {'description': 'Steering angle feedback', 'offset': 0.0,
113// 'precision': 0.05, 'len': 16, 'name': 'llc_fbk_steeringangle',
114// 'is_signed_var': True, 'physical_range': '[-1638.4|1638.35]', 'bit': 0,
115// 'type': 'double', 'order': 'intel', 'physical_unit': 'deg'}
116double Llcmotionfeedback221::llc_fbk_steeringangle(const std::uint8_t* bytes,
117 int32_t length) const {
118 Byte t0(bytes + 1);
119 int32_t x = t0.get_byte(0, 8);
120
121 Byte t1(bytes + 0);
122 int32_t t = t1.get_byte(0, 8);
123 x <<= 8;
124 x |= t;
125
126 x <<= 16;
127 x >>= 16;
128
129 double ret = x * 0.050000;
130 return ret;
131}
132} // namespace transit
133} // namespace canbus
134} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Transit *chassis) const override
class register implement
Definition arena_queue.h:37