Apollo 10.0
自动驾驶开放平台
fbs2_240.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 wey {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Fbs2240::ID = 0x240;
32
33void Fbs2240::Parse(const std::uint8_t* bytes, int32_t length,
34 Wey* chassis) const {
35 chassis->mutable_fbs2_240()->set_flwheeldirection(
36 flwheeldirection(bytes, length));
37 chassis->mutable_fbs2_240()->set_frwheelspd(
38 frwheelspd(bytes, length));
39 chassis->mutable_fbs2_240()->set_rlwheeldrivedirection(
40 rlwheeldrivedirection(bytes, length));
41 chassis->mutable_fbs2_240()->set_rlwheelspd(
42 rlwheelspd(bytes, length));
43 chassis->mutable_fbs2_240()->set_rrwheeldirection(
44 rrwheeldirection(bytes, length));
45 chassis->mutable_fbs2_240()->set_rrwheelspd(
46 rrwheelspd(bytes, length));
47 // change km/h to m/s
48 chassis->mutable_fbs2_240()->set_vehiclespd(
49 vehiclespd(bytes, length) / 3.6);
50}
51
52// config detail: {'description': 'Front left wheel Moving direction',
53// 'enum': {0: 'FLWHEELDIRECTION_INVALID', 1: 'FLWHEELDIRECTION_FORWARD',
54// 2: 'FLWHEELDIRECTION_BACKWARD', 3: 'FLWHEELDIRECTION_STOP'},
55// 'precision': 1.0, 'len': 2, 'name': 'flwheeldirection',
56// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]',
57// 'bit': 57, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
58Fbs2_240::FlwheeldirectionType Fbs2240::flwheeldirection(
59 const std::uint8_t* bytes, int32_t length) const {
60 Byte t0(bytes + 7);
61 int32_t x = t0.get_byte(0, 2);
62
64 static_cast<Fbs2_240::FlwheeldirectionType>(x);
65 return ret;
66}
67
68// config detail: {'description': 'Front right wheel speed', 'offset': 0.0,
69// 'precision': 0.05625, 'len': 13, 'name': 'frwheelspd',
70// 'is_signed_var': False, 'physical_range': '[0|299.98125]', 'bit': 7,
71// 'type': 'double', 'order': 'motorola', 'physical_unit': 'Km/h'}
72double Fbs2240::frwheelspd(const std::uint8_t* bytes, int32_t length) const {
73 Byte t0(bytes + 0);
74 int32_t x = t0.get_byte(0, 8);
75
76 Byte t1(bytes + 1);
77 int32_t t = t1.get_byte(3, 5);
78 x <<= 5;
79 x |= t;
80
81 double ret = x * 0.056250;
82 return ret;
83}
84
85// config detail: {'description': 'Rear left wheel Moving direction', 'enum':
86// {0: 'RLWHEELDRIVEDIRECTION_INVALID', 1: 'RLWHEELDRIVEDIRECTION_FORWARD',
87// 2: 'RLWHEELDRIVEDIRECTION_BACKWARD', 3: 'RLWHEELDRIVEDIRECTION_STOP'},
88// 'precision': 1.0, 'len': 2, 'name': 'rlwheeldrivedirection',
89// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]',
90// 'bit': 9, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
91Fbs2_240::RlwheeldrivedirectionType Fbs2240::rlwheeldrivedirection(
92 const std::uint8_t* bytes, int32_t length) const {
93 Byte t0(bytes + 1);
94 int32_t x = t0.get_byte(0, 2);
95
98 return ret;
99}
100
101// config detail: {'description': 'Rear left wheel speed', 'offset': 0.0,
102// 'precision': 0.05625, 'len': 13, 'name':'rlwheelspd','is_signed_var': False,
103// 'physical_range': '[0|299.98125]', 'bit': 23, 'type': 'double',
104// 'order': 'motorola', 'physical_unit': 'Km/h'}
105double Fbs2240::rlwheelspd(const std::uint8_t* bytes, int32_t length) const {
106 Byte t0(bytes + 2);
107 int32_t x = t0.get_byte(0, 8);
108
109 Byte t1(bytes + 3);
110 int32_t t = t1.get_byte(3, 5);
111 x <<= 5;
112 x |= t;
113
114 double ret = x * 0.056250;
115 return ret;
116}
117
118// config detail: {'description': 'Rear right wheel Moving direction', 'enum':
119// {0: 'RRWHEELDIRECTION_INVALID', 1: 'RRWHEELDIRECTION_FORWARD',
120// 2: 'RRWHEELDIRECTION_BACKWARD', 3: 'RRWHEELDIRECTION_STOP'},'precision':1.0,
121// 'len': 2, 'name': 'rrwheeldirection', 'is_signed_var': False, 'offset': 0.0,
122// 'physical_range': '[0|3]', 'bit': 25, 'type': 'enum', 'order': 'motorola',
123// 'physical_unit': ''}
124Fbs2_240::RrwheeldirectionType Fbs2240::rrwheeldirection(
125 const std::uint8_t* bytes, int32_t length) const {
126 Byte t0(bytes + 3);
127 int32_t x = t0.get_byte(0, 2);
128
130 static_cast<Fbs2_240::RrwheeldirectionType>(x);
131 return ret;
132}
133
134// config detail: {'description': 'Rear right wheel speed', 'offset': 0.0,
135// 'precision': 0.05625, 'len': 13, 'name': 'rrwheelspd','is_signed_var':False,
136// 'physical_range': '[0|299.98125]', 'bit': 39, 'type': 'double',
137// 'order': 'motorola', 'physical_unit': 'Km/h'}
138double Fbs2240::rrwheelspd(const std::uint8_t* bytes, int32_t length) const {
139 Byte t0(bytes + 4);
140 int32_t x = t0.get_byte(0, 8);
141
142 Byte t1(bytes + 5);
143 int32_t t = t1.get_byte(3, 5);
144 x <<= 5;
145 x |= t;
146
147 double ret = x * 0.056250;
148 return ret;
149}
150
151// config detail: {'description': 'Current Vehicle speed information','offset':
152// 0.0, 'precision': 0.05625, 'len': 13, 'name': 'vehiclespd',
153// 'is_signed_var': False, 'physical_range': '[0|299.98125]', 'bit': 55,
154// 'type': 'double', 'order': 'motorola', 'physical_unit': 'Km/h'}
155double Fbs2240::vehiclespd(const std::uint8_t* bytes, int32_t length) const {
156 Byte t0(bytes + 6);
157 int32_t x = t0.get_byte(0, 8);
158
159 Byte t1(bytes + 7);
160 int32_t t = t1.get_byte(3, 5);
161 x <<= 5;
162 x |= t;
163
164 double ret = x * 0.056250;
165 return ret;
166}
167} // namespace wey
168} // namespace canbus
169} // namespace apollo
Defines the Byte class.
static const int32_t ID
Definition fbs2_240.h:29
void Parse(const std::uint8_t *bytes, int32_t length, Wey *chassis) const override
Definition fbs2_240.cc:33
class register implement
Definition arena_queue.h:37