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