Apollo 10.0
自动驾驶开放平台
wheelspeed_report_506.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 Wheelspeedreport506::ID = 0x506;
32
33void Wheelspeedreport506::Parse(const std::uint8_t* bytes, int32_t length,
34 Demo* chassis) const {
35 chassis->mutable_wheelspeed_report_506()->set_rr(rr(bytes, length));
36 chassis->mutable_wheelspeed_report_506()->set_rl(rl(bytes, length));
37 chassis->mutable_wheelspeed_report_506()->set_fr(fr(bytes, length));
38 chassis->mutable_wheelspeed_report_506()->set_fl(fl(bytes, length));
39}
40
41// config detail: {'bit': 55, 'is_signed_var': False, 'len': 16, 'name': 'rr',
42// 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|65.535]',
43// 'physical_unit': 'm/s', 'precision': 0.001, 'type': 'double'}
44double Wheelspeedreport506::rr(const std::uint8_t* bytes,
45 int32_t length) const {
46 Byte t0(bytes + 6);
47 int32_t x = t0.get_byte(0, 8);
48
49 Byte t1(bytes + 7);
50 int32_t t = t1.get_byte(0, 8);
51 x <<= 8;
52 x |= t;
53
54 double ret = x * 0.001000;
55 return ret;
56}
57
58// config detail: {'bit': 39, 'is_signed_var': False, 'len': 16, 'name': 'rl',
59// 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|65.535]',
60// 'physical_unit': 'm/s', 'precision': 0.001, 'type': 'double'}
61double Wheelspeedreport506::rl(const std::uint8_t* bytes,
62 int32_t length) const {
63 Byte t0(bytes + 4);
64 int32_t x = t0.get_byte(0, 8);
65
66 Byte t1(bytes + 5);
67 int32_t t = t1.get_byte(0, 8);
68 x <<= 8;
69 x |= t;
70
71 double ret = x * 0.001000;
72 return ret;
73}
74
75// config detail: {'bit': 23, 'is_signed_var': False, 'len': 16, 'name': 'fr',
76// 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|65.535]',
77// 'physical_unit': 'm/s', 'precision': 0.001, 'type': 'double'}
78double Wheelspeedreport506::fr(const std::uint8_t* bytes,
79 int32_t length) const {
80 Byte t0(bytes + 2);
81 int32_t x = t0.get_byte(0, 8);
82
83 Byte t1(bytes + 3);
84 int32_t t = t1.get_byte(0, 8);
85 x <<= 8;
86 x |= t;
87
88 double ret = x * 0.001000;
89 return ret;
90}
91
92// config detail: {'bit': 7, 'is_signed_var': False, 'len': 16, 'name': 'fl',
93// 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|65.535]',
94// 'physical_unit': 'm/s', 'precision': 0.001, 'type': 'double'}
95double Wheelspeedreport506::fl(const std::uint8_t* bytes,
96 int32_t length) const {
97 Byte t0(bytes + 0);
98 int32_t x = t0.get_byte(0, 8);
99
100 Byte t1(bytes + 1);
101 int32_t t = t1.get_byte(0, 8);
102 x <<= 8;
103 x |= t;
104
105 double ret = x * 0.001000;
106 return ret;
107}
108} // namespace demo
109} // namespace canbus
110} // 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