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(lane_change): add info text to virtual wall #9783

Merged
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 @@ -18,6 +18,7 @@
#include "autoware/behavior_path_lane_change_module/structs/debug.hpp"
#include "autoware/behavior_path_lane_change_module/structs/path.hpp"
#include "autoware/behavior_path_lane_change_module/utils/utils.hpp"
#include "autoware/behavior_path_planner_common/data_manager.hpp"
#include "autoware/behavior_path_planner_common/interface/scene_module_interface.hpp"
#include "autoware/behavior_path_planner_common/turn_signal_decider.hpp"
#include "autoware/behavior_path_planner_common/utils/path_shifter/path_shifter.hpp"
Expand All @@ -38,6 +39,7 @@
class TestNormalLaneChange;
namespace autoware::behavior_path_planner
{
using autoware::behavior_path_planner::PoseWithDetailOpt;
using autoware::route_handler::Direction;
using autoware::universe_utils::StopWatch;
using geometry_msgs::msg::Point;
Expand Down Expand Up @@ -222,7 +224,7 @@ class LaneChangeBase
return direction_;
}

std::optional<Pose> getStopPose() const { return lane_change_stop_pose_; }
PoseWithDetailOpt getStopPose() const { return lane_change_stop_pose_; }

void resetStopPose() { lane_change_stop_pose_ = std::nullopt; }

Expand Down Expand Up @@ -282,7 +284,7 @@ class LaneChangeBase
lane_change::CommonDataPtr common_data_ptr_;
FilteredLanesObjects filtered_objects_{};
BehaviorModuleOutput prev_module_output_{};
std::optional<Pose> lane_change_stop_pose_{std::nullopt};
PoseWithDetailOpt lane_change_stop_pose_{std::nullopt};

PathWithLaneId prev_approved_path_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "autoware/behavior_path_lane_change_module/structs/data.hpp"

#include <memory>
#include <string>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -157,7 +158,8 @@ class NormalLaneChange : public LaneChangeBase

bool check_prepare_phase() const;

void set_stop_pose(const double arc_length_to_stop_pose, PathWithLaneId & path);
void set_stop_pose(
const double arc_length_to_stop_pose, PathWithLaneId & path, const std::string & reason = "");

void updateStopTime();

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_lane_change_module/src/interface.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Overall Code Complexity

The mean cyclomatic complexity in this module is no longer above the threshold
//
// 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 @@ -111,9 +111,7 @@
path_reference_ = std::make_shared<PathWithLaneId>(output.reference_path);
*prev_approved_path_ = getPreviousModuleOutput().path;

const auto stop_pose_opt = module_type_->getStopPose();
stop_pose_ = stop_pose_opt.has_value() ? PoseWithDetailOpt(PoseWithDetail(stop_pose_opt.value()))
: PoseWithDetailOpt();
stop_pose_ = module_type_->getStopPose();

Check warning on line 114 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/interface.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/interface.cpp#L114

Added line #L114 was not covered by tests

const auto & lane_change_debug = module_type_->getDebugData();
for (const auto & [uuid, data] : lane_change_debug.collision_check_objects_after_approval) {
Expand Down Expand Up @@ -171,9 +169,7 @@
}

path_reference_ = std::make_shared<PathWithLaneId>(out.reference_path);
const auto stop_pose_opt = module_type_->getStopPose();
stop_pose_ = stop_pose_opt.has_value() ? PoseWithDetailOpt(PoseWithDetail(stop_pose_opt.value()))
: PoseWithDetailOpt();
stop_pose_ = module_type_->getStopPose();

if (!module_type_->isValidPath()) {
path_candidate_ = std::make_shared<PathWithLaneId>();
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_lane_change_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 1356 to 1358, 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_lane_change_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 4.71 to 4.73, 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 @@ -408,7 +408,7 @@
output.path.points, output.path.points.front().point.pose.position, getEgoPosition());
const auto stop_dist =
-(current_velocity * current_velocity / (2.0 * planner_data_->parameters.min_acc));
set_stop_pose(stop_dist + current_dist, output.path);
set_stop_pose(stop_dist + current_dist, output.path, "incoming rear object");
} else {
insert_stop_point(get_target_lanes(), output.path);
}
Expand Down Expand Up @@ -471,7 +471,7 @@
if (!is_current_lane) {
const auto arc_length_to_stop_pose = motion_utils::calcArcLength(path.points) -
common_data_ptr_->transient_data.next_dist_buffer.min;
set_stop_pose(arc_length_to_stop_pose, path);
set_stop_pose(arc_length_to_stop_pose, path, "next lc terminal");
return;
}

