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

chore(intersection): parameterize stuck vehicle detection turn_direction #5277

Merged
merged 1 commit into from
Oct 12, 2023
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 @@ -13,6 +13,10 @@
path_interpolation_ds: 0.1 # [m]
consider_wrong_direction_vehicle: false
stuck_vehicle:
turn_direction:
left: true
right: true
straight: true
use_stuck_stopline: true # stopline generated before the first conflicting area
stuck_vehicle_detect_dist: 5.0 # this should be the length between cars when they are stopped. The actual stuck vehicle detection length will be this value + vehicle_length.
stuck_vehicle_vel_thr: 0.833 # 0.833m/s = 3.0km/h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ IntersectionModuleManager::IntersectionModuleManager(rclcpp::Node & node)
ip.common.consider_wrong_direction_vehicle =
getOrDeclareParameter<bool>(node, ns + ".common.consider_wrong_direction_vehicle");

ip.stuck_vehicle.turn_direction.left =
getOrDeclareParameter<bool>(node, ns + ".stuck_vehicle.turn_direction.left");
ip.stuck_vehicle.turn_direction.right =
getOrDeclareParameter<bool>(node, ns + ".stuck_vehicle.turn_direction.right");
ip.stuck_vehicle.turn_direction.straight =
getOrDeclareParameter<bool>(node, ns + ".stuck_vehicle.turn_direction.straight");
ip.stuck_vehicle.use_stuck_stopline =
getOrDeclareParameter<bool>(node, ns + ".stuck_vehicle.use_stuck_stopline");
ip.stuck_vehicle.stuck_vehicle_detect_dist =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Tier IV, Inc.

Check notice on line 1 in planning/behavior_velocity_intersection_module/src/scene_intersection.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 1506 to 1511, 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_velocity_intersection_module/src/scene_intersection.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 7.41 to 7.56, 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 @@ -1213,8 +1213,12 @@
bool IntersectionModule::checkStuckVehicle(
const std::shared_ptr<const PlannerData> & planner_data, const util::PathLanelets & path_lanelets)
{
// NOTE: No need to stop for stuck vehicle when the ego will turn left.
if (turn_direction_ == std::string("left")) {
const bool stuck_detection_direction = [&]() {

Check warning on line 1216 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1216

Added line #L1216 was not covered by tests
return (turn_direction_ == "left" && planner_param_.stuck_vehicle.turn_direction.left) ||
(turn_direction_ == "right" && planner_param_.stuck_vehicle.turn_direction.right) ||
(turn_direction_ == "straight" && planner_param_.stuck_vehicle.turn_direction.straight);
}();

Check warning on line 1220 in planning/behavior_velocity_intersection_module/src/scene_intersection.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_velocity_intersection_module/src/scene_intersection.cpp#L1220

Added line #L1220 was not covered by tests
if (!stuck_detection_direction) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ class IntersectionModule : public SceneModuleInterface
} common;
struct StuckVehicle
{
struct TurnDirection
{
bool left;
bool right;
bool straight;
} turn_direction;
bool use_stuck_stopline; //! stopline generate before the intersection lanelet when is_stuck.
double stuck_vehicle_detect_dist; //! distance from end point to finish stuck vehicle check
double stuck_vehicle_vel_thr; //! Threshold of the speed to be recognized as stopped
Expand Down
Loading