Skip to content

Commit

Permalink
make current lanes include path front id
Browse files Browse the repository at this point in the history
Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 committed Oct 24, 2023
1 parent 4ca48aa commit 15cdf37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,7 @@ TurnSignalInfo NormalLaneChange::updateOutputTurnSignal()

lanelet::ConstLanelets NormalLaneChange::getCurrentLanes() const
{
return utils::getCurrentLanes(
planner_data_, lane_change_parameters_->backward_lane_length,
planner_data_->parameters.forward_path_length);
return utils::getCurrentLanesFromPath(prev_module_path_, planner_data_);
}

lanelet::ConstLanelets NormalLaneChange::getLaneChangeLanes(
Expand Down
18 changes: 17 additions & 1 deletion planning/behavior_path_planner/src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3068,8 +3068,24 @@ lanelet::ConstLanelets getCurrentLanesFromPath(
lanelet::ConstLanelet current_lane;
lanelet::utils::query::getClosestLanelet(reference_lanes, current_pose, &current_lane);

return route_handler->getLaneletSequence(
auto current_lanes = route_handler->getLaneletSequence(
current_lane, current_pose, p.backward_path_length, p.forward_path_length);

// Extend the 'lanes' with previous lanes until it contains 'front_lane_ids'.
const auto front_lane_ids = path.points.front().lane_ids;
auto have_front_lanes = [front_lane_ids](const auto & lanes) {
return std::any_of(lanes.begin(), lanes.end(), [&](const auto & lane) {
return std::find(front_lane_ids.begin(), front_lane_ids.end(), lane.id()) !=
front_lane_ids.end();
});
};
while (!have_front_lanes(current_lanes)) {
const auto extended_lanes = extendNextLane(route_handler, current_lanes);
if (extended_lanes.size() == current_lanes.size()) break;
current_lanes = extended_lanes;
}

return current_lanes;

Check notice on line 3088 in planning/behavior_path_planner/src/utils/utils.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ New issue: Bumpy Road Ahead

getCurrentLanesFromPath has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is one single, nested block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
}

lanelet::ConstLanelets extendNextLane(
Expand Down

0 comments on commit 15cdf37

Please sign in to comment.