Apollo 10.0
自动驾驶开放平台
brake_motor_rpt_1_70.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 Brakemotorrpt170::ID = 0x70;
32
33void Brakemotorrpt170::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_brake_motor_rpt_1_70()->set_motor_current(
36 motor_current(bytes, length));
37 chassis->mutable_brake_motor_rpt_1_70()->set_shaft_position(
38 shaft_position(bytes, length));
39}
40
41// config detail: {'name': 'motor_current', 'offset': 0.0, 'precision': 0.001,
42// 'len': 32, 'is_signed_var': False, 'physical_range': '[0|4294967.295]',
43// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'amps'}
44double Brakemotorrpt170::motor_current(const std::uint8_t* bytes,
45 int32_t length) const {
46 Byte t0(bytes + 0);
47 int32_t x = t0.get_byte(0, 8);
48
49 Byte t1(bytes + 1);
50 int32_t t = t1.get_byte(0, 8);
51 x <<= 8;
52 x |= t;
53
54 Byte t2(bytes + 2);
55 t = t2.get_byte(0, 8);
56 x <<= 8;
57 x |= t;
58
59 Byte t3(bytes + 3);
60 t = t3.get_byte(0, 8);
61 x <<= 8;
62 x |= t;
63
64 double ret = x * 0.001000;
65 return ret;
66}
67
68// config detail: {'name': 'shaft_position', 'offset': 0.0, 'precision': 0.001,
69// 'len': 32, 'is_signed_var': True, 'physical_range':
70// '[-2147483.648|2147483.647]', 'bit': 39, 'type': 'double', 'order':
71// 'motorola', 'physical_unit': 'radians'}
72double Brakemotorrpt170::shaft_position(const std::uint8_t* bytes,
73 int32_t length) const {
74 Byte t0(bytes + 4);
75 int32_t x = t0.get_byte(0, 8);
76
77 Byte t1(bytes + 5);
78 int32_t t = t1.get_byte(0, 8);
79 x <<= 8;
80 x |= t;
81
82 Byte t2(bytes + 6);
83 t = t2.get_byte(0, 8);
84 x <<= 8;
85 x |= t;
86
87 Byte t3(bytes + 7);
88 t = t3.get_byte(0, 8);
89 x <<= 8;
90 x |= t;
91
92 x <<= 0;
93 x >>= 0;
94
95 double ret = x * 0.001000;
96 return ret;
97}
98} // namespace gem
99} // namespace canbus
100} // 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