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(goal_planner): update lateral_deviation_thresh from 0.3 to 0.1 #9850

Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -135,9 +135,7 @@ bool isOnModifiedGoal(
bool hasPreviousModulePathShapeChanged(
const BehaviorModuleOutput & upstream_module_output,
const BehaviorModuleOutput & last_upstream_module_output);
bool hasDeviatedFromLastPreviousModulePath(
const PlannerData & planner_data, const BehaviorModuleOutput & last_upstream_module_output);
bool hasDeviatedFromCurrentPreviousModulePath(
bool hasDeviatedFromPath(
const PlannerData & planner_data, const BehaviorModuleOutput & upstream_module_output);

bool needPathUpdate(
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/autoware_behavior_path_goal_planner_module/src/goal_planner_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Lines of Code in a Single File

The lines of code decreases from 1878 to 1870, 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_goal_planner_module/src/goal_planner_module.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 6.44 to 6.54, 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 @@ -155,7 +155,7 @@
{
// Calculate the lateral distance between each point of the current path and the nearest point of
// the last path
constexpr double LATERAL_DEVIATION_THRESH = 0.3;
constexpr double LATERAL_DEVIATION_THRESH = 0.1;
for (const auto & p : upstream_module_output.path.points) {
const size_t nearest_seg_idx = autoware::motion_utils::findNearestSegmentIndex(
last_upstream_module_output.path.points, p.point.pose.position);
Expand Down Expand Up @@ -184,18 +184,10 @@
return false;
}

bool hasDeviatedFromLastPreviousModulePath(
const PlannerData & planner_data, const BehaviorModuleOutput & last_upstream_module_output)
{
return std::abs(autoware::motion_utils::calcLateralOffset(
last_upstream_module_output.path.points,
planner_data.self_odometry->pose.pose.position)) > 0.3;
}

bool hasDeviatedFromCurrentPreviousModulePath(
bool hasDeviatedFromPath(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:
planner_data is too heavy to copy, and this function require only
planner_data.self_odometry->pose.pose.position.
so we can use

bool hasDeviatedFromPath(Point & ego_position, 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point is geometry mesgs

Copy link
Contributor Author

@Kazunori-Nakajima Kazunori-Nakajima Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! I see!
I fixed it.

const PlannerData & planner_data, const BehaviorModuleOutput & upstream_module_output)
{
constexpr double LATERAL_DEVIATION_THRESH = 0.3;
constexpr double LATERAL_DEVIATION_THRESH = 0.1;
return std::abs(autoware::motion_utils::calcLateralOffset(
upstream_module_output.path.points, planner_data.self_odometry->pose.pose.position)) >
LATERAL_DEVIATION_THRESH;
Expand Down Expand Up @@ -373,7 +365,7 @@
local_planner_data->self_odometry->pose.pose, modified_goal_opt, parameters_)) {
return false;
}
if (hasDeviatedFromCurrentPreviousModulePath(*local_planner_data, upstream_module_output)) {
if (hasDeviatedFromPath(*local_planner_data, upstream_module_output)) {
RCLCPP_DEBUG(getLogger(), "has deviated from current previous module path");
return false;
}
Expand All @@ -383,8 +375,7 @@
return true;
}
if (
hasDeviatedFromLastPreviousModulePath(
*local_planner_data, original_upstream_module_output_) &&
hasDeviatedFromPath(*local_planner_data, original_upstream_module_output_) &&
current_state != PathDecisionState::DecisionKind::DECIDED) {
RCLCPP_DEBUG(getLogger(), "has deviated from last previous module path");
return true;
Expand Down
Loading