|
26 | 26 |
|
27 | 27 | namespace behavior_velocity_planner::dynamic_obstacle_stop
|
28 | 28 | {
|
29 |
| - |
30 | 29 | std::optional<geometry_msgs::msg::Point> find_closest_collision_point(
|
31 |
| - const EgoData & ego_data, const geometry_msgs::msg::Pose & object_pose, |
32 |
| - const tier4_autoware_utils::Polygon2d & object_footprint, const PlannerParam & params) |
| 30 | + const EgoData & ego_data, const autoware_auto_perception_msgs::msg::PredictedObject & object, |
| 31 | + const tier4_autoware_utils::MultiPolygon2d & object_footprints, const PlannerParam & params) |
33 | 32 | {
|
34 | 33 | std::optional<geometry_msgs::msg::Point> closest_collision_point;
|
35 | 34 | auto closest_dist = std::numeric_limits<double>::max();
|
36 | 35 | std::vector<BoxIndexPair> rough_collisions;
|
37 |
| - ego_data.rtree.query( |
38 |
| - boost::geometry::index::intersects(object_footprint), std::back_inserter(rough_collisions)); |
39 |
| - for (const auto & rough_collision : rough_collisions) { |
40 |
| - const auto path_idx = rough_collision.second; |
41 |
| - const auto & ego_footprint = ego_data.path_footprints[path_idx]; |
42 |
| - const auto & ego_pose = ego_data.path.points[path_idx].point.pose; |
43 |
| - const auto angle_diff = tier4_autoware_utils::normalizeRadian( |
44 |
| - tf2::getYaw(ego_pose.orientation) - tf2::getYaw(object_pose.orientation)); |
45 |
| - if ( |
46 |
| - (!params.ignore_objects_behind_ego && |
47 |
| - std::abs(angle_diff) < params.yaw_threshold_behind_object) || |
48 |
| - std::abs(angle_diff) > params.yaw_threshold) { |
49 |
| - tier4_autoware_utils::MultiPoint2d collision_points; |
50 |
| - boost::geometry::intersection( |
51 |
| - object_footprint.outer(), ego_footprint.outer(), collision_points); |
52 |
| - for (const auto & coll_p : collision_points) { |
53 |
| - auto p = geometry_msgs::msg::Point().set__x(coll_p.x()).set__y(coll_p.y()); |
54 |
| - const auto dist_to_ego = |
55 |
| - motion_utils::calcSignedArcLength(ego_data.path.points, ego_data.pose.position, p); |
56 |
| - if (dist_to_ego < closest_dist) { |
57 |
| - closest_dist = dist_to_ego; |
58 |
| - closest_collision_point = p; |
| 36 | + for (const auto & object_footprint : object_footprints) { |
| 37 | + ego_data.rtree.query( |
| 38 | + boost::geometry::index::intersects(object_footprint), std::back_inserter(rough_collisions)); |
| 39 | + for (const auto & rough_collision : rough_collisions) { |
| 40 | + const auto path_idx = rough_collision.second; |
| 41 | + const auto & ego_footprint = ego_data.path_footprints[path_idx]; |
| 42 | + const auto & ego_pose = ego_data.path.points[path_idx].point.pose; |
| 43 | + const auto & object_pose = object.kinematics.initial_pose_with_covariance.pose; |
| 44 | + const auto angle_diff = tier4_autoware_utils::normalizeRadian( |
| 45 | + tf2::getYaw(ego_pose.orientation) - tf2::getYaw(object_pose.orientation)); |
| 46 | + if ( |
| 47 | + (!params.ignore_objects_behind_ego && |
| 48 | + std::abs(angle_diff) < params.yaw_threshold_behind_object) || |
| 49 | + std::abs(angle_diff) > params.yaw_threshold) { |
| 50 | + tier4_autoware_utils::MultiPoint2d collision_points; |
| 51 | + boost::geometry::intersection(object_footprints, ego_footprint.outer(), collision_points); |
| 52 | + for (const auto & coll_p : collision_points) { |
| 53 | + auto p = geometry_msgs::msg::Point().set__x(coll_p.x()).set__y(coll_p.y()); |
| 54 | + const auto dist_ego_to_coll = |
| 55 | + motion_utils::calcSignedArcLength(ego_data.path.points, ego_pose.position, p); |
| 56 | + const auto dist_obj_to_coll = |
| 57 | + motion_utils::calcSignedArcLength(ego_data.path.points, object_pose.position, p); |
| 58 | + const auto tta_cp_npc = |
| 59 | + abs(dist_obj_to_coll) / object.kinematics.initial_twist_with_covariance.twist.linear.x; |
| 60 | + const auto tta_cp_ego = |
| 61 | + dist_ego_to_coll / ego_data.path.points[path_idx].point.longitudinal_velocity_mps; |
| 62 | + if (abs(dist_ego_to_coll) < closest_dist && std::abs(tta_cp_npc - tta_cp_ego) < params.time_horizon) { |
| 63 | + closest_dist = dist_ego_to_coll; |
| 64 | + closest_collision_point = p; |
| 65 | + } |
59 | 66 | }
|
60 | 67 | }
|
61 | 68 | }
|
|
0 commit comments