Apollo 10.0
自动驾驶开放平台
adc_motioncontrollimits1_12.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
20
21namespace apollo {
22namespace canbus {
23namespace transit {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Adcmotioncontrollimits112::ID = 0x12;
28
29// public
31
33 // TODO(All) : modify every protocol's period manually
34 static const uint32_t PERIOD = 10 * 1000;
35 return PERIOD;
36}
37
39 set_p_adc_cmd_throttlecommandlimit(data, adc_cmd_throttlecommandlimit_);
40 set_p_adc_cmd_steeringrate(data, adc_cmd_steeringrate_);
41 set_p_adc_cmd_steerwheelanglelimit(data, adc_cmd_steerwheelanglelimit_);
42}
43
45 // TODO(All) : you should check this manually
46 adc_cmd_throttlecommandlimit_ = 0.0;
47 adc_cmd_steeringrate_ = 0.0;
48 adc_cmd_steerwheelanglelimit_ = 0.0;
49}
50
53 double adc_cmd_throttlecommandlimit) {
54 adc_cmd_throttlecommandlimit_ = adc_cmd_throttlecommandlimit;
55 return this;
56}
57
58// config detail: {'description': 'Set limit for throttle position', 'offset':
59// 0.0, 'precision': 0.5, 'len': 8, 'name': 'ADC_CMD_ThrottleCommandLimit',
60// 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': 24, 'type':
61// 'double', 'order': 'intel', 'physical_unit': '%'}
62void Adcmotioncontrollimits112::set_p_adc_cmd_throttlecommandlimit(
63 uint8_t* data, double adc_cmd_throttlecommandlimit) {
64 adc_cmd_throttlecommandlimit =
65 ProtocolData::BoundedValue(0.0, 100.0, adc_cmd_throttlecommandlimit);
66 int x = static_cast<int>(adc_cmd_throttlecommandlimit / 0.500000);
67
68 Byte to_set(data + 3);
69 to_set.set_value(static_cast<uint8_t>(x), 0, 8);
70}
71
73 double adc_cmd_steeringrate) {
74 adc_cmd_steeringrate_ = adc_cmd_steeringrate;
75 return this;
76}
77
78// config detail: {'description': 'Set steering rate', 'offset': 0.0,
79// 'precision': 0.05, 'len': 16, 'name': 'ADC_CMD_SteeringRate',
80// 'is_signed_var': False, 'physical_range': '[0|3276.75]', 'bit': 0, 'type':
81// 'double', 'order': 'intel', 'physical_unit': 'deg/s'}
82void Adcmotioncontrollimits112::set_p_adc_cmd_steeringrate(
83 uint8_t* data, double adc_cmd_steeringrate) {
84 adc_cmd_steeringrate =
85 ProtocolData::BoundedValue(0.0, 3276.75, adc_cmd_steeringrate);
86 int x = static_cast<int>(adc_cmd_steeringrate / 0.050000);
87 uint8_t t = 0;
88
89 t = static_cast<uint8_t>(x & 0xFF);
90 Byte to_set0(data + 0);
91 to_set0.set_value(t, 0, 8);
92 x >>= 8;
93
94 t = static_cast<uint8_t>(x & 0xFF);
95 Byte to_set1(data + 1);
96 to_set1.set_value(t, 0, 8);
97}
98
99Adcmotioncontrollimits112*
101 double adc_cmd_steerwheelanglelimit) {
102 adc_cmd_steerwheelanglelimit_ = adc_cmd_steerwheelanglelimit;
103 return this;
104}
105
106// config detail: {'description': 'Set limit for steering wheel angle. Applies
107// in both positive and negative', 'offset': 0.0, 'precision': 5.0, 'len': 8,
108// 'name': 'ADC_CMD_SteerWheelAngleLimit', 'is_signed_var': False,
109// 'physical_range': '[0|1275]', 'bit': 16, 'type': 'double', 'order': 'intel',
110// 'physical_unit': 'deg'}
111void Adcmotioncontrollimits112::set_p_adc_cmd_steerwheelanglelimit(
112 uint8_t* data, double adc_cmd_steerwheelanglelimit) {
113 adc_cmd_steerwheelanglelimit =
114 ProtocolData::BoundedValue(0.0, 1275.0, adc_cmd_steerwheelanglelimit);
115 int x = static_cast<int>(adc_cmd_steerwheelanglelimit / 5.000000);
116
117 Byte to_set(data + 2);
118 to_set.set_value(static_cast<uint8_t>(x), 0, 8);
119}
120
121} // namespace transit
122} // namespace canbus
123} // namespace apollo
Defines the Byte class.
Adcmotioncontrollimits112 * set_adc_cmd_steeringrate(double adc_cmd_steeringrate)
Adcmotioncontrollimits112 * set_adc_cmd_throttlecommandlimit(double adc_cmd_throttlecommandlimit)
Adcmotioncontrollimits112 * set_adc_cmd_steerwheelanglelimit(double adc_cmd_steerwheelanglelimit)
class register implement
Definition arena_queue.h:37