Apollo 10.0
自动驾驶开放平台
pas_2nd_data_312.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"
20
23
24namespace apollo {
25namespace canbus {
26namespace neolix_edu {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Pas2nddata312::ID = 0x312;
32
33void Pas2nddata312::Parse(const std::uint8_t* bytes, int32_t length,
34 Neolix_edu* chassis) const {
35 chassis->mutable_pas_2nd_data_312()->set_pas_b1_status(
36 pas_b1_status(bytes, length));
37 chassis->mutable_pas_2nd_data_312()->set_pas_b2_status(
38 pas_b2_status(bytes, length));
39 chassis->mutable_pas_2nd_data_312()->set_pas_b3_status(
40 pas_b3_status(bytes, length));
41 chassis->mutable_pas_2nd_data_312()->set_pas_b4_status(
42 pas_b4_status(bytes, length));
43 chassis->mutable_pas_2nd_data_312()->set_pasdistance1(
44 pasdistance1(bytes, length));
45 chassis->mutable_pas_2nd_data_312()->set_pasdistance2(
46 pasdistance2(bytes, length));
47 chassis->mutable_pas_2nd_data_312()->set_pasdistance3(
48 pasdistance3(bytes, length));
49 chassis->mutable_pas_2nd_data_312()->set_pasdistance4(
50 pasdistance4(bytes, length));
51}
52
53// config detail: {'description': '0x0:Invalid;0x1:Valid', 'offset': 0.0,
54// 'precision': 1.0, 'len': 1, 'name': 'pas_b1_status', 'is_signed_var': False,
55// 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', 'order': 'motorola',
56// 'physical_unit': 'bit'}
57bool Pas2nddata312::pas_b1_status(const std::uint8_t* bytes,
58 int32_t length) const {
59 Byte t0(bytes + 0);
60 int32_t x = t0.get_byte(0, 1);
61
62 bool ret = x;
63 return ret;
64}
65
66// config detail: {'description': '0x0:Invalid;0x1:Valid', 'offset': 0.0,
67// 'precision': 1.0, 'len': 1, 'name': 'pas_b2_status', 'is_signed_var': False,
68// 'physical_range': '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola',
69// 'physical_unit': 'bit'}
70bool Pas2nddata312::pas_b2_status(const std::uint8_t* bytes,
71 int32_t length) const {
72 Byte t0(bytes + 0);
73 int32_t x = t0.get_byte(1, 1);
74
75 bool ret = x;
76 return ret;
77}
78
79// config detail: {'description': '0x0:Invalid;0x1:Valid', 'offset': 0.0,
80// 'precision': 1.0, 'len': 1, 'name': 'pas_b3_status', 'is_signed_var': False,
81// 'physical_range': '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola',
82// 'physical_unit': 'bit'}
83bool Pas2nddata312::pas_b3_status(const std::uint8_t* bytes,
84 int32_t length) const {
85 Byte t0(bytes + 0);
86 int32_t x = t0.get_byte(2, 1);
87
88 bool ret = x;
89 return ret;
90}
91
92// config detail: {'description': '0x0:Invalid;0x1:Valid', 'offset': 0.0,
93// 'precision': 1.0, 'len': 1, 'name': 'pas_b4_status', 'is_signed_var': False,
94// 'physical_range': '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola',
95// 'physical_unit': 'bit'}
96bool Pas2nddata312::pas_b4_status(const std::uint8_t* bytes,
97 int32_t length) const {
98 Byte t0(bytes + 0);
99 int32_t x = t0.get_byte(3, 1);
100
101 bool ret = x;
102 return ret;
103}
104
105// config detail: {'description': 'phy=int*2;0xFF:no obstacle', 'offset': 0.0,
106// 'precision': 2.0, 'len': 8, 'name': 'pasdistance1', 'is_signed_var': False,
107// 'physical_range': '[0|510]', 'bit': 15, 'type': 'double', 'order':
108// 'motorola', 'physical_unit': 'cm'}
109double Pas2nddata312::pasdistance1(const std::uint8_t* bytes,
110 int32_t length) const {
111 Byte t0(bytes + 1);
112 int32_t x = t0.get_byte(0, 8);
113
114 double ret = x * 2.000000;
115 return ret;
116}
117
118// config detail: {'description': 'phy=int*2;0xFF:no obstacle', 'offset': 0.0,
119// 'precision': 2.0, 'len': 8, 'name': 'pasdistance2', 'is_signed_var': False,
120// 'physical_range': '[0|510]', 'bit': 23, 'type': 'double', 'order':
121// 'motorola', 'physical_unit': 'cm'}
122double Pas2nddata312::pasdistance2(const std::uint8_t* bytes,
123 int32_t length) const {
124 Byte t0(bytes + 2);
125 int32_t x = t0.get_byte(0, 8);
126
127 double ret = x * 2.000000;
128 return ret;
129}
130
131// config detail: {'description': 'phy=int*2;0xFF:no obstacle', 'offset': 0.0,
132// 'precision': 2.0, 'len': 8, 'name': 'pasdistance3', 'is_signed_var': False,
133// 'physical_range': '[0|510]', 'bit': 31, 'type': 'double', 'order':
134// 'motorola', 'physical_unit': 'cm'}
135double Pas2nddata312::pasdistance3(const std::uint8_t* bytes,
136 int32_t length) const {
137 Byte t0(bytes + 3);
138 int32_t x = t0.get_byte(0, 8);
139
140 double ret = x * 2.000000;
141 return ret;
142}
143
144// config detail: {'description': 'phy=int*2;0xFF:no obstacle', 'offset': 0.0,
145// 'precision': 2.0, 'len': 8, 'name': 'pasdistance4', 'is_signed_var': False,
146// 'physical_range': '[0|510]', 'bit': 39, 'type': 'double', 'order':
147// 'motorola', 'physical_unit': 'cm'}
148double Pas2nddata312::pasdistance4(const std::uint8_t* bytes,
149 int32_t length) const {
150 Byte t0(bytes + 4);
151 int32_t x = t0.get_byte(0, 8);
152
153 double ret = x * 2.000000;
154 return ret;
155}
156} // namespace neolix_edu
157} // namespace canbus
158} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Neolix_edu *chassis) const override
class register implement
Definition arena_queue.h:37