Expand Down Expand Up @@ -514,59 +514,60 @@

const auto dist_to_terminal_stop = std::min(dist_to_terminal_start, distance_to_last_fit_width);

const auto terminal_stop_reason = status_.is_valid_path ? "no safe path" : "no valid path";
if (filtered_objects_.current_lane.empty()) {
set_stop_pose(dist_to_terminal_stop, path);
set_stop_pose(dist_to_terminal_stop, path, terminal_stop_reason);
return;
}

const auto dist_to_target_lane_start = std::invoke([&]() -> double {
const auto & front_lane = lanes_ptr->target_neighbor.front();
const auto target_front =
utils::to_geom_msg_pose(front_lane.centerline2d().front(), front_lane);
return get_arc_length_along_lanelet(target_front);
});

const auto arc_length_to_current_obj = utils::lane_change::get_min_dist_to_current_lanes_obj(
common_data_ptr_, filtered_objects_, dist_to_target_lane_start, path);

// margin with leading vehicle
// consider rss distance when the LC need to avoid obstacles
const auto rss_dist = calcRssDistance(
0.0, lc_param_ptr->trajectory.min_lane_changing_velocity,
lc_param_ptr->safety.rss_params_for_parked);

const auto stop_margin = transient_data.lane_changing_length.min +
lc_param_ptr->backward_length_buffer_for_blocking_object + rss_dist +
bpp_param_ptr->base_link2front;
const auto stop_arc_length_behind_obj = arc_length_to_current_obj - stop_margin;

if (stop_arc_length_behind_obj < dist_to_target_lane_start) {
set_stop_pose(dist_to_target_lane_start, path);
set_stop_pose(dist_to_target_lane_start, path, "maintain distance to front object");
return;
}

if (stop_arc_length_behind_obj > dist_to_terminal_stop) {
set_stop_pose(dist_to_terminal_stop, path);
set_stop_pose(dist_to_terminal_stop, path, terminal_stop_reason);
return;
}

// If the target lane in the lane change section is blocked by a stationary obstacle, there
// is no reason for stopping with a lane change margin. Instead, stop right behind the
// obstacle.
// ----------------------------------------------------------
// [obj]>
// ----------------------------------------------------------
// [ego]> | <--- stop margin ---> [obj]>
// ----------------------------------------------------------
const auto has_blocking_target_lane_obj = utils::lane_change::has_blocking_target_object(
filtered_objects_.target_lane_leading, stop_arc_length_behind_obj, path);

if (has_blocking_target_lane_obj || stop_arc_length_behind_obj <= 0.0) {
set_stop_pose(dist_to_terminal_stop, path);
set_stop_pose(dist_to_terminal_stop, path, terminal_stop_reason);
return;
}

set_stop_pose(stop_arc_length_behind_obj, path);
set_stop_pose(stop_arc_length_behind_obj, path, "maintain distance to front object");

Check warning on line 570 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

NormalLaneChange::insert_stop_point_on_current_lanes 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.
}

PathWithLaneId NormalLaneChange::getReferencePath() const
Expand Down Expand Up @@ -1688,10 +1689,11 @@
return has_object_blocking;
}

void NormalLaneChange::set_stop_pose(const double arc_length_to_stop_pose, PathWithLaneId & path)
void NormalLaneChange::set_stop_pose(

Check warning on line 1692 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp#L1692

Added line #L1692 was not covered by tests
const double arc_length_to_stop_pose, PathWithLaneId & path, const std::string & reason)
{
const auto stop_point = utils::insertStopPoint(arc_length_to_stop_pose, path);
lane_change_stop_pose_ = stop_point.point.pose;
lane_change_stop_pose_ = PoseWithDetailOpt(PoseWithDetail(stop_point.point.pose, reason));
}

void NormalLaneChange::updateStopTime()
Expand Down
Loading