Skip to content

Commit

Permalink
refactor(turn_signal_decider): straddle bound method (#7006)
Browse files Browse the repository at this point in the history
* refactor straddle bound method

Signed-off-by: Daniel Sanchez <[email protected]>

* remove parenthesis

Signed-off-by: Daniel Sanchez <[email protected]>

* add alias for inner lambda

Signed-off-by: Daniel Sanchez <[email protected]>

---------

Signed-off-by: Daniel Sanchez <[email protected]>
  • Loading branch information
danielsanchezaran authored May 14, 2024
1 parent 2ae1716 commit a4bb177
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,23 +228,23 @@ class TurnSignalDecider
using tier4_autoware_utils::transformVector;

const auto footprint = vehicle_info.createFootprint();

for (const auto & lane : lanes) {
for (size_t i = shift_line.start_idx; i < shift_line.end_idx; ++i) {
const auto transform = pose2transform(path.path.points.at(i).point.pose);
const auto shifted_vehicle_footprint = transformVector(footprint, transform);

if (intersects(lane.leftBound2d().basicLineString(), shifted_vehicle_footprint)) {
return true;
}

if (intersects(lane.rightBound2d().basicLineString(), shifted_vehicle_footprint)) {
return true;
}
}
}

return false;
const auto start_itr = std::next(path.path.points.begin(), shift_line.start_idx);
const auto end_itr = std::next(path.path.points.begin(), shift_line.end_idx);

return std::any_of(start_itr, end_itr, [&footprint, &lanes](const auto & point) {
const auto transform = pose2transform(point.point.pose);
const auto shifted_vehicle_footprint = transformVector(footprint, transform);

auto check_for_vehicle_and_bound_intersection =
[&shifted_vehicle_footprint](const auto & lane) {
const auto & left_bound = lane.leftBound2d().basicLineString();
const auto & right_bound = lane.rightBound2d().basicLineString();
return intersects(left_bound, shifted_vehicle_footprint) ||
intersects(right_bound, shifted_vehicle_footprint);
};

return std::any_of(lanes.begin(), lanes.end(), check_for_vehicle_and_bound_intersection);
});
};

inline bool isNearEndOfShift(
Expand Down

0 comments on commit a4bb177

Please sign in to comment.