|
14 | 14 |
|
15 | 15 | #include "autoware/behavior_path_lane_change_module/utils/utils.hpp"
|
16 | 16 |
|
| 17 | +#include "autoware/behavior_path_lane_change_module/utils/calculation.hpp" |
17 | 18 | #include "autoware/behavior_path_lane_change_module/utils/data_structs.hpp"
|
18 | 19 | #include "autoware/behavior_path_lane_change_module/utils/path.hpp"
|
19 | 20 | #include "autoware/behavior_path_planner_common/marker_utils/utils.hpp"
|
@@ -988,30 +989,41 @@ bool passed_parked_objects(
|
988 | 989 | }
|
989 | 990 |
|
990 | 991 | const auto & current_path_end = current_lane_path.points.back().point.pose.position;
|
991 |
| - double min_dist_to_end_of_current_lane = std::numeric_limits<double>::max(); |
992 |
| - const auto & target_lanes = common_data_ptr->lanes_ptr->target; |
993 |
| - const auto is_goal_in_route = route_handler.isInGoalRouteSection(target_lanes.back()); |
994 |
| - for (const auto & point : leading_obj_poly.outer()) { |
995 |
| - const auto obj_p = autoware::universe_utils::createPoint(point.x(), point.y(), 0.0); |
996 |
| - const double dist = autoware::motion_utils::calcSignedArcLength( |
997 |
| - current_lane_path.points, obj_p, current_path_end); |
998 |
| - min_dist_to_end_of_current_lane = std::min(dist, min_dist_to_end_of_current_lane); |
999 |
| - if (is_goal_in_route) { |
| 992 | + const auto dist_to_path_end = [&](const auto & src_point) { |
| 993 | + if (common_data_ptr->lanes_ptr->current_lane_in_goal_section) { |
1000 | 994 | const auto goal_pose = route_handler.getGoalPose();
|
1001 |
| - const double dist_to_goal = autoware::motion_utils::calcSignedArcLength( |
1002 |
| - current_lane_path.points, obj_p, goal_pose.position); |
1003 |
| - min_dist_to_end_of_current_lane = std::min(min_dist_to_end_of_current_lane, dist_to_goal); |
| 995 | + return motion_utils::calcSignedArcLength( |
| 996 | + current_lane_path.points, src_point, goal_pose.position); |
1004 | 997 | }
|
1005 |
| - } |
| 998 | + return motion_utils::calcSignedArcLength(current_lane_path.points, src_point, current_path_end); |
| 999 | + }; |
| 1000 | + |
| 1001 | + const auto min_dist_to_end_of_current_lane = std::invoke([&]() { |
| 1002 | + auto min_dist_to_end_of_current_lane = std::numeric_limits<double>::max(); |
| 1003 | + for (const auto & point : leading_obj_poly.outer()) { |
| 1004 | + const auto obj_p = universe_utils::createPoint(point.x(), point.y(), 0.0); |
| 1005 | + const auto dist = dist_to_path_end(obj_p); |
| 1006 | + min_dist_to_end_of_current_lane = std::min(dist, min_dist_to_end_of_current_lane); |
| 1007 | + } |
| 1008 | + return min_dist_to_end_of_current_lane; |
| 1009 | + }); |
1006 | 1010 |
|
1007 | 1011 | // If there are still enough length after the target object, we delay the lane change
|
1008 |
| - if (min_dist_to_end_of_current_lane > minimum_lane_change_length) { |
1009 |
| - debug.second.unsafe_reason = "delay lane change"; |
1010 |
| - utils::path_safety_checker::updateCollisionCheckDebugMap(object_debug, debug, false); |
1011 |
| - return false; |
| 1012 | + if (min_dist_to_end_of_current_lane <= minimum_lane_change_length) { |
| 1013 | + return true; |
1012 | 1014 | }
|
1013 | 1015 |
|
1014 |
| - return true; |
| 1016 | + const auto current_pose = common_data_ptr->get_ego_pose(); |
| 1017 | + const auto dist_ego_to_obj = motion_utils::calcSignedArcLength( |
| 1018 | + current_lane_path.points, current_pose.position, leading_obj.initial_pose.pose.position); |
| 1019 | + |
| 1020 | + if (dist_ego_to_obj < lane_change_path.info.length.lane_changing) { |
| 1021 | + return true; |
| 1022 | + } |
| 1023 | + |
| 1024 | + debug.second.unsafe_reason = "delay lane change"; |
| 1025 | + utils::path_safety_checker::updateCollisionCheckDebugMap(object_debug, debug, false); |
| 1026 | + return false; |
1015 | 1027 | }
|
1016 | 1028 |
|
1017 | 1029 | std::optional<size_t> getLeadingStaticObjectIdx(
|
|
0 commit comments