Apollo 10.0
自动驾驶开放平台
apollo::third_party_perception::conversion_radar 命名空间参考

apollo::third_party_perception 更多...

类型定义

using Point = apollo::common::Point3D
 

函数

RadarObstacles ContiToRadarObstacles (const apollo::drivers::ContiRadar &conti_radar, const apollo::localization::LocalizationEstimate &localization, const RadarObstacles &last_radar_obstacles, const Chassis &chassis)
 
RadarObstacles DelphiToRadarObstacles (const DelphiESR &delphi_esr, const LocalizationEstimate &localization, const RadarObstacles &last_radar_obstacles)
 
PerceptionObstacles RadarObstaclesToPerceptionObstacles (const RadarObstacles &radar_obstacles)
 

详细描述

类型定义说明

◆ Point

函数说明

◆ ContiToRadarObstacles()

RadarObstacles apollo::third_party_perception::conversion_radar::ContiToRadarObstacles ( const apollo::drivers::ContiRadar conti_radar,
const apollo::localization::LocalizationEstimate localization,
const RadarObstacles last_radar_obstacles,
const Chassis chassis 
)

在文件 conversion_radar.cc48 行定义.

51 {
52 RadarObstacles obstacles;
53
54 const double last_timestamp = last_radar_obstacles.header().timestamp_sec();
55 const double current_timestamp = conti_radar.header().timestamp_sec();
56
57 const auto adc_pos = localization.pose().position();
58 const auto adc_vel = localization.pose().linear_velocity();
59 const auto adc_quaternion = localization.pose().orientation();
60 const double adc_theta = GetAngleFromQuaternion(adc_quaternion);
61
62 for (int index = 0; index < conti_radar.contiobs_size(); ++index) {
63 const auto& contiobs = conti_radar.contiobs(index);
64
65 RadarObstacle rob;
66
67 rob.set_id(contiobs.obstacle_id());
68 rob.set_rcs(contiobs.rcs());
69 rob.set_length(GetDefaultObjectLength(4));
70 rob.set_width(GetDefaultObjectWidth(4));
71 rob.set_height(3.0);
72
73 Point relative_pos_sl;
74
75 // TODO(QiL): load the radar configs here
76 relative_pos_sl.set_x(contiobs.longitude_dist());
77 relative_pos_sl.set_y(contiobs.lateral_dist());
78 rob.mutable_relative_position()->CopyFrom(relative_pos_sl);
79
80 Point relative_pos_xy = SLtoXY(relative_pos_sl, adc_theta);
81 Point absolute_pos;
82 absolute_pos.set_x(adc_pos.x() + relative_pos_xy.x());
83 absolute_pos.set_y(adc_pos.y() + relative_pos_xy.y());
84 absolute_pos.set_z(adc_pos.z());
85 rob.mutable_absolute_position()->CopyFrom(absolute_pos);
86
87 rob.mutable_relative_velocity()->set_x(contiobs.longitude_vel());
88 rob.mutable_relative_velocity()->set_y(contiobs.lateral_vel());
89
90 const auto iter = last_radar_obstacles.radar_obstacle().find(index);
91 Point absolute_vel;
92 if (iter == last_radar_obstacles.radar_obstacle().end()) {
93 rob.set_count(0);
94 rob.set_movable(false);
95 rob.set_moving_frames_count(0);
96 absolute_vel.set_x(0.0);
97 absolute_vel.set_y(0.0);
98 absolute_vel.set_z(0.0);
99 } else if (!FLAGS_use_navigation_mode) {
100 rob.set_count(iter->second.count() + 1);
101 rob.set_movable(iter->second.movable());
102 absolute_vel.set_x(
103 (absolute_pos.x() - iter->second.absolute_position().x()) /
104 (current_timestamp - last_timestamp));
105 absolute_vel.set_y(
106 (absolute_pos.y() - iter->second.absolute_position().y()) /
107 (current_timestamp - last_timestamp));
108 absolute_vel.set_z(0.0);
109 double v_heading = std::atan2(absolute_vel.y(), absolute_vel.x());
110 double heading_diff = HeadingDifference(v_heading, rob.theta());
111 if (heading_diff < FLAGS_movable_heading_threshold &&
112 Speed(absolute_vel) * std::cos(heading_diff) >
113 FLAGS_movable_speed_threshold) {
114 rob.set_moving_frames_count(iter->second.moving_frames_count() + 1);
115 } else {
116 rob.set_moving_frames_count(0);
117 }
118 } else {
119 rob.set_count(iter->second.count() + 1);
120 rob.set_movable(iter->second.movable());
121 absolute_vel.set_x(contiobs.longitude_vel() + chassis.speed_mps());
122 absolute_vel.set_y(contiobs.lateral_vel());
123 absolute_vel.set_z(0.0);
124
125 // Overwrite heading here with relative headings
126 // TODO(QiL) : refind the logic here.
127 if (contiobs.clusterortrack() == 0) {
128 rob.set_theta(contiobs.oritation_angle() / 180 * M_PI);
129 } else {
130 // in FLU
131 rob.set_theta(std::atan2(rob.relative_position().x(),
132 rob.relative_position().y()));
133 }
134 }
135
136 rob.mutable_absolute_velocity()->CopyFrom(absolute_vel);
137
138 if (rob.moving_frames_count() >= FLAGS_movable_frames_count_threshold) {
139 rob.set_movable(true);
140 }
141 (*obstacles.mutable_radar_obstacle())[index] = rob;
142 }
143
144 obstacles.mutable_header()->CopyFrom(conti_radar.header());
145 return obstacles;
146}
double GetDefaultObjectLength(const int object_type)
double GetAngleFromQuaternion(const Quaternion quaternion)
Point SLtoXY(const Point &point, const double theta)
double HeadingDifference(const double theta1, const double theta2)
double GetDefaultObjectWidth(const int object_type)
optional float speed_mps
Definition chassis.proto:70
optional double timestamp_sec
Definition header.proto:9
optional apollo::common::Header header
repeated ContiRadarObs contiobs
optional apollo::localization::Pose pose
optional apollo::common::Point3D linear_velocity
Definition pose.proto:35
optional apollo::common::Quaternion orientation
Definition pose.proto:31
optional apollo::common::PointENU position
Definition pose.proto:26
optional apollo::common::Point3D relative_position

