Apollo 10.0
自动驾驶开放平台
scu_bcs_2_307.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#include "glog/logging.h"
21
22namespace apollo {
23namespace canbus {
24namespace ge3 {
25
26using ::apollo::drivers::canbus::Byte;
27
29const int32_t Scubcs2307::ID = 0x307;
30
31void Scubcs2307::Parse(const std::uint8_t* bytes, int32_t length,
32 Ge3* chassis) const {
33 chassis->mutable_scu_bcs_2_307()->set_bcs_vehspdvd(
34 bcs_vehspdvd(bytes, length));
35 chassis->mutable_scu_bcs_2_307()->set_bcs_yawrate(
36 bcs_yawrate(bytes, length));
37 chassis->mutable_scu_bcs_2_307()->set_bcs_vehspd(
38 bcs_vehspd(bytes, length));
39 chassis->mutable_scu_bcs_2_307()->set_bcs_vehlongaccel(
40 bcs_vehlongaccel(bytes, length));
41 chassis->mutable_scu_bcs_2_307()->set_bcs_vehlataccel(
42 bcs_vehlataccel(bytes, length));
43}
44
45// config detail: {'description': 'Vehicle speed valid data', 'enum': {0:
46// 'BCS_VEHSPDVD_INVALID', 1: 'BCS_VEHSPDVD_VALID'}, 'precision': 1.0, 'len': 1,
47// 'name': 'bcs_vehspdvd', 'is_signed_var': False, 'offset': 0.0,
48// 'physical_range': '[0|1]', 'bit': 40, 'type': 'enum', 'order': 'motorola',
49// 'physical_unit': '-'}
50Scu_bcs_2_307::Bcs_vehspdvdType Scubcs2307::bcs_vehspdvd(
51 const std::uint8_t* bytes, int32_t length) const {
52 Byte t0(bytes + 5);
53 int32_t x = t0.get_byte(0, 1);
54
56 static_cast<Scu_bcs_2_307::Bcs_vehspdvdType>(x);
57 return ret;
58}
59
60// config detail: {'description': 'Yaw rate', 'offset': -2.2243, 'precision':
61// 0.0021326, 'len': 12, 'name': 'bcs_yawrate', 'is_signed_var': False,
62// 'physical_range': '[-2.2243|2.2243]', 'bit': 55, 'type': 'double', 'order':
63// 'motorola', 'physical_unit': 'rad/s'}
64double Scubcs2307::bcs_yawrate(const std::uint8_t* bytes,
65 int32_t length) const {
66 Byte t0(bytes + 6);
67 int32_t x = t0.get_byte(0, 8);
68
69 Byte t1(bytes + 7);
70 int32_t t = t1.get_byte(4, 4);
71 x <<= 4;
72 x |= t;
73
74 double ret = x * 0.002133 + -2.224300;
75 return ret;
76}
77
78// config detail: {'description': 'Vehicle speed', 'offset': 0.0, 'precision':
79// 0.05625, 'len': 13, 'name': 'bcs_vehspd', 'is_signed_var': False,
80// 'physical_range': '[0|240]', 'bit': 39, 'type': 'double', 'order':
81// 'motorola', 'physical_unit': 'km/h'}
82double Scubcs2307::bcs_vehspd(const std::uint8_t* bytes, int32_t length) const {
83 Byte t0(bytes + 4);
84 int32_t x = t0.get_byte(0, 8);
85
86 Byte t1(bytes + 5);
87 int32_t t = t1.get_byte(3, 5);
88 x <<= 5;
89 x |= t;
90
91 double ret = x * 0.056250 / 3.6; // modified by 20181211 , change km/h to m/s
92 return ret;
93}
94
95// config detail: {'description': 'Vehicle longitudinal acceleration', 'offset':
96// -21.593, 'precision': 0.027126736, 'len': 12, 'name': 'bcs_vehlongaccel',
97// 'is_signed_var': False, 'physical_range': '[-21.593|21.593]', 'bit': 23,
98// 'type': 'double', 'order': 'motorola', 'physical_unit': 'm/s^2'}
99double Scubcs2307::bcs_vehlongaccel(const std::uint8_t* bytes,
100 int32_t length) const {
101 Byte t0(bytes + 2);
102 int32_t x = t0.get_byte(0, 8);
103
104 Byte t1(bytes + 3);
105 int32_t t = t1.get_byte(4, 4);
106 x <<= 4;
107 x |= t;
108
109 double ret = x * 0.027127 + -21.593000;
110 return ret;
111}
112
113// config detail: {'description': 'Vehicle lateral acceleration', 'offset':
114// -21.593, 'precision': 0.027126736, 'len': 12, 'name': 'bcs_vehlataccel',
115// 'is_signed_var': False, 'physical_range': '[-21.593|21.593]', 'bit': 7,
116// 'type': 'double', 'order': 'motorola', 'physical_unit': 'm/s^2'}
117double Scubcs2307::bcs_vehlataccel(const std::uint8_t* bytes,
118 int32_t length) const {
119 Byte t0(bytes + 0);
120 int32_t x = t0.get_byte(0, 8);
121
122 Byte t1(bytes + 1);
123 int32_t t = t1.get_byte(4, 4);
124 x <<= 4;
125 x |= t;
126
127 double ret = x * 0.027127 + -21.593000;
128 return ret;
129}
130} // namespace ge3
131} // namespace canbus
132} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Ge3 *chassis) const override
class register implement
Definition arena_queue.h:37