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): don't insert stop line if the ego can't avoid or return #9089

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -321,6 +321,19 @@ class AvoidanceHelper
});
}

bool isFeasible(const AvoidLineArray & shift_lines) const
{
const auto JERK_BUFFER = 0.1; // [m/sss]
satoshi-ota marked this conversation as resolved.
Show resolved Hide resolved
const auto & values = parameters_->velocity_map;
const auto idx = getConstraintsMapIndex(0.0, values); // use minimum avoidance speed
const auto jerk_limit = parameters_->lateral_max_jerk_map.at(idx);
return std::all_of(shift_lines.begin(), shift_lines.end(), [&](const auto & line) {
return autoware::motion_utils::calc_jerk_from_lat_lon_distance(
line.getRelativeLength(), line.getRelativeLongitudinal(), values.at(idx)) <
jerk_limit + JERK_BUFFER;
});
}

bool isReady(const ObjectDataArray & objects) const
{
if (objects.empty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check notice on line 1 in planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1397 to 1413, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 5.60 to 5.70, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// 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 @@ -1630,28 +1630,42 @@
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
const auto & data = avoid_data_;

if (data.new_shift_line.empty()) {
RCLCPP_WARN(getLogger(), "module doesn't have return shift line.");
return;
}

if (data.to_return_point > planner_data_->parameters.forward_path_length) {
RCLCPP_DEBUG(getLogger(), "return dead line is far enough.");
return;
}

const auto shift_length = path_shifter_.getLastShiftLength();

if (std::abs(shift_length) < 1e-3) {
RCLCPP_DEBUG(getLogger(), "don't have to consider return shift.");
return;
}

if (!helper_->isFeasible(data.new_shift_line)) {
RCLCPP_WARN(getLogger(), "return shift line is not feasible. do nothing..");
return;
}

// Consider the difference in path length between the shifted path and original path (the path
// that is shifted inward has a shorter distance to the end of the path than the other one.)
const auto & to_reference_path_end = data.arclength_from_ego.back();
const auto to_shifted_path_end = autoware::motion_utils::calcSignedArcLength(
shifted_path.path.points, getEgoPosition(), shifted_path.path.points.size() - 1);
const auto buffer = std::max(0.0, to_shifted_path_end - to_reference_path_end);

const auto min_return_distance =
helper_->getMinAvoidanceDistance(shift_length) + helper_->getNominalPrepareDistance(0.0);
const auto to_stop_line = data.to_return_point - min_return_distance - buffer;
if (to_stop_line < 0.0) {
RCLCPP_WARN(getLogger(), "ego overran return shift dead line. do nothing.");
return;
}

Check warning on line 1668 in planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

StaticObstacleAvoidanceModule::insertReturnDeadLine has a cyclomatic complexity of 11, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

// If we don't need to consider deceleration constraints, insert a deceleration point
// and return immediately
Expand Down Expand Up @@ -1721,6 +1735,11 @@
return;
}

if (data.to_stop_line < 0.0) {
RCLCPP_WARN(getLogger(), "ego overran avoidance dead line. do nothing.");
return;
}

Check warning on line 1742 in planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

StaticObstacleAvoidanceModule::insertWaitPoint has a cyclomatic complexity of 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
// If we don't need to consider deceleration constraints, insert a deceleration point
// and return immediately
if (!use_constraints_for_decel) {
Expand Down
Loading