Skip to content

Commit

Permalink
feat(lane_change): expand target lanes for object filtering
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Zulfaqar Azmi <[email protected]>
  • Loading branch information
zulfaqar-azmi-t4 committed Sep 28, 2023
1 parent c552c3d commit 6f3a68a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ struct LaneChangeParameters
bool check_objects_on_current_lanes{true};
bool check_objects_on_other_lanes{true};
bool use_all_predicted_path{false};
double lane_expansion_left_offset{0.0};
double lane_expansion_right_offset{0.0};

// regulatory elements
bool regulate_on_crosswalk{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,24 @@ ExtendedPredictedObject transform(

bool isCollidedPolygonsInLanelet(
const std::vector<Polygon2d> & collided_polygons, const lanelet::ConstLanelets & lanes);

/**
* @brief Generates expanded lanelets based on the given direction and offsets.
*
* Expands the provided lanelets in either the left or right direction based on
* the specified direction. If the direction is 'LEFT', the lanelets are expanded
* using the left_offset; if 'RIGHT', they are expanded using the right_offset.
* Otherwise, no expansion occurs.
*
* @param lanes The lanelets to be expanded.
* @param direction The direction of expansion: either LEFT or RIGHT.
* @param left_offset The offset value for left expansion.
* @param right_offset The offset value for right expansion.
* @return lanelet::ConstLanelets A collection of expanded lanelets.
*/
lanelet::ConstLanelets generateExpandedLanelets(
const lanelet::ConstLanelets & lanes, const Direction direction, const double left_offset,
const double right_offset);

} // namespace behavior_path_planner::utils::lane_change
#endif // BEHAVIOR_PATH_PLANNER__UTILS__LANE_CHANGE__UTILS_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ LaneChangeModuleManager::LaneChangeModuleManager(
getOrDeclareParameter<bool>(*node, parameter("check_objects_on_other_lanes"));
p.use_all_predicted_path =
getOrDeclareParameter<bool>(*node, parameter("use_all_predicted_path"));

p.lane_expansion_left_offset =
getOrDeclareParameter<double>(*node, parameter("safety_check.lane_expansion.left_offset"));
p.lane_expansion_right_offset =
getOrDeclareParameter<double>(*node, parameter("safety_check.lane_expansion.right_offset"));
// lane change regulations
p.regulate_on_crosswalk = getOrDeclareParameter<bool>(*node, parameter("regulation.crosswalk"));
p.regulate_on_intersection =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,11 @@ LaneChangeTargetObjectIndices NormalLaneChange::filterObject(

const auto current_polygon =
utils::lane_change::createPolygon(current_lanes, 0.0, std::numeric_limits<double>::max());
const auto target_polygon =
utils::lane_change::createPolygon(target_lanes, 0.0, std::numeric_limits<double>::max());
const auto expanded_target_lanes = utils::lane_change::generateExpandedLanelets(
target_lanes, direction_, lane_change_parameters_->lane_expansion_left_offset,
lane_change_parameters_->lane_expansion_right_offset);
const auto target_polygon = utils::lane_change::createPolygon(
expanded_target_lanes, 0.0, std::numeric_limits<double>::max());
const auto dist_ego_to_current_lanes_center =
lanelet::utils::getLateralDistanceToClosestLanelet(current_lanes, current_pose);
std::vector<std::optional<lanelet::BasicPolygon2d>> target_backward_polygons;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,4 +1104,13 @@ bool isCollidedPolygonsInLanelet(

return std::any_of(collided_polygons.begin(), collided_polygons.end(), is_in_lanes);
}

lanelet::ConstLanelets generateExpandedLanelets(
const lanelet::ConstLanelets & lanes, const Direction direction, const double left_offset,
const double right_offset)
{
const auto left_extend_offset = (direction == Direction::LEFT) ? left_offset : 0.0;
const auto right_extend_offset = (direction == Direction::RIGHT) ? -right_offset : 0.0;
return lanelet::utils::getExpandedLanelets(lanes, left_extend_offset, right_extend_offset);
}
} // namespace behavior_path_planner::utils::lane_change

0 comments on commit 6f3a68a

Please sign in to comment.