247 {
248 static auto planning_reader =
251 const auto trajectory = planning_reader->GetLatestObserved();
252 if (trajectory == nullptr || trajectory->trajectory_point().empty()) {
253 AERROR <<
"Planning trajectory not ready.";
254 return;
255 }
256
257 GetOverlaps(*trajectory);
258
259
260 if (!clear_area_id_.empty() && clear_area_distance_ >= 0) {
261 if (!stories->has_close_to_clear_area()) {
262 AINFO <<
"Enter CloseToClearArea story";
263 }
264 auto* story = stories->mutable_close_to_clear_area();
265 story->set_id(clear_area_id_);
266 story->set_distance(clear_area_distance_);
267 } else if (stories->has_close_to_clear_area()) {
268 AINFO <<
"Exit CloseToClearArea story";
269 stories->clear_close_to_clear_area();
270 }
271
272
273 if (!crosswalk_id_.empty() && crosswalk_distance_ >= 0) {
274 if (!stories->has_close_to_crosswalk()) {
275 AINFO <<
"Enter CloseToCrosswalk story";
276 }
277 auto* story = stories->mutable_close_to_crosswalk();
278 story->set_id(crosswalk_id_);
279 story->set_distance(crosswalk_distance_);
280 } else if (stories->has_close_to_crosswalk()) {
281 AINFO <<
"Exit CloseToCrosswalk story";
282 stories->clear_close_to_crosswalk();
283 }
284
285
286 if ((!junction_id_.empty() && junction_distance_ >= 0) ||
287 (!pnc_junction_id_.empty() && pnc_junction_distance_ >= 0)) {
288 if (!stories->has_close_to_junction()) {
289 AINFO <<
"Enter CloseToJunction story";
290 }
291 auto* story = stories->mutable_close_to_junction();
292 if (!pnc_junction_id_.empty() && pnc_junction_distance_ >= 0) {
293 story->set_id(pnc_junction_id_);
295 story->set_distance(pnc_junction_distance_);
296 } else {
297 story->set_id(junction_id_);
299 story->set_distance(junction_distance_);
300 }
301 } else if (stories->has_close_to_junction()) {
302 AINFO <<
"Exit CloseToJunction story";
303 stories->clear_close_to_junction();
304 }
305
306
307 if (!signal_id_.empty() && signal_distance_ >= 0) {
308 if (!stories->has_close_to_signal()) {
309 AINFO <<
"Enter CloseToSignal story";
310 }
311 auto* story = stories->mutable_close_to_signal();
312 story->set_id(signal_id_);
313 story->set_distance(signal_distance_);
314 } else if (stories->has_close_to_signal()) {
315 AINFO <<
"Exit CloseToSignal story";
316 stories->clear_close_to_signal();
317 }
318
319
320 if (!stop_sign_id_.empty() && stop_sign_distance_ >= 0) {
321 if (!stories->has_close_to_stop_sign()) {
322 AINFO <<
"Enter CloseToStopSign story";
323 }
324 auto* story = stories->mutable_close_to_stop_sign();
325 story->set_id(stop_sign_id_);
326 story->set_distance(stop_sign_distance_);
327 } else if (stories->has_close_to_stop_sign()) {
328 AINFO <<
"Exit CloseToStopSign story";
329 stories->clear_close_to_stop_sign();
330 }
331
332
333 if (!yield_sign_id_.empty() && yield_sign_distance_ >= 0) {
334 if (!stories->has_close_to_yield_sign()) {
335 AINFO <<
"Enter CloseToYieldSign story";
336 }
337 auto* story = stories->mutable_close_to_yield_sign();
338 story->set_id(yield_sign_id_);
339 story->set_distance(yield_sign_distance_);
340 } else if (stories->has_close_to_yield_sign()) {
341 AINFO <<
"Exit CloseToYieldSign story";
342 stories->clear_close_to_yield_sign();
343 }
344}