Apollo 10.0
自动驾驶开放平台
accel_rpt_68.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 Accelrpt68::ID = 0x68;
32
33void Accelrpt68::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_accel_rpt_68()->set_manual_input(
36 manual_input(bytes, length));
37 chassis->mutable_accel_rpt_68()->set_commanded_value(
38 commanded_value(bytes, length));
39 chassis->mutable_accel_rpt_68()->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': False, 'physical_range': '[0|1]', 'bit': 7,
45// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
46double Accelrpt68::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 double ret = x * 0.001000;
57 return ret;
58}
59
60// config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 0.001,
61// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 23,
62// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
63double Accelrpt68::commanded_value(const std::uint8_t* bytes,
64 int32_t length) const {
65 Byte t0(bytes + 2);
66 int32_t x = t0.get_byte(0, 8);
67
68 Byte t1(bytes + 3);
69 int32_t t = t1.get_byte(0, 8);
70 x <<= 8;
71 x |= t;
72
73 double ret = x * 0.001000;
74 return ret;
75}
76
77// config detail: {'name': 'output_value', 'offset': 0.0, 'precision': 0.001,
78// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 39,
79// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
80double Accelrpt68::output_value(const std::uint8_t* bytes,
81 int32_t length) const {
82 Byte t0(bytes + 4);
83 int32_t x = t0.get_byte(0, 8);
84
85 Byte t1(bytes + 5);
86 int32_t t = t1.get_byte(0, 8);
87 x <<= 8;
88 x |= t;
89
90 double ret = x * 0.001000;
91 return ret;
92}
93} // namespace gem
94} // namespace canbus
95} // 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