Skip to content

Commit 8fdebeb

Browse files
fix(lane_change): unify stuck detection to avoid unnecessary computation (#8383)
unify stuck detection in getLaneChangePaths Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
1 parent a742e82 commit 8fdebeb

File tree

3 files changed

+17
-26
lines changed
  • planning/behavior_path_planner/autoware_behavior_path_lane_change_module

3 files changed

+17
-26
lines changed

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/scene.hpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ class NormalLaneChange : public LaneChangeBase
155155

156156
bool getLaneChangePaths(
157157
const lanelet::ConstLanelets & current_lanes, const lanelet::ConstLanelets & target_lanes,
158-
Direction direction, LaneChangePaths * candidate_paths,
159-
const utils::path_safety_checker::RSSparams rss_params, const bool is_stuck,
160-
const bool check_safety = true) const override;
158+
Direction direction, const bool is_stuck, LaneChangePaths * candidate_paths) const;
161159

162160
std::optional<LaneChangePath> calcTerminalLaneChangePath(
163161
const lanelet::ConstLanelets & current_lanes,

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/utils/base_class.hpp

-6
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,6 @@ class LaneChangeBase
234234
const lanelet::ConstLanelets & current_lanes, const double backward_path_length,
235235
const double prepare_length) const = 0;
236236

237-
virtual bool getLaneChangePaths(
238-
const lanelet::ConstLanelets & original_lanelets,
239-
const lanelet::ConstLanelets & target_lanelets, Direction direction,
240-
LaneChangePaths * candidate_paths, const utils::path_safety_checker::RSSparams rss_params,
241-
const bool is_stuck, const bool check_safety) const = 0;
242-
243237
virtual bool isValidPath(const PathWithLaneId & path) const = 0;
244238

245239
virtual bool isAbleToStopSafely() const = 0;

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp

+16-17
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,9 @@ std::pair<bool, bool> NormalLaneChange::getSafePath(LaneChangePath & safe_path)
125125

126126
LaneChangePaths valid_paths{};
127127
const bool is_stuck = isVehicleStuck(current_lanes);
128-
bool found_safe_path = getLaneChangePaths(
129-
current_lanes, target_lanes, direction_, &valid_paths, lane_change_parameters_->rss_params,
130-
is_stuck);
128+
bool found_safe_path =
129+
getLaneChangePaths(current_lanes, target_lanes, direction_, is_stuck, &valid_paths);
131130
// if no safe path is found and ego is stuck, try to find a path with a small margin
132-
if (!found_safe_path && is_stuck) {
133-
found_safe_path = getLaneChangePaths(
134-
current_lanes, target_lanes, direction_, &valid_paths,
135-
lane_change_parameters_->rss_params_for_stuck, is_stuck);
136-
}
137131

138132
lane_change_debug_.valid_paths = valid_paths;
139133

@@ -1331,9 +1325,7 @@ bool NormalLaneChange::hasEnoughLengthToTrafficLight(
13311325

13321326
bool NormalLaneChange::getLaneChangePaths(
13331327
const lanelet::ConstLanelets & current_lanes, const lanelet::ConstLanelets & target_lanes,
1334-
Direction direction, LaneChangePaths * candidate_paths,
1335-
const utils::path_safety_checker::RSSparams rss_params, const bool is_stuck,
1336-
const bool check_safety) const
1328+
Direction direction, const bool is_stuck, LaneChangePaths * candidate_paths) const
13371329
{
13381330
lane_change_debug_.collision_check_objects.clear();
13391331
if (current_lanes.empty() || target_lanes.empty()) {
@@ -1637,13 +1629,20 @@ bool NormalLaneChange::getLaneChangePaths(
16371629
return false;
16381630
}
16391631

1640-
if (!check_safety) {
1641-
debug_print_lat("ACCEPT!!!: it is valid (and safety check is skipped).");
1642-
return false;
1643-
}
1632+
const auto is_safe = std::invoke([&]() {
1633+
const auto safety_check_with_normal_rss = isLaneChangePathSafe(
1634+
*candidate_path, target_objects, common_data_ptr_->lc_param_ptr->rss_params,
1635+
lane_change_debug_.collision_check_objects);
16441636

1645-
const auto [is_safe, is_trailing_object] = isLaneChangePathSafe(
1646-
*candidate_path, target_objects, rss_params, lane_change_debug_.collision_check_objects);
1637+
if (!safety_check_with_normal_rss.is_safe && is_stuck) {
1638+
const auto safety_check_with_stuck_rss = isLaneChangePathSafe(
1639+
*candidate_path, target_objects, common_data_ptr_->lc_param_ptr->rss_params_for_stuck,
1640+
lane_change_debug_.collision_check_objects);
1641+
return safety_check_with_stuck_rss.is_safe;
1642+
}
1643+
1644+
return safety_check_with_normal_rss.is_safe;
1645+
});
16471646

16481647
if (is_safe) {
16491648
debug_print_lat("ACCEPT!!!: it is valid and safe!");

0 commit comments

Comments
 (0)