Skip to content

Commit be454ee

Browse files
zulfaqar-azmi-t4maxime-clem
authored andcommitted
feat(lane_change): fix delay logic that caused timing to be late (autowarefoundation#8549)
* RT1-5067 fix delay logic that caused timing to be late Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> * remove autoware namespace Co-authored-by: Maxime CLEMENT <78338830+maxime-clem@users.noreply.github.com> --------- Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> Co-authored-by: Maxime CLEMENT <78338830+maxime-clem@users.noreply.github.com>
1 parent b714a54 commit be454ee

File tree

1 file changed

+30
-18
lines changed
  • planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/utils

1 file changed

+30
-18
lines changed

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/utils/utils.cpp

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "autoware/behavior_path_lane_change_module/utils/utils.hpp"
1616

17+
#include "autoware/behavior_path_lane_change_module/utils/calculation.hpp"
1718
#include "autoware/behavior_path_lane_change_module/utils/data_structs.hpp"
1819
#include "autoware/behavior_path_lane_change_module/utils/path.hpp"
1920
#include "autoware/behavior_path_planner_common/marker_utils/utils.hpp"
@@ -988,30 +989,41 @@ bool passed_parked_objects(
988989
}
989990

990991
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) {
1000994
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);
1004997
}
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+
});
10061010

10071011
// 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;
10121014
}
10131015

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;
10151027
}
10161028

10171029
std::optional<size_t> getLeadingStaticObjectIdx(

0 commit comments

Comments
 (0)