Apollo 10.0
自动驾驶开放平台
scu_eps_311.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 Scueps311::ID = 0x311;
30
31void Scueps311::Parse(const std::uint8_t* bytes, int32_t length,
32 Ge3* chassis) const {
33 chassis->mutable_scu_eps_311()->set_eps_intidx(
34 eps_intidx(bytes, length));
35 chassis->mutable_scu_eps_311()->set_eps_steeranglespd(
36 eps_steeranglespd(bytes, length));
37 chassis->mutable_scu_eps_311()->set_eps_steerangle(
38 eps_steerangle(bytes, length));
39 chassis->mutable_scu_eps_311()->set_eps_faultst(
40 eps_faultst(bytes, length));
41 chassis->mutable_scu_eps_311()->set_eps_drvmode(
42 eps_drvmode(bytes, length));
43}
44
45// config detail: {'description': 'EPS interrupt index', 'enum': {0:
46// 'EPS_INTIDX_NOINT', 1: 'EPS_INTIDX_OVERFLOW', 2: 'EPS_INTIDX_TIMEOUT', 3:
47// 'EPS_INTIDX_STEERINT'}, 'precision': 1.0, 'len': 3, 'name': 'eps_intidx',
48// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|7]', 'bit': 6,
49// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
50Scu_eps_311::Eps_intidxType Scueps311::eps_intidx(const std::uint8_t* bytes,
51 int32_t length) const {
52 Byte t0(bytes + 0);
53 int32_t x = t0.get_byte(4, 3);
54
56 return ret;
57}
58
59// config detail: {'description': 'Steer angle speed', 'offset': 0.0,
60// 'precision': 4.0, 'len': 8, 'name': 'eps_steeranglespd', 'is_signed_var':
61// False, 'physical_range': '[0|1016]', 'bit': 15, 'type': 'double', 'order':
62// 'motorola', 'physical_unit': 'deg/s'}
63double Scueps311::eps_steeranglespd(const std::uint8_t* bytes,
64 int32_t length) const {
65 Byte t0(bytes + 1);
66 int32_t x = t0.get_byte(0, 8);
67
68 double ret = x * 4.000000;
69 return ret;
70}
71
72// config detail: {'description': 'Steer angle Left + right -', 'offset':
73// -780.0, 'precision': 0.1, 'len': 16, 'name': 'eps_steerangle',
74// 'is_signed_var': False, 'physical_range': '[-780|779.9]', 'bit': 23, 'type':
75// 'double', 'order': 'motorola', 'physical_unit': 'deg'}
76double Scueps311::eps_steerangle(const std::uint8_t* bytes,
77 int32_t length) const {
78 Byte t0(bytes + 2);
79 int32_t x = t0.get_byte(0, 8);
80
81 Byte t1(bytes + 3);
82 int32_t t = t1.get_byte(0, 8);
83 x <<= 8;
84 x |= t;
85
86 double ret = x * 0.100000 + -780.000000;
87 return ret;
88}
89
90// config detail: {'description': 'EPS fault status', 'enum': {0:
91// 'EPS_FAULTST_NORMAL', 1: 'EPS_FAULTST_FAULT'}, 'precision': 1.0, 'len': 1,
92// 'name': 'eps_faultst', 'is_signed_var': False, 'offset': 0.0,
93// 'physical_range': '[0|1]', 'bit': 7, 'type': 'enum', 'order': 'motorola',
94// 'physical_unit': ''}
95Scu_eps_311::Eps_faultstType Scueps311::eps_faultst(const std::uint8_t* bytes,
96 int32_t length) const {
97 Byte t0(bytes + 0);
98 int32_t x = t0.get_byte(7, 1);
99
101 static_cast<Scu_eps_311::Eps_faultstType>(x);
102 return ret;
103}
104
105// config detail: {'description': 'EPS drive mode', 'enum': {0:
106// 'EPS_DRVMODE_INVALID', 1: 'EPS_DRVMODE_MANUAL', 2: 'EPS_DRVMODE_INTERRUPT',
107// 3: 'EPS_DRVMODE_AUTO'}, 'precision': 1.0, 'len': 2, 'name': 'eps_drvmode',
108// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]', 'bit': 1,
109// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
110Scu_eps_311::Eps_drvmodeType Scueps311::eps_drvmode(const std::uint8_t* bytes,
111 int32_t length) const {
112 Byte t0(bytes + 0);
113 int32_t x = t0.get_byte(0, 2);
114
116 static_cast<Scu_eps_311::Eps_drvmodeType>(x);
117 return ret;
118}
119} // namespace ge3
120} // namespace canbus
121} // namespace apollo
Defines the Byte class.
static const int32_t ID
Definition scu_eps_311.h:29
void Parse(const std::uint8_t *bytes, int32_t length, Ge3 *chassis) const override
class register implement
Definition arena_queue.h:37