Skip to content

Commit

Permalink
feat: add predefined deceleration rate for VRUs
Browse files Browse the repository at this point in the history
Signed-off-by: Berkay Karaman <berkay@leodrive.ai>
  • Loading branch information
Berkay Karaman committed Sep 25, 2024
1 parent d499b48 commit 3b2e246
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@
outside_obstacle:
max_lateral_time_margin: 4.0 # time threshold of lateral margin between the obstacles and ego's footprint [s]
num_of_predicted_paths: 3 # number of the highest confidence predicted path to check collision between obstacle and ego
pedestrian_deceleration_rate: 0.5 # planner perceives pedestrians will stop with this rate to avoid unnecessary stops [m/ss]
bicycle_deceleration_rate: 0.5 # planner perceives bicycles will stop with this rate to avoid unnecessary stops [m/ss]
crossing_obstacle:
collision_time_margin : 4.0 # time threshold of collision between obstacle adn ego for cruise or stop [s]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ class ObstacleCruisePlannerNode : public rclcpp::Node
double crossing_obstacle_traj_angle_threshold;
int num_of_predicted_paths_for_outside_cruise_obstacle;
int num_of_predicted_paths_for_outside_stop_obstacle;
double pedestrian_deceleration_rate;
double bicycle_deceleration_rate;
// obstacle hold
double stop_obstacle_hold_time_threshold;
// reach collision point
Expand Down
27 changes: 25 additions & 2 deletions planning/autoware_obstacle_cruise_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ ObstacleCruisePlannerNode::BehaviorDeterminationParam::BehaviorDeterminationPara
"behavior_determination.cruise.outside_obstacle.num_of_predicted_paths");
num_of_predicted_paths_for_outside_stop_obstacle = node.declare_parameter<int>(
"behavior_determination.stop.outside_obstacle.num_of_predicted_paths");
pedestrian_deceleration_rate = node.declare_parameter<double>(
"behavior_determination.stop.outside_obstacle.pedestrian_deceleration_rate");
bicycle_deceleration_rate = node.declare_parameter<double>(
"behavior_determination.stop.outside_obstacle.bicycle_deceleration_rate");

Check warning on line 374 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Large Method

ObstacleCruisePlannerNode::BehaviorDeterminationParam::BehaviorDeterminationParam has 83 lines, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
}

void ObstacleCruisePlannerNode::BehaviorDeterminationParam::onParam(
Expand Down Expand Up @@ -475,6 +479,12 @@ void ObstacleCruisePlannerNode::BehaviorDeterminationParam::onParam(
autoware::universe_utils::updateParam<int>(
parameters, "behavior_determination.stop.outside_obstacle.num_of_predicted_paths",
num_of_predicted_paths_for_outside_stop_obstacle);

Check warning on line 481 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_obstacle_cruise_planner/src/node.cpp#L481

Added line #L481 was not covered by tests
autoware::universe_utils::updateParam<double>(
parameters, "behavior_determination.stop.outside_obstacle.pedestrian_deceleration_rate",
pedestrian_deceleration_rate);

Check warning on line 484 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_obstacle_cruise_planner/src/node.cpp#L484

Added line #L484 was not covered by tests
autoware::universe_utils::updateParam<double>(
parameters, "behavior_determination.stop.outside_obstacle.bicycle_deceleration_rate",
bicycle_deceleration_rate);

Check warning on line 487 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: Large Method

ObstacleCruisePlannerNode::BehaviorDeterminationParam::onParam increases from 89 to 110 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check warning on line 487 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_obstacle_cruise_planner/src/node.cpp#L487

Added line #L487 was not covered by tests
}

ObstacleCruisePlannerNode::ObstacleCruisePlannerNode(const rclcpp::NodeOptions & node_options)
Expand Down Expand Up @@ -1664,10 +1674,23 @@ std::optional<StopObstacle> ObstacleCruisePlannerNode::createStopObstacleForPred
return std::nullopt;
}

// brkay54: For the pedestrians and bicycles, we need to check the collision point by thinking

Check warning on line 1677 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (brkay)
// they will stop with a predefined deceleration rate to avoid unnecessary stops.
double resample_time_horizon = p.prediction_resampling_time_horizon;

Check warning on line 1679 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_obstacle_cruise_planner/src/node.cpp#L1679

Added line #L1679 was not covered by tests
if (obstacle.classification.label == ObjectClassification::PEDESTRIAN) {
resample_time_horizon =
std::sqrt(std::pow(obstacle.twist.linear.x, 2) + std::pow(obstacle.twist.linear.y, 2)) /
p.pedestrian_deceleration_rate;

Check warning on line 1683 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_obstacle_cruise_planner/src/node.cpp#L1681-L1683

Added lines #L1681 - L1683 were not covered by tests
} else if (obstacle.classification.label == ObjectClassification::BICYCLE) {
resample_time_horizon =
std::sqrt(std::pow(obstacle.twist.linear.x, 2) + std::pow(obstacle.twist.linear.y, 2)) /
p.bicycle_deceleration_rate;

Check warning on line 1687 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_obstacle_cruise_planner/src/node.cpp#L1685-L1687

Added lines #L1685 - L1687 were not covered by tests
}

// Get the highest confidence predicted path
const auto resampled_predicted_paths = resampleHighestConfidencePredictedPaths(
obstacle.predicted_paths, p.prediction_resampling_time_interval,
p.prediction_resampling_time_horizon, p.num_of_predicted_paths_for_outside_stop_obstacle);
obstacle.predicted_paths, p.prediction_resampling_time_interval, resample_time_horizon,

Check warning on line 1692 in planning/autoware_obstacle_cruise_planner/src/node.cpp

View check run for this annotation

Codecov / codecov/patch

planning/autoware_obstacle_cruise_planner/src/node.cpp#L1692

Added line #L1692 was not covered by tests
p.num_of_predicted_paths_for_outside_stop_obstacle);
if (resampled_predicted_paths.empty()) {
return std::nullopt;
}
Expand Down

0 comments on commit 3b2e246

Please sign in to comment.