Apollo 10.0
自动驾驶开放平台
scu_vcu_2_313.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 Scuvcu2313::ID = 0x313;
30
31void Scuvcu2313::Parse(const std::uint8_t* bytes, int32_t length,
32 Ge3* chassis) const {
33 chassis->mutable_scu_vcu_2_313()->set_vcu_torqposmax(
34 vcu_torqposmax(bytes, length));
35 chassis->mutable_scu_vcu_2_313()->set_vcu_torqnegmax(
36 vcu_torqnegmax(bytes, length));
37 chassis->mutable_scu_vcu_2_313()->set_vcu_torqact(
38 vcu_torqact(bytes, length));
39 chassis->mutable_scu_vcu_2_313()->set_vcu_engspd(
40 vcu_engspd(bytes, length));
41}
42
43// config detail: {'description': 'Max positive torque', 'offset': 0.0,
44// 'precision': 1.5, 'len': 11, 'name': 'vcu_torqposmax', 'is_signed_var':
45// False, 'physical_range': '[0|3000]', 'bit': 55, 'type': 'double', 'order':
46// 'motorola', 'physical_unit': 'Nm'}
47double Scuvcu2313::vcu_torqposmax(const std::uint8_t* bytes,
48 int32_t length) const {
49 Byte t0(bytes + 6);
50 int32_t x = t0.get_byte(0, 8);
51
52 Byte t1(bytes + 7);
53 int32_t t = t1.get_byte(5, 3);
54 x <<= 3;
55 x |= t;
56
57 double ret = x * 1.500000;
58 return ret;
59}
60
61// config detail: {'description': 'Max negative torque', 'offset': -3000.0,
62// 'precision': 1.5, 'len': 11, 'name': 'vcu_torqnegmax', 'is_signed_var':
63// False, 'physical_range': '[-3000|0]', 'bit': 39, 'type': 'double', 'order':
64// 'motorola', 'physical_unit': 'Nm'}
65double Scuvcu2313::vcu_torqnegmax(const std::uint8_t* bytes,
66 int32_t length) const {
67 Byte t0(bytes + 4);
68 int32_t x = t0.get_byte(0, 8);
69
70 Byte t1(bytes + 5);
71 int32_t t = t1.get_byte(5, 3);
72 x <<= 3;
73 x |= t;
74
75 double ret = x * 1.500000 + -3000.000000;
76 return ret;
77}
78
79// config detail: {'description': 'Actual torque', 'offset': -3000.0,
80// 'precision': 1.5, 'len': 12, 'name': 'vcu_torqact', 'is_signed_var': False,
81// 'physical_range': '[-3000|3000]', 'bit': 23, 'type': 'double', 'order':
82// 'motorola', 'physical_unit': 'Nm'}
83double Scuvcu2313::vcu_torqact(const std::uint8_t* bytes,
84 int32_t length) const {
85 Byte t0(bytes + 2);
86 int32_t x = t0.get_byte(0, 8);
87
88 Byte t1(bytes + 3);
89 int32_t t = t1.get_byte(4, 4);
90 x <<= 4;
91 x |= t;
92
93 double ret = x * 1.500000 + -3000.000000;
94 return ret;
95}
96
97// config detail: {'description': 'Engine speed', 'offset': 0.0,
98// 'precision': 1.0, 'len': 16, 'name': 'vcu_engspd', 'is_signed_var': False,
99// 'physical_range': '[0|65535]', 'bit': 7, 'type': 'int', 'order': 'motorola',
100// 'physical_unit': 'rpm'}
101int Scuvcu2313::vcu_engspd(const std::uint8_t* bytes, int32_t length) const {
102 Byte t0(bytes + 0);
103 int32_t x = t0.get_byte(0, 8);
104
105 Byte t1(bytes + 1);
106 int32_t t = t1.get_byte(0, 8);
107 x <<= 8;
108 x |= t;
109
110 int ret = x;
111 return ret;
112}
113} // namespace ge3
114} // namespace canbus
115} // 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