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(intersection): ignore high curvature lane occlusion #914

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -52,6 +52,8 @@
absence_traffic_light:
creep_velocity: 1.388 # [m/s]
maximum_peeking_distance: 6.0 # [m]
attention_lane_crop_curvature_threshold: 0.25
attention_lane_curvature_calculation_ds: 0.5

enable_rtc:
intersection: true # If set to true, the scene modules require approval from the rtc (request to cooperate) function. If set to false, the modules can be executed without requiring rtc approval
Expand Down
8 changes: 8 additions & 0 deletions planning/behavior_velocity_intersection_module/src/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ visualization_msgs::msg::MarkerArray IntersectionModule::createDebugMarkerArray(
&debug_marker_array);
}

if (debug_data_.occlusion_attention_area) {
appendMarkerArray(
createLaneletPolygonsMarkerArray(
debug_data_.occlusion_attention_area.value(), "occlusion_attention_area", lane_id_, 0.917,
0.568, 0.596),
&debug_marker_array);
}

if (debug_data_.adjacent_area) {
appendMarkerArray(
createLaneletPolygonsMarkerArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ IntersectionModuleManager::IntersectionModuleManager(rclcpp::Node & node)
node.declare_parameter<double>(ns + ".occlusion.absence_traffic_light.creep_velocity");
ip.occlusion.absence_traffic_light.maximum_peeking_distance = node.declare_parameter<double>(
ns + ".occlusion.absence_traffic_light.maximum_peeking_distance");
ip.occlusion.attention_lane_crop_curvature_threshold =
node.declare_parameter<double>(ns + ".occlusion.attention_lane_crop_curvature_threshold");
ip.occlusion.attention_lane_curvature_calculation_ds =
node.declare_parameter<double>(ns + ".occlusion.attention_lane_curvature_calculation_ds");
}

void IntersectionModuleManager::launchNewModules(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
const auto & occlusion_attention_lanelets = intersection_lanelets.occlusion_attention();
const auto & occlusion_attention_area = intersection_lanelets.occlusion_attention_area();
debug_data_.attention_area = intersection_lanelets.attention_area();
debug_data_.occlusion_attention_area = occlusion_attention_area;
debug_data_.adjacent_area = intersection_lanelets.adjacent_area();

// get intersection area
Expand Down Expand Up @@ -1013,7 +1014,9 @@ IntersectionModule::DecisionResult IntersectionModule::modifyPathVelocityDetail(
if (!occlusion_attention_divisions_) {
occlusion_attention_divisions_ = util::generateDetectionLaneDivisions(
occlusion_attention_lanelets, routing_graph_ptr,
planner_data_->occupancy_grid->info.resolution);
planner_data_->occupancy_grid->info.resolution,
planner_param_.occlusion.attention_lane_crop_curvature_threshold,
planner_param_.occlusion.attention_lane_curvature_calculation_ds);
}
const auto & occlusion_attention_divisions = occlusion_attention_divisions_.value();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class IntersectionModule : public SceneModuleInterface
double creep_velocity;
double maximum_peeking_distance;
} absence_traffic_light;
double attention_lane_crop_curvature_threshold;
double attention_lane_curvature_calculation_ds;
} occlusion;
};

Expand Down
42 changes: 40 additions & 2 deletions planning/behavior_velocity_intersection_module/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <behavior_velocity_planner_common/utilization/path_utilization.hpp>
#include <behavior_velocity_planner_common/utilization/trajectory_utils.hpp>
#include <behavior_velocity_planner_common/utilization/util.hpp>
#include <interpolation/spline_interpolation_points_2d.hpp>
#include <lanelet2_extension/regulatory_elements/road_marking.hpp>
#include <lanelet2_extension/utility/query.hpp>
#include <lanelet2_extension/utility/utilities.hpp>
Expand All @@ -40,6 +41,21 @@
#include <unordered_map>
#include <vector>

namespace tier4_autoware_utils
{

template <>
inline geometry_msgs::msg::Point getPoint(const lanelet::ConstPoint3d & p)
{
geometry_msgs::msg::Point point;
point.x = p.x();
point.y = p.y();
point.z = p.z();
return point;
}

} // namespace tier4_autoware_utils

namespace behavior_velocity_planner
{
namespace bg = boost::geometry;
Expand Down Expand Up @@ -804,10 +820,26 @@ bool isTrafficLightArrowActivated(
return false;
}

double getHighestCurvature(const lanelet::ConstLineString3d & centerline)
{
std::vector<lanelet::ConstPoint3d> points;
for (auto point = centerline.begin(); point != centerline.end(); point++) {
points.push_back(*point);
}

SplineInterpolationPoints2d interpolation(points);
const std::vector<double> curvatures = interpolation.getSplineInterpolatedCurvatures();
std::vector<double> curvatures_positive;
for (const auto & curvature : curvatures) {
curvatures_positive.push_back(std::fabs(curvature));
}
return *std::max_element(curvatures_positive.begin(), curvatures_positive.end());
}

std::vector<DescritizedLane> generateDetectionLaneDivisions(
lanelet::ConstLanelets detection_lanelets_all,
[[maybe_unused]] const lanelet::routing::RoutingGraphPtr routing_graph_ptr,
const double resolution)
const lanelet::routing::RoutingGraphPtr routing_graph_ptr, const double resolution,
const double curvature_threshold, const double curvature_calculation_ds)
{
using lanelet::utils::getCenterlineWithOffset;
using lanelet::utils::to2D;
Expand All @@ -819,6 +851,12 @@ std::vector<DescritizedLane> generateDetectionLaneDivisions(
if (turn_direction.compare("left") == 0 || turn_direction.compare("right") == 0) {
continue;
}
const auto fine_centerline =
lanelet::utils::generateFineCenterline(detection_lanelet, curvature_calculation_ds);
const double highest_curvature = getHighestCurvature(fine_centerline);
if (highest_curvature > curvature_threshold) {
continue;
}
detection_lanelets.push_back(detection_lanelet);
}

Expand Down
3 changes: 2 additions & 1 deletion planning/behavior_velocity_intersection_module/src/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ bool isTrafficLightArrowActivated(

std::vector<DescritizedLane> generateDetectionLaneDivisions(
lanelet::ConstLanelets detection_lanelets,
const lanelet::routing::RoutingGraphPtr routing_graph_ptr, const double resolution);
const lanelet::routing::RoutingGraphPtr routing_graph_ptr, const double resolution,
const double curvature_threshold, const double curvature_calculation_ds);

std::optional<InterpolatedPathInfo> generateInterpolatedPath(
const int lane_id, const std::set<int> & associative_lane_ids,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct DebugData
std::optional<geometry_msgs::msg::Pose> occlusion_first_stop_wall_pose{std::nullopt};
std::optional<geometry_msgs::msg::Pose> pass_judge_wall_pose{std::nullopt};
std::optional<std::vector<lanelet::CompoundPolygon3d>> attention_area{std::nullopt};
std::optional<std::vector<lanelet::CompoundPolygon3d>> occlusion_attention_area{std::nullopt};
std::optional<geometry_msgs::msg::Polygon> intersection_area{std::nullopt};
std::optional<lanelet::CompoundPolygon3d> ego_lane{std::nullopt};
std::optional<std::vector<lanelet::CompoundPolygon3d>> adjacent_area{std::nullopt};
Expand Down
Loading