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

feat(obstacle_cruise_planner): independant decision making #9641

Closed
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
19 changes: 16 additions & 3 deletions planning/autoware_obstacle_cruise_planner/src/node.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 TIER IV, Inc.

Check notice on line 1 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: Lines of Code in a Single File

The lines of code increases from 1735 to 1743, 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.
//
// 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 @@ -1119,20 +1119,17 @@
const auto cruise_obstacle = createCruiseObstacle(
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 @@ -1666,6 +1663,22 @@
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 1681 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 1681 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
Loading