◆ DelphiToRadarObstacles()

RadarObstacles apollo::third_party_perception::conversion_radar::DelphiToRadarObstacles ( const DelphiESR delphi_esr,
const LocalizationEstimate localization,
const RadarObstacles last_radar_obstacles 
)

在文件 conversion_radar.cc148 行定义.

150 {
151 RadarObstacles obstacles;
152
153 const double last_timestamp = last_radar_obstacles.header().timestamp_sec();
154 const double current_timestamp = delphi_esr.header().timestamp_sec();
155
156 // assign motion power from 540
157 std::vector<apollo::drivers::Esr_trackmotionpower_540::Motionpower>
158 motionpowers(64);
159 for (const auto& esr_trackmotionpower_540 :
160 delphi_esr.esr_trackmotionpower_540()) {
161 if (!esr_trackmotionpower_540.has_can_tx_track_can_id_group()) {
162 AERROR << "ESR track motion power 540 does not have "
163 "can_tx_track_can_id_group()";
164 continue;
165 }
166 const int can_tx_track_can_id_group =
167 esr_trackmotionpower_540.can_tx_track_can_id_group();
168 const int can_tx_track_motion_power_size =
169 esr_trackmotionpower_540.can_tx_track_motion_power_size();
170 for (int index = 0; index < (can_tx_track_can_id_group < 9 ? 7 : 1) &&
171 index < can_tx_track_motion_power_size;
172 ++index) {
173 std::size_t motion_powers_index = can_tx_track_can_id_group * 7 + index;
174 if (motion_powers_index < motionpowers.size()) {
175 motionpowers[motion_powers_index].CopyFrom(
176 esr_trackmotionpower_540.can_tx_track_motion_power(index));
177 }
178 }
179 }
180
181 const auto adc_pos = localization.pose().position();
182 const auto adc_vel = localization.pose().linear_velocity();
183 const auto adc_quaternion = localization.pose().orientation();
184 const double adc_theta = GetAngleFromQuaternion(adc_quaternion);
185
186 for (int index = 0; index < delphi_esr.esr_track01_500_size() &&
187 index < static_cast<int>(motionpowers.size());
188 ++index) {
189 const auto& data_500 = delphi_esr.esr_track01_500(index);
190
191 // ignore invalid target
192 if (data_500.can_tx_track_status() ==
194 continue;
195 }
196
197 RadarObstacle rob;
198
199 rob.set_id(index);
200 rob.set_rcs(static_cast<double>(motionpowers[index].can_tx_track_power()) -
201 10.0);
202 rob.set_length(GetDefaultObjectLength(4));
203 rob.set_width(GetDefaultObjectWidth(4));
204 rob.set_height(3.0);
205
206 const double range = data_500.can_tx_track_range();
207 const double angle = data_500.can_tx_track_angle() * M_PI / 180.0;
208 Point relative_pos_sl;
209 relative_pos_sl.set_x(range * std::cos(angle) +
210 FLAGS_radar_pos_adjust + // offset: imu <-> mobileye
211 rob.length() /
212 2.0); // make x the middle point of the vehicle
213 relative_pos_sl.set_y(range * std::sin(angle));
214 rob.mutable_relative_position()->CopyFrom(relative_pos_sl);
215
216 Point relative_pos_xy = SLtoXY(relative_pos_sl, adc_theta);
217 Point absolute_pos;
218 absolute_pos.set_x(adc_pos.x() + relative_pos_xy.x());
219 absolute_pos.set_y(adc_pos.y() + relative_pos_xy.y());
220 absolute_pos.set_z(adc_pos.z());
221 rob.mutable_absolute_position()->CopyFrom(absolute_pos);
222
223 double theta = GetNearestLaneHeading(rob.absolute_position());
224 rob.set_theta(theta);
225
226 const double range_vel = data_500.can_tx_track_range_rate();
227 const double lateral_vel = data_500.can_tx_track_lat_rate();
228 rob.mutable_relative_velocity()->set_x(range_vel * std::cos(angle) -
229 lateral_vel * std::sin(angle));
230 rob.mutable_relative_velocity()->set_y(range_vel * std::sin(angle) +
231 lateral_vel * std::cos(angle));
232
233 const auto iter = last_radar_obstacles.radar_obstacle().find(index);
234 Point absolute_vel;
235 if (iter == last_radar_obstacles.radar_obstacle().end()) {
236 rob.set_count(0);
237 rob.set_movable(false);
238 rob.set_moving_frames_count(0);
239 absolute_vel.set_x(0.0);
240 absolute_vel.set_y(0.0);
241 absolute_vel.set_z(0.0);
242 } else {
243 rob.set_count(iter->second.count() + 1);
244 rob.set_movable(iter->second.movable());
245 absolute_vel.set_x(
246 (absolute_pos.x() - iter->second.absolute_position().x()) /
247 (current_timestamp - last_timestamp));
248 absolute_vel.set_y(
249 (absolute_pos.y() - iter->second.absolute_position().y()) /
250 (current_timestamp - last_timestamp));
251 absolute_vel.set_z(0.0);
252 double v_heading = std::atan2(absolute_vel.y(), absolute_vel.x());
253 double heading_diff = HeadingDifference(v_heading, rob.theta());
254 if (heading_diff < FLAGS_movable_heading_threshold &&
255 Speed(absolute_vel) * std::cos(heading_diff) >
256 FLAGS_movable_speed_threshold) {
257 rob.set_moving_frames_count(iter->second.moving_frames_count() + 1);
258 } else {
259 rob.set_moving_frames_count(0);
260 }
261 }
262
263 rob.mutable_absolute_velocity()->CopyFrom(absolute_vel);
264
265 if (rob.moving_frames_count() >= FLAGS_movable_frames_count_threshold) {
266 rob.set_movable(true);
267 }
268 (*obstacles.mutable_radar_obstacle())[index] = rob;
269 }
270
271 obstacles.mutable_header()->CopyFrom(delphi_esr.header());
272 return obstacles;
273}
#define AERROR
Definition log.h:44
apollo::common::Point3D Point
double GetNearestLaneHeading(const PointENU &point_enu)
optional apollo::common::Header header
repeated Esr_track01_500 esr_track01_500

