@@ -65,25 +65,27 @@ std::vector<autoware_auto_perception_msgs::msg::PredictedObject> filter_predicte
65
65
const auto ego_yaw = tf2::getYaw (ego_data.pose .orientation );
66
66
const auto yaw_diff = std::abs (tier4_autoware_utils::normalizeRadian (o_yaw - ego_yaw));
67
67
const auto opposite_heading = yaw_diff > M_PI_2 + M_PI_4;
68
- auto distance = std::abs (
69
- (o_pose.position .y - ego_data.pose .position .y ) * std::cos (o_yaw) -
70
- (o_pose.position .x - ego_data.pose .position .x ) * std::sin (o_yaw));
68
+ const auto collision_distance_threshold =
69
+ params.ego_lateral_offset + o.shape .dimensions .y / 2.0 + params.hysteresis ;
70
+ auto has_collision = std::abs (
71
+ (o_pose.position .y - ego_data.pose .position .y ) * std::cos (o_yaw) -
72
+ (o_pose.position .x - ego_data.pose .position .x ) * std::sin (o_yaw)) <=
73
+ collision_distance_threshold;
71
74
if (ego_data.earliest_stop_pose ) {
72
- distance = std::min (
73
- distance,
75
+ const auto collision_at_earliest_stop_pose =
74
76
std::abs (
75
77
(o_pose.position .y - ego_data.earliest_stop_pose ->position .y ) * std::cos (o_yaw) -
76
- (o_pose.position .x - ego_data.earliest_stop_pose ->position .x ) * std::sin (o_yaw)));
78
+ (o_pose.position .x - ego_data.earliest_stop_pose ->position .x ) * std::sin (o_yaw)) <=
79
+ collision_distance_threshold;
80
+ has_collision |= collision_at_earliest_stop_pose;
77
81
}
78
- return opposite_heading &&
79
- distance <= params.ego_lateral_offset + o.shape .dimensions .y / 2.0 + hysteresis;
82
+ return opposite_heading && has_collision;
80
83
};
81
84
for (const auto & object : objects.objects ) {
85
+ const auto is_not_too_slow = object.kinematics .initial_twist_with_covariance .twist .linear .x >=
86
+ params.minimum_object_velocity ;
82
87
if (
83
- is_vehicle (object) &&
84
- object.kinematics .initial_twist_with_covariance .twist .linear .x >=
85
- params.minimum_object_velocity &&
86
- is_in_range (object) && is_not_too_close (object) &&
88
+ is_vehicle (object) && is_not_too_slow && is_in_range (object) && is_not_too_close (object) &&
87
89
(!params.ignore_unavoidable_collisions || !is_unavoidable (object)))
88
90
filtered_objects.push_back (object);
89
91
}
0 commit comments