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): implement terminal lane change feature #9592

Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f9ddbb6
implement function to compute terminal lane change path
mkquda Nov 11, 2024
7d71f67
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Nov 13, 2024
9ee52bb
push terminal path to candidate paths if no other valid candidate pat…
mkquda Nov 13, 2024
46b9bf3
use terminal path in LC interface planWaitingApproval function
mkquda Nov 13, 2024
c1b84e2
set lane changing longitudinal accel to zero for terminal lc path
mkquda Nov 13, 2024
38a7841
rename function
mkquda Nov 13, 2024
8c3f006
Merge remote-tracking branch 'origin/awf-latest' into RT1-8205-implem…
mkquda Nov 13, 2024
c0b39d8
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Nov 25, 2024
e855b39
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Nov 26, 2024
aa5bb07
chore: rename codeowners file
tkimura4 Nov 27, 2024
690b262
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Nov 28, 2024
ff69ee9
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 2, 2024
aa79ab9
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 3, 2024
63d6700
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 6, 2024
d547fcc
remove unused member variable prev_approved_path_
mkquda Dec 6, 2024
cebe4c1
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 6, 2024
7739b75
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 8, 2024
8eb32ae
refactor stop point insertion for terminal lc path
mkquda Dec 8, 2024
aacb961
add flag to enable/disable terminal path feature
mkquda Dec 8, 2024
5ee503f
update README
mkquda Dec 9, 2024
e83c97b
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 10, 2024
a2f6eca
add parameter to configure stop point placement
mkquda Dec 10, 2024
dfcd5e8
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 11, 2024
8265c3f
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 12, 2024
33a6804
compute terminal path only when near terminal start
mkquda Dec 13, 2024
3e6eed9
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 18, 2024
c2a900c
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 20, 2024
75a6878
add option to disable feature near goal
mkquda Dec 20, 2024
349850b
set default flag value to false
mkquda Dec 23, 2024
79338e2
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 23, 2024
a382a0e
add documentation for terminal lane change path
mkquda Dec 23, 2024
78b1182
ensure actual prepare duration is always above minimum prepare durati…
mkquda Dec 24, 2024
10fa0e0
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 24, 2024
fb2f9e0
explicitly return std::nullopt
mkquda Dec 24, 2024
97705fd
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 25, 2024
2d258d0
Update planning/behavior_path_planner/autoware_behavior_path_lane_cha…
mkquda Dec 25, 2024
1a4fd5b
fix assignment
mkquda Dec 25, 2024
6514c0e
fix spelling
mkquda Dec 25, 2024
fe583cb
Merge branch 'main' into RT1-8205-implement-terminal-lane-change-feature
mkquda Dec 25, 2024
c6c468b
Merge branch 'awf-latest' into RT1-8205-implement-terminal-lane-chang…
mkquda Dec 27, 2024
44f90b8
fix merge errors
mkquda Dec 27, 2024
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 @@ -874,6 +874,16 @@
@enduml
```

## Terminal Lane Change Path

Depending on the space configration around the Ego vehicle, it is possible that a valid LC path cannot be generated. If that happens, then Ego will get stuck at `terminal_start` and will be not be able to proceed. Therefore we introduced the terminal LC path feature; when ego gets near to the terminal point (dist to `terminal_start` is less than the maximum lane change length) a terminal lane changing path will be computed starting from the terminal start point on the current lane and connects to the target lane. The terminal path only needs to be computed once in each execution of LC module. If no valid candidate paths are found in the path generation process, then the terminal path will be used as a fallback candidate path, the safety of the terminal path is not ensured and therefore it can only be force approved. The following images illustrate the expected behavior without and with the terminal path feature respectively:

Check warning on line 879 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/README.md

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (configration)

![no terminal path](./images/lane_change-no_terminal_path.png)

![terminal path](./images/lane_change-terminal_path.png)

Additionally if terminal path feature is enabled and path is computed, stop point placement can be configured to be at the edge of the current lane instead of at the `terminal_start` position, as indicated by the dashed red line in the image above.

## Parameters

### Essential lane change parameters
Expand Down Expand Up @@ -934,6 +944,16 @@
| `delay_lane_change.min_road_shoulder_width` | [m] | double | Width considered as road shoulder if lane doesn't have road shoulder when checking for parked vehicle | 0.5 |
| `delay_lane_change.th_parked_vehicle_shift_ratio` | [-] | double | Stopped vehicles beyond this distance ratio from center line will be considered as parked | 0.6 |

### Terminal Lane Change Path

The following parameters are used to configure terminal lane change path feature.
mkquda marked this conversation as resolved.
Show resolved Hide resolved

| Name | Unit | Type | Description | Default value |
| :-------------------------------- | ---- | ---- | ------------------------------------------------------------------------- | ------------- |
| `terminal_path.enable` | [-] | bool | Flag to enable/disable terminal path feature | true |
| `terminal_path.disable_near_goal` | [-] | bool | Flag to disable terminal path feature if ego is near goal | true |
| `terminal_path.stop_at_boundary` | [-] | bool | If true, ego will stop at current lane boundary instead of middle of lane | false |

### Collision checks

#### Target Objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
# turn signal
min_length_for_turn_signal_activation: 10.0 # [m]

# terminal path
terminal_path:
enable: true
disable_near_goal: true
stop_at_boundary: false

# trajectory generation
trajectory:
max_prepare_duration: 4.0
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class LaneChangeBase

virtual void insert_stop_point(
[[maybe_unused]] const lanelet::ConstLanelets & lanelets,
[[maybe_unused]] PathWithLaneId & path)
[[maybe_unused]] PathWithLaneId & path, [[maybe_unused]] const bool is_waiting_approval = false)
{
}

Expand Down Expand Up @@ -288,8 +288,7 @@ class LaneChangeBase
FilteredLanesObjects filtered_objects_{};
BehaviorModuleOutput prev_module_output_{};
std::optional<Pose> lane_change_stop_pose_{std::nullopt};

PathWithLaneId prev_approved_path_;
mutable std::optional<LaneChangePath> terminal_lane_change_path_{std::nullopt};

int unsafe_hysteresis_count_{0};
bool is_abort_path_approved_{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ class LaneChangeInterface : public SceneModuleInterface

mutable MarkerArray virtual_wall_marker_;

std::unique_ptr<PathWithLaneId> prev_approved_path_;

void clearAbortApproval() { is_abort_path_approved_ = false; }

bool is_abort_path_approved_{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ class NormalLaneChange : public LaneChangeBase

void extendOutputDrivableArea(BehaviorModuleOutput & output) const override;

void insert_stop_point(const lanelet::ConstLanelets & lanelets, PathWithLaneId & path) override;
void insert_stop_point(
const lanelet::ConstLanelets & lanelets, PathWithLaneId & path,
const bool is_waiting_approval = false) override;

void insert_stop_point_on_current_lanes(PathWithLaneId & path);
void insert_stop_point_on_current_lanes(
PathWithLaneId & path, const bool is_waiting_approval = false);

PathWithLaneId getReferencePath() const override;

Expand Down Expand Up @@ -151,9 +154,7 @@ class NormalLaneChange : public LaneChangeBase
bool check_candidate_path_safety(
const LaneChangePath & candidate_path, const lane_change::TargetObjects & target_objects) const;

std::optional<LaneChangePath> calcTerminalLaneChangePath(
const lanelet::ConstLanelets & current_lanes,
const lanelet::ConstLanelets & target_lanes) const;
std::optional<PathWithLaneId> compute_terminal_lane_change_path() const;

bool isValidPath(const PathWithLaneId & path) const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@
terminal_lane_changing_velocity = _lc_metrics.velocity;
shift_line = _shift_line;
}

void set_prepare(const PhaseMetrics & _prep_metrics)
{
longitudinal_acceleration.prepare = _prep_metrics.actual_lon_accel;
velocity.prepare = _prep_metrics.velocity;
duration.prepare = _prep_metrics.duration;

Check warning on line 136 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/structs/data.hpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/structs/data.hpp#L134-L136

Added lines #L134 - L136 were not covered by tests
length.prepare = _prep_metrics.length;
}

void set_lane_changing(const PhaseMetrics & _lc_metrics)
{
longitudinal_acceleration.prepare = _lc_metrics.actual_lon_accel;
velocity.prepare = _lc_metrics.velocity;
duration.prepare = _lc_metrics.duration;
length.prepare = _lc_metrics.length;
}
mkquda marked this conversation as resolved.
Show resolved Hide resolved
};

struct TargetLaneLeadingObjects
Expand Down Expand Up @@ -217,6 +233,8 @@

double target_lane_length{std::numeric_limits<double>::min()};

double dist_to_target_end{std::numeric_limits<double>::max()};

lanelet::ArcCoordinates current_lanes_ego_arc; // arc coordinates of ego pose along current lanes
lanelet::ArcCoordinates target_lanes_ego_arc; // arc coordinates of ego pose along target lanes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,20 @@ struct DelayParameters
double th_parked_vehicle_shift_ratio{0.6};
};

struct TerminalPathParameters
{
bool enable{false};
bool disable_near_goal{false};
bool stop_at_boundary{false};
};

struct Parameters
{
TrajectoryParameters trajectory{};
SafetyParameters safety{};
CancelParameters cancel{};
DelayParameters delay{};
TerminalPathParameters terminal_path{};

// lane change parameters
double backward_lane_length{200.0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ double calc_dist_to_last_fit_width(
const lanelet::ConstLanelets & lanelets, const Pose & src_pose,
const BehaviorPathPlannerParameters & bpp_param, const double margin = 0.1);

double calc_dist_to_last_fit_width(
const CommonDataPtr & common_data_ptr, const PathWithLaneId & path, const double margin = 0.1);

/**
* @brief Calculates the maximum preparation longitudinal distance for lane change.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
std::unique_ptr<LaneChangeBase> && module_type)
: SceneModuleInterface{name, node, rtc_interface_ptr_map, objects_of_interest_marker_interface_ptr_map}, // NOLINT
parameters_{std::move(parameters)},
module_type_{std::move(module_type)},
prev_approved_path_{std::make_unique<PathWithLaneId>()}
module_type_{std::move(module_type)}
{
module_type_->setTimeKeeper(getTimeKeeper());
logger_ = utils::lane_change::getLogger(module_type_->getModuleTypeStr());
Expand Down Expand Up @@ -109,7 +108,6 @@

auto output = module_type_->generateOutput();
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()))
Expand Down Expand Up @@ -157,11 +155,9 @@

BehaviorModuleOutput LaneChangeInterface::planWaitingApproval()
{
BehaviorModuleOutput out = getPreviousModuleOutput();
BehaviorModuleOutput out = module_type_->getTerminalLaneChangePath();

Check warning on line 158 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#L158

Added line #L158 was not covered by tests

*prev_approved_path_ = out.path;

module_type_->insert_stop_point(module_type_->get_current_lanes(), out.path);
module_type_->insert_stop_point(module_type_->get_current_lanes(), out.path, true);
out.turn_signal_info = module_type_->get_current_turn_signal_info();

const auto & lane_change_debug = module_type_->getDebugData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@
// debug marker
p.publish_debug_marker = getOrDeclareParameter<bool>(*node, parameter("publish_debug_marker"));

// terminal lane change path
p.terminal_path.enable = getOrDeclareParameter<bool>(*node, parameter("terminal_path.enable"));
p.terminal_path.disable_near_goal =
getOrDeclareParameter<bool>(*node, parameter("terminal_path.disable_near_goal"));
p.terminal_path.stop_at_boundary =
getOrDeclareParameter<bool>(*node, parameter("terminal_path.stop_at_boundary"));

Check warning on line 249 in planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/manager.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

LaneChangeModuleManager::set_params already has high cyclomatic complexity, and now it increases in Lines of Code from 200 to 205. 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.
// validation of safety check parameters
// if loose check is not enabled, lane change module will keep on chattering and canceling, and
// false positive situation might occur
Expand Down
Loading
Loading