Apollo 10.0
自动驾驶开放平台
region_config_401.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2021 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
21
22namespace apollo {
23namespace drivers {
24namespace nano_radar {
25
28
29const uint32_t RegionConfig401::ID = 0x401;
30
33
35 static const uint32_t PERIOD = 100 * 1000;
36 return PERIOD;
37}
38
43void RegionConfig401::UpdateData(uint8_t* data) {
45 data, radar_conf_.collision_detection_coordinates_valid());
47 data, radar_conf_.collision_detection_activation_valid());
48
50 data, static_cast<uint8_t>(radar_conf_.region_max_output_number()));
51 set_region_id_p(data, static_cast<uint8_t>(radar_conf_.region_id()));
53 static_cast<double>(radar_conf_.point1_longitude()));
54 set_point1_lateral_p(data, static_cast<double>(radar_conf_.point1_lateral()));
56 static_cast<double>(radar_conf_.point2_longitude()));
57 set_point2_lateral_p(data, static_cast<double>(radar_conf_.point2_lateral()));
58}
59
64 radar_conf_.set_collision_detection_coordinates_valid(false);
65 radar_conf_.set_collision_detection_activation_valid(false);
66
67 radar_conf_.set_region_max_output_number(63);
68 radar_conf_.set_region_id(1);
69 radar_conf_.set_point1_longitude(0);
70 radar_conf_.set_point1_lateral(50);
71 radar_conf_.set_point2_longitude(20);
72 radar_conf_.set_point2_lateral(-50);
73}
74
75RadarConf RegionConfig401::radar_conf() { return radar_conf_; }
76
78 radar_conf_.CopyFrom(radar_conf);
79 return this;
80}
81
83 bool valid) {
84 radar_conf_.set_collision_detection_coordinates_valid(valid);
85 return this;
86}
87
89 bool valid) {
90 radar_conf_.set_collision_detection_activation_valid(valid);
91 return this;
92}
93
95 radar_conf_.set_region_max_output_number(data);
96 return this;
97}
98
100 radar_conf_.set_region_id(data);
101 return this;
102}
103
105 radar_conf_.set_point1_longitude(data);
106 return this;
107}
108
110 radar_conf_.set_point1_lateral(data);
111 return this;
112}
113
115 radar_conf_.set_point2_longitude(data);
116 return this;
117}
118
120 radar_conf_.set_point2_lateral(data);
121 return this;
122}
123
125 bool valid) {
126 Byte frame(data);
127 if (valid) {
128 frame.set_value(1, 7, 1);
129 } else {
130 frame.set_value(0, 7, 1);
131 }
132}
133
135 bool valid) {
136 Byte frame(data);
137 if (valid) {
138 frame.set_value(1, 6, 1);
139 } else {
140 frame.set_value(0, 6, 1);
141 }
142}
143
145 uint8_t value) {
146 Byte frame(data);
147 frame.set_value(value, 0, 6);
148}
149
150void RegionConfig401::set_region_id_p(uint8_t* data, uint8_t value) {
151 Byte frame(data + 1);
152 frame.set_value(value, 0, 3);
153}
154
155void RegionConfig401::set_point1_longitude_p(uint8_t* data, double value) {
156 uint16_t x = (value - REGION_POINT_LONG_MIN) / REGION_POINT_RES;
157 uint8_t t = 0;
158
159 t = x & 0x1F;
160 Byte to_set0(data + 3);
161 to_set0.set_value(t, 3, 5);
162
163 x >>= 5;
164 t = x & 0xFF;
165 Byte to_set1(data + 2);
166 to_set1.set_value(t, 0, 8);
167}
168
169void RegionConfig401::set_point1_lateral_p(uint8_t* data, double value) {
170 uint16_t x = (value - REGION_POINT_LAT_MIN) / REGION_POINT_RES;
171 uint8_t t = 0;
172
173 t = x & 0xFF;
174 Byte to_set0(data + 4);
175 to_set0.set_value(t, 0, 8);
176
177 x >>= 8;
178 t = x & 0x7;
179 Byte to_set1(data + 3);
180 to_set1.set_value(t, 0, 3);
181}
182
183void RegionConfig401::set_point2_longitude_p(uint8_t* data, double value) {
184 uint16_t x = (value - REGION_POINT_LONG_MIN) / REGION_POINT_RES;
185 uint8_t t = 0;
186
187 t = x & 0x1F;
188 Byte to_set0(data + 6);
189 to_set0.set_value(t, 3, 5);
190
191 x >>= 5;
192 t = x & 0xFF;
193 Byte to_set1(data + 5);
194 to_set1.set_value(t, 0, 8);
195}
196
197void RegionConfig401::set_point2_lateral_p(uint8_t* data, double value) {
198 uint16_t x = ceil((value - REGION_POINT_LAT_MIN) / REGION_POINT_RES);
199 uint8_t t = 0;
200
201 t = x & 0xFF;
202 Byte to_set0(data + 7);
203 to_set0.set_value(t, 0, 8);
204
205 x >>= 8;
206 t = x & 0x7;
207 Byte to_set1(data + 6);
208 to_set1.set_value(t, 0, 3);
209}
210
211} // namespace nano_radar
212} // namespace drivers
213} // namespace apollo
Defines the Byte class.
The class of one byte, which is 8 bits.
Definition byte.h:39
void set_value(const uint8_t value)
Reset this Byte by a specified one-byte unsigned integer.
Definition byte.cc:90
RegionConfig401 * set_region_max_output_number(uint8_t data)
RegionConfig401 * set_collision_detection_activation_valid(bool valid)
void set_point1_lateral_p(uint8_t *data, double value)
void set_point2_longitude_p(uint8_t *data, double value)
RegionConfig401 * set_region_id(uint8_t datad)
void set_collision_detection_activation_valid_p(uint8_t *data, bool valid)
void set_region_max_output_number_p(uint8_t *data, uint8_t value)
void set_point2_lateral_p(uint8_t *data, double value)
RegionConfig401 * set_point1_lateral(double data)
RegionConfig401 * set_collision_detection_coordinates_valid(bool valid)
RegionConfig401 * set_radar_conf(RadarConf radar_conf)
void UpdateData(uint8_t *data) override
update the data
void Reset() override
reset the private variables
uint32_t GetPeriod() const override
get the data period
void set_collision_detection_coordinates_valid_p(uint8_t *data, bool valid)
RegionConfig401 * set_point2_longitude(double data)
RegionConfig401 * set_point2_lateral(double data)
void set_point1_longitude_p(uint8_t *data, double value)
RegionConfig401 * set_point1_longitude(double data)
void set_region_id_p(uint8_t *data, uint8_t value)
const double REGION_POINT_RES
Definition const_vars.h:58
const double REGION_POINT_LAT_MIN
Definition const_vars.h:60
const double REGION_POINT_LONG_MIN
Definition const_vars.h:59
class register implement
Definition arena_queue.h:37