Apollo 10.0
自动驾驶开放平台
accel_aux_rpt_300.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 lexus {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Accelauxrpt300::ID = 0x300;
32
33void Accelauxrpt300::Parse(const std::uint8_t* bytes, int32_t length,
34 Lexus* chassis) const {
35 chassis->mutable_accel_aux_rpt_300()->set_user_interaction_is_valid(
36 user_interaction_is_valid(bytes, length));
37 chassis->mutable_accel_aux_rpt_300()->set_user_interaction(
38 user_interaction(bytes, length));
39 chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_force_is_valid(
40 raw_pedal_force_is_valid(bytes, length));
41 chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_force(
42 raw_pedal_force(bytes, length));
43 chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_pos_is_valid(
44 raw_pedal_pos_is_valid(bytes, length));
45 chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_pos(
46 raw_pedal_pos(bytes, length));
47}
48
49// config detail: {'name': 'user_interaction_is_valid', 'offset': 0.0,
50// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
51// '[0|1]', 'bit': 42, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
52bool Accelauxrpt300::user_interaction_is_valid(const std::uint8_t* bytes,
53 int32_t length) const {
54 Byte t0(bytes + 5);
55 int32_t x = t0.get_byte(2, 1);
56
57 bool ret = x;
58 return ret;
59}
60
61// config detail: {'name': 'user_interaction', 'offset': 0.0, 'precision': 1.0,
62// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 32,
63// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
64bool Accelauxrpt300::user_interaction(const std::uint8_t* bytes,
65 int32_t length) const {
66 Byte t0(bytes + 4);
67 int32_t x = t0.get_byte(0, 1);
68
69 bool ret = x;
70 return ret;
71}
72
73// config detail: {'name': 'raw_pedal_force_is_valid', 'offset': 0.0,
74// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
75// '[0|1]', 'bit': 41, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
76bool Accelauxrpt300::raw_pedal_force_is_valid(const std::uint8_t* bytes,
77 int32_t length) const {
78 Byte t0(bytes + 5);
79 int32_t x = t0.get_byte(1, 1);
80
81 bool ret = x;
82 return ret;
83}
84
85// config detail: {'name': 'raw_pedal_force', 'offset': 0.0, 'precision': 0.001,
86// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
87// 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
88double Accelauxrpt300::raw_pedal_force(const std::uint8_t* bytes,
89 int32_t length) const {
90 Byte t0(bytes + 2);
91 int32_t x = t0.get_byte(0, 8);
92
93 Byte t1(bytes + 3);
94 int32_t t = t1.get_byte(0, 8);
95 x <<= 8;
96 x |= t;
97
98 x <<= 16;
99 x >>= 16;
100
101 double ret = x * 0.001000;
102 return ret;
103}
104
105// config detail: {'name': 'raw_pedal_pos_is_valid', 'offset': 0.0,
106// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range':
107// '[0|1]', 'bit': 40, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
108bool Accelauxrpt300::raw_pedal_pos_is_valid(const std::uint8_t* bytes,
109 int32_t length) const {
110 Byte t0(bytes + 5);
111 int32_t x = t0.get_byte(0, 1);
112
113 bool ret = x;
114 return ret;
115}
116
117// config detail: {'name': 'raw_pedal_pos', 'offset': 0.0, 'precision': 0.001,
118// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
119// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
120double Accelauxrpt300::raw_pedal_pos(const std::uint8_t* bytes,
121 int32_t length) const {
122 Byte t0(bytes + 0);
123 int32_t x = t0.get_byte(0, 8);
124
125 Byte t1(bytes + 1);
126 int32_t t = t1.get_byte(0, 8);
127 x <<= 8;
128 x |= t;
129
130 x <<= 16;
131 x >>= 16;
132
133 double ret = x * 0.001000;
134 return ret;
135}
136} // namespace lexus
137} // namespace canbus
138} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Lexus *chassis) const override
class register implement
Definition arena_queue.h:37