@@ -318,7 +318,12 @@ AvoidancePlanningData AvoidanceModule::calcAvoidancePlanningData(DebugData & deb
318
318
void AvoidanceModule::fillAvoidanceTargetObjects (
319
319
AvoidancePlanningData & data, DebugData & debug) const
320
320
{
321
- const auto expanded_lanelets = utils::avoidance::getTargetLanelets (
321
+ using utils::avoidance::fillObjectStoppableJudge;
322
+ using utils::avoidance::filterTargetObjects;
323
+ using utils::avoidance::getTargetLanelets;
324
+
325
+ // Separate dynamic objects based on whether they are inside or outside of the expanded lanelets.
326
+ const auto expanded_lanelets = getTargetLanelets (
322
327
planner_data_, data.current_lanelets , parameters_->detection_area_left_expand_dist ,
323
328
parameters_->detection_area_right_expand_dist * (-1.0 ));
324
329
@@ -337,7 +342,18 @@ void AvoidanceModule::fillAvoidanceTargetObjects(
337
342
objects.push_back (createObjectData (data, object));
338
343
}
339
344
340
- utils::avoidance::filterTargetObjects (objects, data, debug, planner_data_, parameters_);
345
+ // Filter out the objects to determine the ones to be avoided.
346
+ filterTargetObjects (objects, data, debug, planner_data_, parameters_);
347
+
348
+ // Calculate the distance needed to safely decelerate the ego vehicle to a stop line.
349
+ // TODO(Satoshi OTA) use helper_ after the manager transition
350
+ helper::avoidance::AvoidanceHelper helper (planner_data_, parameters_);
351
+
352
+ const auto feasible_stop_distance = helper.getFeasibleDecelDistance (0.0 );
353
+ std::for_each (data.target_objects .begin (), data.target_objects .end (), [&, this ](auto & o) {
354
+ o.to_stop_line = calcDistanceToStopLine (o);
355
+ fillObjectStoppableJudge (o, registered_objects_, feasible_stop_distance, parameters_);
356
+ });
341
357
342
358
// debug
343
359
{
@@ -355,9 +371,7 @@ void AvoidanceModule::fillAvoidanceTargetObjects(
355
371
debug_info_array.push_back (debug_info);
356
372
};
357
373
358
- for (const auto & o : objects) {
359
- append (o);
360
- }
374
+ std::for_each (objects.begin (), objects.end (), [&](const auto & o) { append (o); });
361
375
362
376
updateAvoidanceDebugData (debug_info_array);
363
377
}
@@ -516,7 +530,7 @@ void AvoidanceModule::fillEgoStatus(
516
530
if (o.avoid_required && enough_space) {
517
531
data.avoid_required = true ;
518
532
data.stop_target_object = o;
519
- data.to_stop_line = calcDistanceToStopLine (o) ;
533
+ data.to_stop_line = o. to_stop_line ;
520
534
break ;
521
535
}
522
536
}
@@ -660,17 +674,16 @@ void AvoidanceModule::updateEgoBehavior(const AvoidancePlanningData & data, Shif
660
674
break ;
661
675
}
662
676
case AvoidanceState::AVOID_PATH_NOT_READY: {
663
- insertPrepareVelocity (false , path);
677
+ insertPrepareVelocity (path);
664
678
insertWaitPoint (parameters_->use_constraints_for_decel , path);
665
679
break ;
666
680
}
667
681
case AvoidanceState::AVOID_PATH_READY: {
668
- insertPrepareVelocity (true , path);
669
682
insertWaitPoint (parameters_->use_constraints_for_decel , path);
670
683
break ;
671
684
}
672
685
case AvoidanceState::AVOID_EXECUTE: {
673
- insertStopPoint (true , path);
686
+ insertStopPoint (parameters_-> use_constraints_for_decel , path);
674
687
break ;
675
688
}
676
689
default :
@@ -3290,18 +3303,26 @@ void AvoidanceModule::insertWaitPoint(
3290
3303
return ;
3291
3304
}
3292
3305
3306
+ // If we don't need to consider deceleration constraints, insert a deceleration point
3307
+ // and return immediately
3293
3308
if (!use_constraints_for_decel) {
3294
3309
utils::avoidance::insertDecelPoint (
3295
3310
getEgoPosition (), data.to_stop_line , 0.0 , shifted_path.path , stop_pose_);
3296
3311
return ;
3297
3312
}
3298
3313
3299
- const auto stop_distance = helper_.getMildDecelDistance (0.0 );
3300
- if (stop_distance) {
3301
- const auto insert_distance = std::max (data.to_stop_line , *stop_distance);
3314
+ // If target object can be stopped for, insert a deceleration point and return
3315
+ if (data.stop_target_object .get ().is_stoppable ) {
3302
3316
utils::avoidance::insertDecelPoint (
3303
- getEgoPosition (), insert_distance, 0.0 , shifted_path.path , stop_pose_);
3317
+ getEgoPosition (), data.to_stop_line , 0.0 , shifted_path.path , stop_pose_);
3318
+ return ;
3304
3319
}
3320
+
3321
+ // If the object cannot be stopped for, calculate a "mild" deceleration distance
3322
+ // and insert a deceleration point at that distance
3323
+ const auto stop_distance = helper_.getFeasibleDecelDistance (0.0 , false );
3324
+ utils::avoidance::insertDecelPoint (
3325
+ getEgoPosition (), stop_distance, 0.0 , shifted_path.path , stop_pose_);
3305
3326
}
3306
3327
3307
3328
void AvoidanceModule::insertStopPoint (
@@ -3333,19 +3354,16 @@ void AvoidanceModule::insertStopPoint(
3333
3354
const auto stop_distance =
3334
3355
calcSignedArcLength (shifted_path.path .points , getEgoPosition (), stop_idx);
3335
3356
3336
- // Insert deceleration point at stop distance without deceleration if use_constraints_for_decel is
3337
- // false
3357
+ // If we don't need to consider deceleration constraints, insert a deceleration point
3358
+ // and return immediately
3338
3359
if (!use_constraints_for_decel) {
3339
3360
utils::avoidance::insertDecelPoint (
3340
3361
getEgoPosition (), stop_distance, 0.0 , shifted_path.path , stop_pose_);
3341
3362
return ;
3342
3363
}
3343
3364
3344
3365
// Otherwise, consider deceleration constraints before inserting deceleration point
3345
- const auto decel_distance = helper_.getMildDecelDistance (0.0 );
3346
- if (!decel_distance) {
3347
- return ;
3348
- }
3366
+ const auto decel_distance = helper_.getFeasibleDecelDistance (0.0 , false );
3349
3367
if (stop_distance < decel_distance) {
3350
3368
return ;
3351
3369
}
@@ -3368,14 +3386,12 @@ void AvoidanceModule::insertYieldVelocity(ShiftedPath & shifted_path) const
3368
3386
return ;
3369
3387
}
3370
3388
3371
- const auto decel_distance = helper_.getMildDecelDistance (p->yield_velocity );
3372
- if (decel_distance) {
3373
- utils::avoidance::insertDecelPoint (
3374
- getEgoPosition (), *decel_distance, p->yield_velocity , shifted_path.path , slow_pose_);
3375
- }
3389
+ const auto decel_distance = helper_.getFeasibleDecelDistance (p->yield_velocity , false );
3390
+ utils::avoidance::insertDecelPoint (
3391
+ getEgoPosition (), decel_distance, p->yield_velocity , shifted_path.path , slow_pose_);
3376
3392
}
3377
3393
3378
- void AvoidanceModule::insertPrepareVelocity (const bool avoidable, ShiftedPath & shifted_path) const
3394
+ void AvoidanceModule::insertPrepareVelocity (ShiftedPath & shifted_path) const
3379
3395
{
3380
3396
const auto & data = avoidance_data_;
3381
3397
@@ -3393,15 +3409,9 @@ void AvoidanceModule::insertPrepareVelocity(const bool avoidable, ShiftedPath &
3393
3409
return ;
3394
3410
}
3395
3411
3396
- if (avoidable) {
3397
- return ;
3398
- }
3399
-
3400
3412
const auto decel_distance = helper_.getFeasibleDecelDistance (0.0 );
3401
- if (decel_distance) {
3402
- utils::avoidance::insertDecelPoint (
3403
- getEgoPosition (), *decel_distance, 0.0 , shifted_path.path , slow_pose_);
3404
- }
3413
+ utils::avoidance::insertDecelPoint (
3414
+ getEgoPosition (), decel_distance, 0.0 , shifted_path.path , slow_pose_);
3405
3415
}
3406
3416
3407
3417
std::shared_ptr<AvoidanceDebugMsgArray> AvoidanceModule::get_debug_msg_array () const
0 commit comments