@@ -525,7 +525,8 @@ bool isMergingToEgoLane(const ObjectData & object)
525
525
}
526
526
527
527
bool isParkedVehicle (
528
- ObjectData & object, const std::shared_ptr<RouteHandler> & route_handler,
528
+ ObjectData & object, const AvoidancePlanningData & data,
529
+ const std::shared_ptr<RouteHandler> & route_handler,
529
530
const std::shared_ptr<AvoidanceParameters> & parameters)
530
531
{
531
532
using lanelet::geometry::distance2d;
@@ -622,57 +623,36 @@ bool isParkedVehicle(
622
623
object.shiftable_ratio > parameters->object_check_shiftable_ratio ;
623
624
}
624
625
625
- return is_left_side_parked_vehicle || is_right_side_parked_vehicle;
626
- }
627
-
628
- bool isAmbiguousStoppedVehicle (
629
- ObjectData & object, const AvoidancePlanningData & data,
630
- const std::shared_ptr<const PlannerData> & planner_data,
631
- const std::shared_ptr<AvoidanceParameters> & parameters)
632
- {
633
- const auto stop_time_longer_than_threshold =
634
- object.stop_time > parameters->threshold_time_force_avoidance_for_stopped_vehicle ;
635
-
636
- if (!stop_time_longer_than_threshold) {
626
+ if (!is_left_side_parked_vehicle && !is_right_side_parked_vehicle) {
637
627
return false ;
638
628
}
639
629
640
630
const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
641
- const auto is_moving_distance_longer_than_threshold =
642
- tier4_autoware_utils::calcDistance2d (object.init_pose , object_pose) >
643
- parameters->force_avoidance_distance_threshold ;
644
-
645
- if (is_moving_distance_longer_than_threshold) {
646
- return false ;
647
- }
648
-
649
- if (object.is_within_intersection ) {
650
- RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is in the intersection area." );
651
- return false ;
652
- }
653
-
654
- const auto rh = planner_data->route_handler ;
655
-
656
- if (
657
- !!rh->getRoutingGraphPtr ()->right (object.overhang_lanelet ) &&
658
- !!rh->getRoutingGraphPtr ()->left (object.overhang_lanelet )) {
659
- RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object isn't on the edge lane." );
631
+ object.to_centerline =
632
+ lanelet::utils::getArcCoordinates (data.current_lanelets , object_pose).distance ;
633
+ if (std::abs (object.to_centerline ) < parameters->threshold_distance_object_is_on_center ) {
660
634
return false ;
661
635
}
662
636
663
- if (!object.is_on_ego_lane ) {
664
- return true ;
665
- }
637
+ return true ;
638
+ }
666
639
640
+ bool isCloseToStopFactor (
641
+ ObjectData & object, const AvoidancePlanningData & data,
642
+ const std::shared_ptr<const PlannerData> & planner_data,
643
+ const std::shared_ptr<AvoidanceParameters> & parameters)
644
+ {
645
+ const auto & rh = planner_data->route_handler ;
667
646
const auto & ego_pose = planner_data->self_odometry ->pose .pose ;
647
+ const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
668
648
669
649
// force avoidance for stopped vehicle
670
- bool not_parked_object = true ;
650
+ bool is_close_to_stop_factor = false ;
671
651
672
652
// check traffic light
673
653
const auto to_traffic_light = getDistanceToNextTrafficLight (object_pose, data.extend_lanelets );
674
654
{
675
- not_parked_object =
655
+ is_close_to_stop_factor =
676
656
to_traffic_light < parameters->object_ignore_section_traffic_light_in_front_distance ;
677
657
}
678
658
@@ -684,12 +664,89 @@ bool isAmbiguousStoppedVehicle(
684
664
const auto stop_for_crosswalk =
685
665
to_crosswalk < parameters->object_ignore_section_crosswalk_in_front_distance &&
686
666
to_crosswalk > -1.0 * parameters->object_ignore_section_crosswalk_behind_distance ;
687
- not_parked_object = not_parked_object || stop_for_crosswalk;
667
+ is_close_to_stop_factor = is_close_to_stop_factor || stop_for_crosswalk;
688
668
}
689
669
690
670
object.to_stop_factor_distance = std::min (to_traffic_light, to_crosswalk);
691
671
692
- return !not_parked_object;
672
+ return is_close_to_stop_factor;
673
+ }
674
+
675
+ bool isNeverAvoidanceTarget (
676
+ ObjectData & object, const AvoidancePlanningData & data,
677
+ const std::shared_ptr<const PlannerData> & planner_data,
678
+ const std::shared_ptr<AvoidanceParameters> & parameters)
679
+ {
680
+ const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
681
+ const auto is_moving_distance_longer_than_threshold =
682
+ tier4_autoware_utils::calcDistance2d (object.init_pose , object_pose) >
683
+ parameters->force_avoidance_distance_threshold ;
684
+ if (is_moving_distance_longer_than_threshold) {
685
+ object.reason = AvoidanceDebugFactor::MOVING_OBJECT;
686
+ return true ;
687
+ }
688
+
689
+ if (object.is_within_intersection ) {
690
+ if (object.behavior == ObjectData::Behavior::NONE) {
691
+ object.reason = " ParallelToEgoLane" ;
692
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object belongs to ego lane. never avoid it." );
693
+ return true ;
694
+ }
695
+
696
+ if (object.behavior == ObjectData::Behavior::MERGING) {
697
+ object.reason = " MergingToEgoLane" ;
698
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object belongs to ego lane. never avoid it." );
699
+ return true ;
700
+ }
701
+ }
702
+
703
+ if (object.is_on_ego_lane ) {
704
+ if (
705
+ !!planner_data->route_handler ->getRoutingGraphPtr ()->right (object.overhang_lanelet ) &&
706
+ !!planner_data->route_handler ->getRoutingGraphPtr ()->left (object.overhang_lanelet )) {
707
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
708
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object isn't on the edge lane. never avoid it." );
709
+ return true ;
710
+ }
711
+ }
712
+
713
+ if (isCloseToStopFactor (object, data, planner_data, parameters)) {
714
+ if (object.is_on_ego_lane && !object.is_parked ) {
715
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
716
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is close to stop factor. never avoid it." );
717
+ return true ;
718
+ }
719
+ }
720
+
721
+ return false ;
722
+ }
723
+
724
+ bool isObviousAvoidanceTarget (
725
+ ObjectData & object, [[maybe_unused]] const AvoidancePlanningData & data,
726
+ [[maybe_unused]] const std::shared_ptr<const PlannerData> & planner_data,
727
+ [[maybe_unused]] const std::shared_ptr<AvoidanceParameters> & parameters)
728
+ {
729
+ if (!object.is_within_intersection ) {
730
+ if (object.is_parked && object.behavior == ObjectData::Behavior::NONE) {
731
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is obvious parked vehicle." );
732
+ return true ;
733
+ }
734
+
735
+ if (!object.is_on_ego_lane && object.behavior == ObjectData::Behavior::NONE) {
736
+ RCLCPP_DEBUG (rclcpp::get_logger (__func__), " object is adjacent vehicle." );
737
+ return true ;
738
+ }
739
+ }
740
+
741
+ if (!object.is_parked ) {
742
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
743
+ }
744
+
745
+ if (object.behavior == ObjectData::Behavior::MERGING) {
746
+ object.reason = " MergingToEgoLane" ;
747
+ }
748
+
749
+ return false ;
693
750
}
694
751
695
752
bool isSatisfiedWithCommonCondition (
@@ -792,45 +849,53 @@ bool isSatisfiedWithVehicleCondition(
792
849
{
793
850
object.behavior = getObjectBehavior (object, parameters);
794
851
object.is_on_ego_lane = isOnEgoLane (object);
795
- object.is_ambiguous = isAmbiguousStoppedVehicle (object, data, planner_data, parameters);
796
852
797
- // from here condition check for vehicle type objects.
798
- if (object.is_ambiguous && parameters->enable_force_avoidance_for_stopped_vehicle ) {
853
+ if (isNeverAvoidanceTarget (object, data, planner_data, parameters)) {
854
+ return false ;
855
+ }
856
+
857
+ if (isObviousAvoidanceTarget (object, data, planner_data, parameters)) {
799
858
return true ;
800
859
}
801
860
802
- // check vehicle shift ratio
803
- if (object.is_on_ego_lane ) {
804
- if (object.is_parked ) {
805
- return true ;
806
- } else {
807
- object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
808
- return false ;
809
- }
861
+ // from here, filtering for ambiguous vehicle.
862
+
863
+ if (!parameters->enable_force_avoidance_for_stopped_vehicle ) {
864
+ object.reason = " AmbiguousStoppedVehicle" ;
865
+ return false ;
810
866
}
811
867
812
- // Object is on center line -> ignore.
813
- const auto & object_pose = object.object .kinematics .initial_pose_with_covariance .pose ;
814
- object.to_centerline =
815
- lanelet::utils::getArcCoordinates (data.current_lanelets , object_pose).distance ;
816
- if (std::abs (object.to_centerline ) < parameters->threshold_distance_object_is_on_center ) {
817
- object.reason = AvoidanceDebugFactor::TOO_NEAR_TO_CENTERLINE;
868
+ const auto stop_time_longer_than_threshold =
869
+ object.stop_time > parameters->threshold_time_force_avoidance_for_stopped_vehicle ;
870
+ if (!stop_time_longer_than_threshold) {
871
+ object.reason = " AmbiguousStoppedVehicle(wait-and-see)" ;
818
872
return false ;
819
873
}
820
874
821
875
if (object.is_within_intersection ) {
822
- if (object.behavior == ObjectData::Behavior::NONE) {
823
- object.reason = " ParallelToEgoLane" ;
824
- return false ;
876
+ if (object.behavior == ObjectData::Behavior::DEVIATING) {
877
+ object.is_ambiguous = true ;
878
+ return true ;
879
+ }
880
+ } else {
881
+ if (object.behavior == ObjectData::Behavior::MERGING) {
882
+ object.is_ambiguous = true ;
883
+ return true ;
825
884
}
826
- }
827
885
828
- if (object.behavior == ObjectData::Behavior::MERGING) {
829
- object.reason = " MergingToEgoLane" ;
830
- return false ;
886
+ if (object.behavior == ObjectData::Behavior::DEVIATING) {
887
+ object.is_ambiguous = true ;
888
+ return true ;
889
+ }
890
+
891
+ if (object.behavior == ObjectData::Behavior::NONE) {
892
+ object.is_ambiguous = false ;
893
+ return true ;
894
+ }
831
895
}
832
896
833
- return true ;
897
+ object.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
898
+ return false ;
834
899
}
835
900
836
901
bool isNoNeedAvoidanceBehavior (
@@ -1757,7 +1822,8 @@ void filterTargetObjects(
1757
1822
if (filtering_utils::isVehicleTypeObject (o)) {
1758
1823
o.is_within_intersection =
1759
1824
filtering_utils::isWithinIntersection (o, planner_data->route_handler );
1760
- o.is_parked = filtering_utils::isParkedVehicle (o, planner_data->route_handler , parameters);
1825
+ o.is_parked =
1826
+ filtering_utils::isParkedVehicle (o, data, planner_data->route_handler , parameters);
1761
1827
o.avoid_margin = filtering_utils::getAvoidMargin (o, planner_data, parameters);
1762
1828
1763
1829
if (filtering_utils::isNoNeedAvoidanceBehavior (o, parameters)) {
0 commit comments