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