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(lane_change): add visualization for passParkedObject #5291

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 @@ -52,6 +52,7 @@ using data::lane_change::PathSafetyStatus;
using geometry_msgs::msg::Point;
using geometry_msgs::msg::Pose;
using geometry_msgs::msg::Twist;
using path_safety_checker::CollisionCheckDebugMap;
using route_handler::Direction;
using tier4_autoware_utils::Polygon2d;

Expand Down Expand Up @@ -170,7 +171,8 @@ bool isParkedObject(
bool passParkedObject(
const RouteHandler & route_handler, const LaneChangePath & lane_change_path,
const std::vector<ExtendedPredictedObject> & objects, const double minimum_lane_change_length,
const bool is_goal_in_route, const LaneChangeParameters & lane_change_parameters);
const bool is_goal_in_route, const LaneChangeParameters & lane_change_parameters,
CollisionCheckDebugMap & object_debug);

boost::optional<size_t> getLeadingStaticObjectIdx(
const RouteHandler & route_handler, const LaneChangePath & lane_change_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ bool NormalLaneChange::getLaneChangePaths(

if (utils::lane_change::passParkedObject(
route_handler, *candidate_path, target_objects.target_lane, lane_change_buffer,
is_goal_in_route, *lane_change_parameters_)) {
is_goal_in_route, *lane_change_parameters_, object_debug_)) {
return false;
}
candidate_paths->push_back(*candidate_path);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Tier IV, Inc.

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

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Primitive Obsession

The ratio of primitive types in function arguments decreases from 33.59% to 33.33%, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -930,52 +930,56 @@
bool passParkedObject(
const RouteHandler & route_handler, const LaneChangePath & lane_change_path,
const std::vector<ExtendedPredictedObject> & objects, const double minimum_lane_change_length,
const bool is_goal_in_route, const LaneChangeParameters & lane_change_parameters)
const bool is_goal_in_route, const LaneChangeParameters & lane_change_parameters,
CollisionCheckDebugMap & object_debug)
{
const auto & object_check_min_road_shoulder_width =
lane_change_parameters.object_check_min_road_shoulder_width;
const auto & object_shiftable_ratio_threshold =
lane_change_parameters.object_shiftable_ratio_threshold;
const auto & path = lane_change_path.path;
const auto & current_lanes = lane_change_path.info.current_lanes;
const auto current_lane_path =
route_handler.getCenterLinePath(current_lanes, 0.0, std::numeric_limits<double>::max());

if (objects.empty() || path.points.empty() || current_lane_path.points.empty()) {
return false;
}

const auto leading_obj_idx = getLeadingStaticObjectIdx(
route_handler, lane_change_path, objects, object_check_min_road_shoulder_width,
object_shiftable_ratio_threshold);
if (!leading_obj_idx) {
return false;
}

const auto & leading_obj = objects.at(*leading_obj_idx);
auto debug = marker_utils::createObjectDebug(leading_obj);
const auto leading_obj_poly =
tier4_autoware_utils::toPolygon2d(leading_obj.initial_pose.pose, leading_obj.shape);
if (leading_obj_poly.outer().empty()) {
return false;
}

const auto & current_path_end = current_lane_path.points.back().point.pose.position;
double min_dist_to_end_of_current_lane = std::numeric_limits<double>::max();
for (const auto & point : leading_obj_poly.outer()) {
const auto obj_p = tier4_autoware_utils::createPoint(point.x(), point.y(), 0.0);
const double dist =
motion_utils::calcSignedArcLength(current_lane_path.points, obj_p, current_path_end);
min_dist_to_end_of_current_lane = std::min(dist, min_dist_to_end_of_current_lane);
if (is_goal_in_route) {
const auto goal_pose = route_handler.getGoalPose();
const double dist_to_goal =
motion_utils::calcSignedArcLength(current_lane_path.points, obj_p, goal_pose.position);
min_dist_to_end_of_current_lane = std::min(min_dist_to_end_of_current_lane, dist_to_goal);
}
}

// If there are still enough length after the target object, we delay the lane change
if (min_dist_to_end_of_current_lane > minimum_lane_change_length) {
debug.second.unsafe_reason = "delay lane change";
marker_utils::updateCollisionCheckDebugMap(object_debug, debug, false);

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

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Excess Number of Function Arguments

passParkedObject increases from 6 to 7 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
return true;
}

Expand Down
Loading