Apollo 10.0
自动驾驶开放平台
turn_cmd_130.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 lexus {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Turncmd130::ID = 0x130;
28
29// public
31
32uint32_t Turncmd130::GetPeriod() const {
33 // TODO(QiL) modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Turncmd130::UpdateData(uint8_t* data) {
39 set_p_ignore_overrides(data, ignore_overrides_);
40 set_p_enable(data, enable_);
41 set_p_clear_override(data, clear_override_);
42 set_p_clear_faults(data, clear_faults_);
43 set_p_turn_signal_cmd(data, turn_signal_cmd_);
44}
45
47 // TODO(QiL) you should check this manually
48 ignore_overrides_ = false;
49 enable_ = false;
50 clear_override_ = false;
51 clear_faults_ = false;
52 turn_signal_cmd_ = Turn_cmd_130::TURN_SIGNAL_CMD_RIGHT;
53}
54
56 ignore_overrides_ = ignore_overrides;
57 return this;
58}
59
60// config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, 'precision': 1.0,
61// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1,
62// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
63void Turncmd130::set_p_ignore_overrides(uint8_t* data, bool ignore_overrides) {
64 uint8_t x = ignore_overrides;
65
66 Byte to_set(data + 0);
67 to_set.set_value(static_cast<uint8_t>(x), 1, 1);
68}
69
71 enable_ = enable;
72 return this;
73}
74
75// config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': 1,
76// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool',
77// 'order': 'motorola', 'physical_unit': ''}
78void Turncmd130::set_p_enable(uint8_t* data, bool enable) {
79 uint8_t x = enable;
80
81 Byte to_set(data + 0);
82 to_set.set_value(static_cast<uint8_t>(x), 0, 1);
83}
84
86 clear_override_ = clear_override;
87 return this;
88}
89
90// config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0,
91// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2,
92// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
93void Turncmd130::set_p_clear_override(uint8_t* data, bool clear_override) {
94 uint8_t x = clear_override;
95
96 Byte to_set(data + 0);
97 to_set.set_value(static_cast<uint8_t>(x), 2, 1);
98}
99
101 clear_faults_ = clear_faults;
102 return this;
103}
104
105// config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0,
106// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3,
107// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
108void Turncmd130::set_p_clear_faults(uint8_t* data, bool clear_faults) {
109 uint8_t x = clear_faults;
110
111 Byte to_set(data + 0);
112 to_set.set_value(static_cast<uint8_t>(x), 3, 1);
113}
114
116 Turn_cmd_130::Turn_signal_cmdType turn_signal_cmd) {
117 turn_signal_cmd_ = turn_signal_cmd;
118 return this;
119}
120
121// config detail: {'name': 'TURN_SIGNAL_CMD', 'enum': {0:
122// 'TURN_SIGNAL_CMD_RIGHT', 1: 'TURN_SIGNAL_CMD_NONE', 2:
123// 'TURN_SIGNAL_CMD_LEFT', 3: 'TURN_SIGNAL_CMD_HAZARD'}, 'precision': 1.0,
124// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]',
125// 'bit': 15, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
126void Turncmd130::set_p_turn_signal_cmd(
127 uint8_t* data, Turn_cmd_130::Turn_signal_cmdType turn_signal_cmd) {
128 uint8_t x = turn_signal_cmd;
129
130 Byte to_set(data + 1);
131 to_set.set_value(static_cast<uint8_t>(x), 0, 8);
132}
133
134} // namespace lexus
135} // namespace canbus
136} // namespace apollo
Defines the Byte class.
Turncmd130 * set_enable(bool enable)
void UpdateData(uint8_t *data) override
Turncmd130 * set_turn_signal_cmd(Turn_cmd_130::Turn_signal_cmdType turn_signal_cmd)
uint32_t GetPeriod() const override
Turncmd130 * set_clear_override(bool clear_override)
Turncmd130 * set_clear_faults(bool clear_faults)
Turncmd130 * set_ignore_overrides(bool ignore_overrides)
class register implement
Definition arena_queue.h:37