Skip to content

Commit

Permalink
fix(behavior_path_planner): fix turn signal endless loop (autowarefou…
Browse files Browse the repository at this point in the history
…ndation#5444)

Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 committed Nov 30, 2023
1 parent 4758e13 commit 2ceed0c
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions planning/behavior_path_planner/src/turn_signal_decider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,16 @@ boost::optional<TurnSignalInfo> TurnSignalDecider::getIntersectionTurnSignalInfo
const std::string lane_attribute =
current_lane.attributeOr("turn_direction", std::string("none"));

// check next lanes
auto next_lanes = route_handler.getNextLanelets(current_lane);
if (next_lanes.empty()) {
// check next lane has the same attribute
lanelet::ConstLanelet next_lane{};
if (!route_handler.getNextLaneletWithinRoute(current_lane, &next_lane)) {
break;
}

// filter next lanes with same attribute in the path
std::vector<lanelet::ConstLanelet> next_lanes_in_path{};
std::copy_if(
next_lanes.begin(), next_lanes.end(), std::back_inserter(next_lanes_in_path),
[&](const auto & next_lane) {
const bool is_in_unique_ids =
std::find(unique_lane_ids.begin(), unique_lane_ids.end(), next_lane.id()) !=
unique_lane_ids.end();
const bool has_same_attribute =
next_lane.attributeOr("turn_direction", std::string("none")) == lane_attribute;
return is_in_unique_ids && has_same_attribute;
});
if (next_lanes_in_path.empty()) {
if (next_lane.attributeOr("turn_direction", std::string("none")) != lane_attribute) {
break;
}

// assume that the next lane in the path is only one
current_lane = next_lanes_in_path.front();
current_lane = next_lane;
}

if (!combined_lane_elems.empty()) {
Expand Down

0 comments on commit 2ceed0c

Please sign in to comment.