Apollo 11.0
自动驾驶开放平台
vehicle_state_feedback_c1.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 zhongyun {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Vehiclestatefeedbackc1::ID = 0xC1;
32
33void Vehiclestatefeedbackc1::Parse(const std::uint8_t* bytes, int32_t length,
34 Zhongyun* chassis) const {
35 chassis->mutable_vehicle_state_feedback_c1()->set_parking_actual(
36 parking_actual(bytes, length));
37 chassis->mutable_vehicle_state_feedback_c1()->set_brake_torque_feedback(
38 brake_torque_feedback(bytes, length));
39 chassis->mutable_vehicle_state_feedback_c1()->set_gear_state_actual(
40 gear_state_actual(bytes, length));
41 chassis->mutable_vehicle_state_feedback_c1()->set_steering_actual(
42 steering_actual(bytes, length));
43 chassis->mutable_vehicle_state_feedback_c1()->set_speed(
44 speed(bytes, length) / 3.6);
45}
46
47// config detail: {'name': 'parking_actual', 'enum': {0:
48// 'PARKING_ACTUAL_RELEASE', 1: 'PARKING_ACTUAL_PARKING_TRIGGER'},
49// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
50// 'physical_range': '[0|1]', 'bit': 56, 'type': 'enum', 'order': 'intel',
51// 'physical_unit': ''}
53Vehiclestatefeedbackc1::parking_actual(const std::uint8_t* bytes,
54 int32_t length) const {
55 Byte t0(bytes + 7);
56 int32_t x = t0.get_byte(0, 8);
57
60 return ret;
61}
62
63// config detail: {'name': 'brake_torque_feedback', 'offset': 0.0, 'precision':
64// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit':
65// 40, 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
66double Vehiclestatefeedbackc1::brake_torque_feedback(const std::uint8_t* bytes,
67 int32_t length) const {
68 Byte t0(bytes + 6);
69 int32_t x = t0.get_byte(0, 8);
70
71 Byte t1(bytes + 5);
72 int32_t t = t1.get_byte(0, 8);
73 x <<= 8;
74 x |= t;
75
76 double ret = x * 0.050000;
77 return ret;
78}
79
80// config detail: {'name': 'gear_state_actual', 'enum': {1:
81// 'GEAR_STATE_ACTUAL_P', 2: 'GEAR_STATE_ACTUAL_N', 3: 'GEAR_STATE_ACTUAL_D', 4:
82// 'GEAR_STATE_ACTUAL_R', 5: 'GEAR_STATE_ACTUAL_INVALID'}, 'precision': 1.0,
83// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|5]',
84// 'bit': 32, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
86Vehiclestatefeedbackc1::gear_state_actual(const std::uint8_t* bytes,
87 int32_t length) const {
88 Byte t0(bytes + 4);
89 int32_t x = t0.get_byte(0, 8);
90
93 return ret;
94}
95
96// config detail: {'name': 'steering_actual', 'offset': -1638.35, 'precision':
97// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[-40|40]', 'bit':
98// 16, 'type': 'double', 'order': 'intel', 'physical_unit': 'deg'}
99double Vehiclestatefeedbackc1::steering_actual(const std::uint8_t* bytes,
100 int32_t length) const {
101 Byte t0(bytes + 3);
102 int32_t x = t0.get_byte(0, 8);
103
104 Byte t1(bytes + 2);
105 int32_t t = t1.get_byte(0, 8);
106 x <<= 8;
107 x |= t;
108
109 double ret = x * 0.050000 + -1638.350000;
110 return ret;
111}
112
113// config detail: {'name': 'speed', 'offset': 0.0, 'precision': 0.01, 'len': 16,
114// 'is_signed_var': False, 'physical_range': '[0|35]', 'bit': 0, 'type':
115// 'double', 'order': 'intel', 'physical_unit': 'kph'}
116double Vehiclestatefeedbackc1::speed(const std::uint8_t* bytes,
117 int32_t length) const {
118 Byte t0(bytes + 1);
119 int32_t x = t0.get_byte(0, 8);
120
121 Byte t1(bytes + 0);
122 int32_t t = t1.get_byte(0, 8);
123 x <<= 8;
124 x |= t;
125
126 double ret = x * 0.010000;
127 return ret;
128}
129} // namespace zhongyun
130} // namespace canbus
131} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Zhongyun *chassis) const override
class register implement
Definition arena_queue.h:37