@@ -399,7 +399,8 @@ bool isMergingToEgoLane(const ObjectData & object)
399
399
}
400
400
401
401
bool isParkedVehicle (
402
- ObjectData & object, const std::shared_ptr<RouteHandler> & route_handler,
402
+ ObjectData & object, const AvoidancePlanningData & data,
403
+ const std::shared_ptr<RouteHandler> & route_handler,
403
404
const std::shared_ptr<AvoidanceParameters> & parameters)
404
405
{
405
406
using lanelet::geometry::distance2d;
@@ -496,57 +497,36 @@ bool isParkedVehicle(
496
497
object.shiftable_ratio > parameters->object_check_shiftable_ratio ;
497
498
}
498
499
499
- return is_left_side_parked_vehicle || is_right_side_parked_vehicle;
500
- }
501
-
502
- bool isAmbiguousStoppedVehicle (
503
- ObjectData & object, const AvoidancePlanningData & data,
504
- const std::shared_ptr<const PlannerData> & planner_data,
505
- const std::shared_ptr<AvoidanceParameters> & parameters)
506
- {
507
- const auto stop_time_longer_than_threshold =
508
- object.stop_time > parameters->threshold_time_force_avoidance_for_stopped_vehicle ;
509
-
510
- if (!stop_time_longer_than_threshold) {
500
+ if (!is_left_side_parked_vehicle && !is_right_side_parked_vehicle) {
511
501
return false ;
512
502
}
513
503
514
504
const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
515
- const auto is_moving_distance_longer_than_threshold =
516
- tier4_autoware_utils::calcDistance2d (object.init_pose , object_pose) >
517
- parameters->force_avoidance_distance_threshold ;
518
-
519
- if (is_moving_distance_longer_than_threshold) {
520
- return false ;
521
- }
522
-
523
- if (object.is_within_intersection ) {
524
- RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is in the intersection area." );
525
- return false ;
526
- }
527
-
528
- const auto rh = planner_data->route_handler ;
529
-
530
- if (
531
- !!rh->getRoutingGraphPtr ()->right (object.overhang_lanelet ) &&
532
- !!rh->getRoutingGraphPtr ()->left (object.overhang_lanelet )) {
533
- RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object isn't on the edge lane." );
505
+ object.to_centerline =
506
+ lanelet::utils::getArcCoordinates (data.current_lanelets , object_pose).distance ;
507
+ if (std::abs (object.to_centerline ) < parameters->threshold_distance_object_is_on_center ) {
534
508
return false ;
535
509
}
536
510
537
- if (!object.is_on_ego_lane ) {
538
- return true ;
539
- }
511
+ return true ;
512
+ }
540
513
514
+ bool isCloseToStopFactor (
515
+ ObjectData & object, const AvoidancePlanningData & data,
516
+ const std::shared_ptr<const PlannerData> & planner_data,
517
+ const std::shared_ptr<AvoidanceParameters> & parameters)
518
+ {
519
+ const auto & rh = planner_data->route_handler ;
541
520
const auto & ego_pose = planner_data->self_odometry ->pose .pose ;
521
+ const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
542
522
543
523
// force avoidance for stopped vehicle
544
- bool not_parked_object = true ;
524
+ bool is_close_to_stop_factor = false ;
545
525
546
526
// check traffic light
547
527
const auto to_traffic_light = getDistanceToNextTrafficLight (object_pose, data.extend_lanelets );
548
528
{
549
- not_parked_object =
529
+ is_close_to_stop_factor =
550
530
to_traffic_light < parameters->object_ignore_section_traffic_light_in_front_distance ;
551
531
}
552
532
@@ -558,12 +538,89 @@ bool isAmbiguousStoppedVehicle(
558
538
const auto stop_for_crosswalk =
559
539
to_crosswalk < parameters->object_ignore_section_crosswalk_in_front_distance &&
560
540
to_crosswalk > -1.0 * parameters->object_ignore_section_crosswalk_behind_distance ;
561
- not_parked_object = not_parked_object || stop_for_crosswalk;
541
+ is_close_to_stop_factor = is_close_to_stop_factor || stop_for_crosswalk;
562
542
}
563
543
564
544
object.to_stop_factor_distance = std::min (to_traffic_light, to_crosswalk);
565
545
566
- return !not_parked_object;
546
+ return is_close_to_stop_factor;
547
+ }
548
+
549
+ bool isNeverAvoidanceTarget (
550
+ ObjectData & object, const AvoidancePlanningData & data,
551
+ const std::shared_ptr<const PlannerData> & planner_data,
552
+ const std::shared_ptr<AvoidanceParameters> & parameters)
553
+ {
554
+ const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
555
+ const auto is_moving_distance_longer_than_threshold =
556
+ tier4_autoware_utils::calcDistance2d (object.init_pose , object_pose) >
557
+ parameters->distance_threshold_for_ambiguous_vehicle ;
558
+ if (is_moving_distance_longer_than_threshold) {
559
+ object.reason = AvoidanceDebugFactor::MOVING_OBJECT;
560
+ return true ;
561
+ }
562
+
563
+ if (object.is_within_intersection ) {
564
+ if (object.behavior == ObjectData::Behavior::NONE) {
565
+ object.reason = " ParallelToEgoLane" ;
566
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object belongs to ego lane. never avoid it." );
567
+ return true ;
568
+ }
569
+
570
+ if (object.behavior == ObjectData::Behavior::MERGING) {
571
+ object.reason = " MergingToEgoLane" ;
572
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object belongs to ego lane. never avoid it." );
573
+ return true ;
574
+ }
575
+ }
576
+
577
+ if (object.is_on_ego_lane ) {
578
+ if (
579
+ planner_data->route_handler ->getRightLanelet (object.overhang_lanelet ).has_value () &&
580
+ planner_data->route_handler ->getLeftLanelet (object.overhang_lanelet ).has_value ()) {
581
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
582
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object isn't on the edge lane. never avoid it." );
583
+ return true ;
584
+ }
585
+ }
586
+
587
+ if (isCloseToStopFactor (object, data, planner_data, parameters)) {
588
+ if (object.is_on_ego_lane && !object.is_parked ) {
589
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
590
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is close to stop factor. never avoid it." );
591
+ return true ;
592
+ }
593
+ }
594
+
595
+ return false ;
596
+ }
597
+
598
+ bool isObviousAvoidanceTarget (
599
+ ObjectData & object, [[maybe_unused]] const AvoidancePlanningData & data,
600
+ [[maybe_unused]] const std::shared_ptr<const PlannerData> & planner_data,
601
+ [[maybe_unused]] const std::shared_ptr<AvoidanceParameters> & parameters)
602
+ {
603
+ if (!object.is_within_intersection ) {
604
+ if (object.is_parked && object.behavior == ObjectData::Behavior::NONE) {
605
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is obvious parked vehicle." );
606
+ return true ;
607
+ }
608
+
609
+ if (!object.is_on_ego_lane && object.behavior == ObjectData::Behavior::NONE) {
610
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is adjacent vehicle." );
611
+ return true ;
612
+ }
613
+ }
614
+
615
+ if (!object.is_parked ) {
616
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
617
+ }
618
+
619
+ if (object.behavior == ObjectData::Behavior::MERGING) {
620
+ object.reason = " MergingToEgoLane" ;
621
+ }
622
+
623
+ return false ;
567
624
}
568
625
569
626
bool isSatisfiedWithCommonCondition (
@@ -666,50 +723,56 @@ bool isSatisfiedWithVehicleCondition(
666
723
{
667
724
object.behavior = getObjectBehavior (object, parameters);
668
725
object.is_on_ego_lane = isOnEgoLane (object);
669
- object.is_ambiguous = isAmbiguousStoppedVehicle (object, data, planner_data, parameters);
670
726
671
- // from here condition check for vehicle type objects.
672
- if (object.is_ambiguous && parameters->enable_force_avoidance_for_stopped_vehicle ) {
727
+ if (isNeverAvoidanceTarget (object, data, planner_data, parameters)) {
728
+ return false ;
729
+ }
730
+
731
+ if (isObviousAvoidanceTarget (object, data, planner_data, parameters)) {
673
732
return true ;
674
733
}
675
734
676
- // check vehicle shift ratio
677
- if (object.is_on_ego_lane ) {
678
- if (object.is_parked ) {
679
- return true ;
680
- } else {
681
- object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
682
- return false ;
683
- }
735
+ // from here, filtering for ambiguous vehicle.
736
+
737
+ if (!parameters->enable_avoidance_for_ambiguous_vehicle ) {
738
+ object.reason = " AmbiguousStoppedVehicle" ;
739
+ return false ;
684
740
}
685
741
686
- // Object is on center line -> ignore.
687
- const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
688
- object.to_centerline =
689
- lanelet::utils::getArcCoordinates (data.current_lanelets , object_pose).distance ;
690
- if (std::abs (object.to_centerline ) < parameters->threshold_distance_object_is_on_center ) {
691
- object.reason = AvoidanceDebugFactor::TOO_NEAR_TO_CENTERLINE;
742
+ const auto stop_time_longer_than_threshold =
743
+ object.stop_time > parameters->time_threshold_for_ambiguous_vehicle ;
744
+ if (!stop_time_longer_than_threshold) {
745
+ object.reason = " AmbiguousStoppedVehicle(wait-and-see)" ;
692
746
return false ;
693
747
}
694
748
695
749
if (object.is_within_intersection ) {
696
- std::string turn_direction = object.overhang_lanelet .attributeOr (" turn_direction" , " else" );
697
- if (turn_direction == " straight" ) {
750
+ if (object.behavior == ObjectData::Behavior::DEVIATING) {
751
+ object.reason = " AmbiguousStoppedVehicle(wait-and-see)" ;
752
+ object.is_ambiguous = true ;
753
+ return true ;
754
+ }
755
+ } else {
756
+ if (object.behavior == ObjectData::Behavior::MERGING) {
757
+ object.reason = " AmbiguousStoppedVehicle(wait-and-see)" ;
758
+ object.is_ambiguous = true ;
698
759
return true ;
699
760
}
700
761
701
- if (object.behavior == ObjectData::Behavior::NONE) {
702
- object.reason = " ParallelToEgoLane" ;
703
- return false ;
762
+ if (object.behavior == ObjectData::Behavior::DEVIATING) {
763
+ object.reason = " AmbiguousStoppedVehicle(wait-and-see)" ;
764
+ object.is_ambiguous = true ;
765
+ return true ;
704
766
}
705
- }
706
767
707
- if (object.behavior == ObjectData::Behavior::MERGING) {
708
- object.reason = " MergingToEgoLane" ;
709
- return false ;
768
+ if (object.behavior == ObjectData::Behavior::NONE) {
769
+ object.is_ambiguous = false ;
770
+ return true ;
771
+ }
710
772
}
711
773
712
- return true ;
774
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
775
+ return false ;
713
776
}
714
777
715
778
bool isNoNeedAvoidanceBehavior (
@@ -1636,7 +1699,8 @@ void filterTargetObjects(
1636
1699
if (filtering_utils::isVehicleTypeObject (o)) {
1637
1700
o.is_within_intersection =
1638
1701
filtering_utils::isWithinIntersection (o, planner_data->route_handler );
1639
- o.is_parked = filtering_utils::isParkedVehicle (o, planner_data->route_handler , parameters);
1702
+ o.is_parked =
1703
+ filtering_utils::isParkedVehicle (o, data, planner_data->route_handler , parameters);
1640
1704
o.avoid_margin = filtering_utils::getAvoidMargin (o, planner_data, parameters);
1641
1705
1642
1706
if (filtering_utils::isNoNeedAvoidanceBehavior (o, parameters)) {
0 commit comments