Apollo 10.0
自动驾驶开放平台
brake_motor_rpt_2_71.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 Brakemotorrpt271::ID = 0x71;
32
33void Brakemotorrpt271::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_brake_motor_rpt_2_71()->set_encoder_temperature(
36 encoder_temperature(bytes, length));
37 chassis->mutable_brake_motor_rpt_2_71()->set_motor_temperature(
38 motor_temperature(bytes, length));
39 chassis->mutable_brake_motor_rpt_2_71()->set_angular_speed(
40 angular_speed(bytes, length));
41}
42
43// config detail: {'name': 'encoder_temperature', 'offset': -40.0,
44// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
45// '[-32808|32727]', 'bit': 7, 'type': 'int', 'order': 'motorola',
46// 'physical_unit': 'deg C'}
47int Brakemotorrpt271::encoder_temperature(const std::uint8_t* bytes,
48 int32_t length) const {
49 Byte t0(bytes + 0);
50 int32_t x = t0.get_byte(0, 8);
51
52 Byte t1(bytes + 1);
53 int32_t t = t1.get_byte(0, 8);
54 x <<= 8;
55 x |= t;
56
57 x <<= 16;
58 x >>= 16;
59
60 int ret = x + -40;
61 return ret;
62}
63
64// config detail: {'name': 'motor_temperature', 'offset': -40.0,
65// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
66// '[-32808|32727]', 'bit': 23, 'type': 'int', 'order': 'motorola',
67// 'physical_unit': 'deg C'}
68int Brakemotorrpt271::motor_temperature(const std::uint8_t* bytes,
69 int32_t length) const {
70 Byte t0(bytes + 2);
71 int32_t x = t0.get_byte(0, 8);
72
73 Byte t1(bytes + 3);
74 int32_t t = t1.get_byte(0, 8);
75 x <<= 8;
76 x |= t;
77
78 x <<= 16;
79 x >>= 16;
80
81 int ret = x + -40;
82 return ret;
83}
84
85// config detail: {'name': 'angular_speed', 'offset': 0.0, 'precision': 0.001,
86// 'len': 32, 'is_signed_var': False, 'physical_range': '[0|4294967.295]',
87// 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rev/s'}
88double Brakemotorrpt271::angular_speed(const std::uint8_t* bytes,
89 int32_t length) const {
90 Byte t0(bytes + 4);
91 int32_t x = t0.get_byte(0, 8);
92
93 Byte t1(bytes + 5);
94 int32_t t = t1.get_byte(0, 8);
95 x <<= 8;
96 x |= t;
97
98 Byte t2(bytes + 6);
99 t = t2.get_byte(0, 8);
100 x <<= 8;
101 x |= t;
102
103 Byte t3(bytes + 7);
104 t = t3.get_byte(0, 8);
105 x <<= 8;
106 x |= t;
107
108 double ret = x * 0.001000;
109 return ret;
110}
111} // namespace gem
112} // namespace canbus
113} // 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