Apollo 10.0
自动驾驶开放平台
steering_rpt_1_6e.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 gem {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Steeringrpt16e::ID = 0x6E;
32
33void Steeringrpt16e::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_steering_rpt_1_6e()->set_manual_input(
36 manual_input(bytes, length));
37 chassis->mutable_steering_rpt_1_6e()->set_commanded_value(
38 commanded_value(bytes, length));
39 chassis->mutable_steering_rpt_1_6e()->set_output_value(
40 output_value(bytes, length));
41}
42
43// config detail: {'name': 'manual_input', 'offset': 0.0, 'precision': 0.001,
44// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
45// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'}
46double Steeringrpt16e::manual_input(const std::uint8_t* bytes,
47 int32_t length) const {
48 Byte t0(bytes + 0);
49 int32_t x = t0.get_byte(0, 8);
50
51 Byte t1(bytes + 1);
52 int32_t t = t1.get_byte(0, 8);
53 x <<= 8;
54 x |= t;
55
56 x <<= 16;
57 x >>= 16;
58
59 double ret = x * 0.001000;
60 return ret;
61}
62
63// config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 0.001,
64// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
65// 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'}
66double Steeringrpt16e::commanded_value(const std::uint8_t* bytes,
67 int32_t length) const {
68 Byte t0(bytes + 2);
69 int32_t x = t0.get_byte(0, 8);
70
71 Byte t1(bytes + 3);
72 int32_t t = t1.get_byte(0, 8);
73 x <<= 8;
74 x |= t;
75
76 x <<= 16;
77 x >>= 16;
78
79 double ret = x * 0.001000;
80 return ret;
81}
82
83// config detail: {'name': 'output_value', 'offset': 0.0, 'precision': 0.001,
84// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
85// 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'}
86double Steeringrpt16e::output_value(const std::uint8_t* bytes,
87 int32_t length) const {
88 Byte t0(bytes + 4);
89 int32_t x = t0.get_byte(0, 8);
90
91 Byte t1(bytes + 5);
92 int32_t t = t1.get_byte(0, 8);
93 x <<= 8;
94 x |= t;
95
96 x <<= 16;
97 x >>= 16;
98
99 double ret = x * 0.001000;
100 return ret;
101}
102} // namespace gem
103} // namespace canbus
104} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Gem *chassis) const override
class register implement
Definition arena_queue.h:37