Skip to content

Commit

Permalink
feat(obstacle_cruise_planner): independant decision making
Browse files Browse the repository at this point in the history
Signed-off-by: Takayuki Murooka <[email protected]>
  • Loading branch information
takayuki5168 committed Dec 13, 2024
1 parent 2127ca8 commit 2b8c45c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions planning/autoware_obstacle_cruise_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,19 +1120,16 @@ ObstacleCruisePlannerNode::determineEgoBehaviorAgainstPredictedObjectObstacles(
odometry, decimated_traj_points, decimated_traj_polys, obstacle, precise_lat_dist);
if (cruise_obstacle) {
cruise_obstacles.push_back(*cruise_obstacle);
continue;
}
const auto stop_obstacle = createStopObstacleForPredictedObject(
odometry, decimated_traj_points, decimated_traj_polys, obstacle, precise_lat_dist);
if (stop_obstacle) {
stop_obstacles.push_back(*stop_obstacle);
continue;
}
const auto slow_down_obstacle = createSlowDownObstacleForPredictedObject(
odometry, decimated_traj_points, obstacle, precise_lat_dist);
if (slow_down_obstacle) {
slow_down_obstacles.push_back(*slow_down_obstacle);

Check notice on line 1132 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

ObstacleCruisePlannerNode::determineEgoBehaviorAgainstPredictedObjectObstacles decreases in cyclomatic complexity from 13 to 10, 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.
continue;
}
}
const auto & p = behavior_determination_param_;
Expand Down Expand Up @@ -1484,6 +1481,7 @@ ObstacleCruisePlannerNode::createCollisionPointsForInsideCruiseObstacle(
return std::nullopt;
}

/*
{ // consider hysteresis
// const bool is_prev_obstacle_stop = getObstacleFromUuid(prev_stop_obstacles_,
// obstacle.uuid).has_value();
Expand All @@ -1504,6 +1502,7 @@ ObstacleCruisePlannerNode::createCollisionPointsForInsideCruiseObstacle(
// NOTE: else is cruise from stop
}
}
*/

// Get highest confidence predicted path
const auto resampled_predicted_paths = resampleHighestConfidencePredictedPaths(
Expand Down Expand Up @@ -1666,6 +1665,22 @@ std::optional<StopObstacle> ObstacleCruisePlannerNode::createStopObstacleForPred
if (!isStopObstacle(obstacle.classification.label)) {
return std::nullopt;
}

const bool is_prev_obstacle_stop =
getObstacleFromUuid(prev_stop_object_obstacles_, obstacle.uuid).has_value();

if (is_prev_obstacle_stop) {
if (p.obstacle_velocity_threshold_from_stop_to_cruise < obstacle.longitudinal_velocity) {
return std::nullopt;
}
// keep obstacle stop
} else {
if (p.obstacle_velocity_threshold_from_cruise_to_stop < obstacle.longitudinal_velocity) {
return std::nullopt;
}
// NOTE: else is stop from cruise
}

Check notice on line 1683 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Complex Method

ObstacleCruisePlannerNode::createStopObstacleForPredictedObject increases in cyclomatic complexity from 20 to 23, 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.

Check notice on line 1683 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Bumpy Road Ahead

ObstacleCruisePlannerNode::createStopObstacleForPredictedObject increases from 2 to 4 logical blocks with deeply nested code, threshold is one single block per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.
const double max_lat_margin_for_stop =
(obstacle.classification.label == ObjectClassification::UNKNOWN)
? p.max_lat_margin_for_stop_against_unknown
Expand Down

0 comments on commit 2b8c45c

Please sign in to comment.