Apollo 10.0
自动驾驶开放平台
steering_motor_rpt_2_74.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 Steeringmotorrpt274::ID = 0x74;
32
33void Steeringmotorrpt274::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_steering_motor_rpt_2_74()->set_encoder_temperature(
36 encoder_temperature(bytes, length));
37 chassis->mutable_steering_motor_rpt_2_74()->set_motor_temperature(
38 motor_temperature(bytes, length));
39 chassis->mutable_steering_motor_rpt_2_74()->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 Steeringmotorrpt274::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 Steeringmotorrpt274::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': True, 'physical_range':
87// '[-2147483.648|2147483.647]', 'bit': 39, 'type': 'double', 'order':
88// 'motorola', 'physical_unit': 'rev/s'}
89double Steeringmotorrpt274::angular_speed(const std::uint8_t* bytes,
90 int32_t length) const {
91 Byte t0(bytes + 4);
92 int32_t x = t0.get_byte(0, 8);
93
94 Byte t1(bytes + 5);
95 int32_t t = t1.get_byte(0, 8);
96 x <<= 8;
97 x |= t;
98
99 Byte t2(bytes + 6);
100 t = t2.get_byte(0, 8);
101 x <<= 8;
102 x |= t;
103
104 Byte t3(bytes + 7);
105 t = t3.get_byte(0, 8);
106 x <<= 8;
107 x |= t;
108
109 x <<= 0;
110 x >>= 0;
111
112 double ret = x * 0.001000;
113 return ret;
114}
115} // namespace gem
116} // namespace canbus
117} // 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