◆ RadarObstaclesToPerceptionObstacles()

apollo::perception::PerceptionObstacles apollo::third_party_perception::conversion_radar::RadarObstaclesToPerceptionObstacles ( const RadarObstacles radar_obstacles)

在文件 conversion_radar.cc275 行定义.

276 {
277 PerceptionObstacles obstacles;
278
279 for (const auto& iter : radar_obstacles.radar_obstacle()) {
280 auto* pob = obstacles.add_perception_obstacle();
281 const auto& radar_obstacle = iter.second;
282
283 pob->set_id(radar_obstacle.id() + FLAGS_radar_id_offset);
284
285 pob->set_type(PerceptionObstacle::VEHICLE);
286 pob->set_length(radar_obstacle.length());
287 pob->set_width(radar_obstacle.width());
288 pob->set_height(radar_obstacle.height());
289
290 if (!FLAGS_use_navigation_mode) {
291 pob->mutable_position()->CopyFrom(radar_obstacle.absolute_position());
292 pob->mutable_velocity()->CopyFrom(radar_obstacle.absolute_velocity());
293 } else {
294 pob->mutable_position()->CopyFrom(radar_obstacle.relative_position());
295 pob->mutable_velocity()->CopyFrom(radar_obstacle.relative_velocity());
296 }
297
298 pob->set_theta(radar_obstacle.theta());
299
300 // create polygon
301 FillPerceptionPolygon(pob, pob->position().x(), pob->position().y(),
302 pob->position().z(), pob->length(), pob->width(),
303 pob->height(), pob->theta());
304 pob->set_confidence(0.01);
305 }
306
307 obstacles.mutable_header()->CopyFrom(radar_obstacles.header());
308
309 return obstacles;
310}