Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(avoidance): avoidable right side parked-vehicle #2932

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -467,37 +467,81 @@ void AvoidanceModule::fillAvoidanceTargetObjects(
// +: object position
// o: nearest point on centerline

const auto most_left_road_lanelet = rh->getMostLeftLanelet(object_closest_lanelet);
const auto most_left_lanelet_candidates =
rh->getLaneletMapPtr()->laneletLayer.findUsages(most_left_road_lanelet.leftBound());
bool is_left_side_parked_vehicle = false;
{
auto [object_shiftable_distance, sub_type] = [&]() {
const auto most_left_road_lanelet = rh->getMostLeftLanelet(object_closest_lanelet);
const auto most_left_lanelet_candidates =
rh->getLaneletMapPtr()->laneletLayer.findUsages(most_left_road_lanelet.leftBound());

lanelet::ConstLanelet most_left_lanelet = most_left_road_lanelet;
const lanelet::Attribute sub_type =
most_left_lanelet.attribute(lanelet::AttributeName::Subtype);

for (const auto & ll : most_left_lanelet_candidates) {
const lanelet::Attribute sub_type = ll.attribute(lanelet::AttributeName::Subtype);
if (sub_type.value() == "road_shoulder") {
most_left_lanelet = ll;
}
}

const auto center_to_left_boundary = distance2d(
to2D(most_left_lanelet.leftBound().basicLineString()), to2D(centerline_point));

lanelet::ConstLanelet most_left_lanelet = most_left_road_lanelet;
return std::make_pair(
center_to_left_boundary - 0.5 * object.shape.dimensions.y, sub_type);
}();

for (const auto & ll : most_left_lanelet_candidates) {
const lanelet::Attribute sub_type = ll.attribute(lanelet::AttributeName::Subtype);
if (sub_type.value() == "road_shoulder") {
most_left_lanelet = ll;
if (sub_type.value() != "road_shoulder") {
object_shiftable_distance += parameters_->object_check_min_road_shoulder_width;
}
}

const auto center_to_left_boundary =
distance2d(to2D(most_left_lanelet.leftBound().basicLineString()), to2D(centerline_point));
double object_shiftable_distance = center_to_left_boundary - 0.5 * object.shape.dimensions.y;
const auto arc_coordinates = toArcCoordinates(
to2D(object_closest_lanelet.centerline().basicLineString()), object_centroid);
object_data.shiftable_ratio = arc_coordinates.distance / object_shiftable_distance;

const lanelet::Attribute sub_type =
most_left_lanelet.attribute(lanelet::AttributeName::Subtype);
if (sub_type.value() != "road_shoulder") {
object_shiftable_distance += parameters_->object_check_min_road_shoulder_width;
is_left_side_parked_vehicle =
object_data.shiftable_ratio > parameters_->object_check_shiftable_ratio;
}

const auto arc_coordinates = toArcCoordinates(
to2D(object_closest_lanelet.centerline().basicLineString()), object_centroid);
object_data.shiftable_ratio = arc_coordinates.distance / object_shiftable_distance;
bool is_right_side_parked_vehicle = false;
{
auto [object_shiftable_distance, sub_type] = [&]() {
const auto most_right_road_lanelet = rh->getMostRightLanelet(object_closest_lanelet);
const auto most_right_lanelet_candidates =
rh->getLaneletMapPtr()->laneletLayer.findUsages(most_right_road_lanelet.rightBound());

lanelet::ConstLanelet most_right_lanelet = most_right_road_lanelet;
const lanelet::Attribute sub_type =
most_right_lanelet.attribute(lanelet::AttributeName::Subtype);

for (const auto & ll : most_right_lanelet_candidates) {
const lanelet::Attribute sub_type = ll.attribute(lanelet::AttributeName::Subtype);
if (sub_type.value() == "road_shoulder") {
most_right_lanelet = ll;
}
}

const auto center_to_right_boundary = distance2d(
to2D(most_right_lanelet.rightBound().basicLineString()), to2D(centerline_point));

return std::make_pair(
center_to_right_boundary - 0.5 * object.shape.dimensions.y, sub_type);
}();

if (sub_type.value() != "road_shoulder") {
object_shiftable_distance += parameters_->object_check_min_road_shoulder_width;
}

const auto arc_coordinates = toArcCoordinates(
to2D(object_closest_lanelet.centerline().basicLineString()), object_centroid);
object_data.shiftable_ratio = -1.0 * arc_coordinates.distance / object_shiftable_distance;

const auto is_parking_object =
object_data.shiftable_ratio > parameters_->object_check_shiftable_ratio;
is_right_side_parked_vehicle =
object_data.shiftable_ratio > parameters_->object_check_shiftable_ratio;
}

if (!is_parking_object) {
if (!is_left_side_parked_vehicle && !is_right_side_parked_vehicle) {
avoidance_debug_array_false_and_push_back(AvoidanceDebugFactor::NOT_PARKING_OBJECT);
object_data.reason = AvoidanceDebugFactor::NOT_PARKING_OBJECT;
data.other_objects.push_back(object_data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ class RouteHandler
const lanelet::ConstLanelet & current_lane, bool is_right = true, bool is_left = true,
bool is_opposite = true, const bool & invert_opposite = false) const noexcept;

/**
* @brief Check if same-direction lane is available at the right side of the lanelet
* Searches for any lanes regardless of whether it is lane-changeable or not.
* Required the linestring to be shared(same line ID) between the lanelets.
* @param the lanelet of interest
* @return vector of lanelet having same direction if true
*/
lanelet::ConstLanelet getMostRightLanelet(const lanelet::ConstLanelet & lanelet) const;

/**
* @brief Check if same-direction lane is available at the left side of the lanelet
* Searches for any lanes regardless of whether it is lane-changeable or not.
Expand Down
11 changes: 11 additions & 0 deletions planning/route_handler/src/route_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,17 @@ lanelet::Lanelets RouteHandler::getLeftOppositeLanelets(const lanelet::ConstLane
return opposite_lanelets;
}

lanelet::ConstLanelet RouteHandler::getMostRightLanelet(const lanelet::ConstLanelet & lanelet) const
{
// recursively compute the width of the lanes
const auto & same = getRightLanelet(lanelet);

if (same) {
return getMostRightLanelet(same.get());
}
return lanelet;
}

lanelet::ConstLanelet RouteHandler::getMostLeftLanelet(const lanelet::ConstLanelet & lanelet) const
{
// recursively compute the width of the lanes
Expand Down