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, blind_spot): add objects of interest marker #6201

Merged
merged 1 commit into from
Jan 29, 2024
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
4 changes: 3 additions & 1 deletion planning/behavior_velocity_blind_spot_module/src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,67 +348,69 @@
lanelet::LaneletMapConstPtr lanelet_map_ptr, lanelet::routing::RoutingGraphPtr routing_graph_ptr,
const autoware_auto_planning_msgs::msg::PathWithLaneId & path,
const autoware_auto_perception_msgs::msg::PredictedObjects::ConstSharedPtr objects_ptr,
const int closest_idx, const geometry_msgs::msg::Pose & stop_line_pose) const
const int closest_idx, const geometry_msgs::msg::Pose & stop_line_pose)
{
/* get detection area */
if (turn_direction_ == TurnDirection::INVALID) {
RCLCPP_WARN(logger_, "blind spot detector is running, turn_direction_ = not right or left.");
return false;
}

const auto areas_opt = generateBlindSpotPolygons(
lanelet_map_ptr, routing_graph_ptr, path, closest_idx, stop_line_pose);
if (areas_opt) {
const auto & detection_areas = areas_opt.value().detection_areas;
const auto & conflict_areas = areas_opt.value().conflict_areas;
const auto & opposite_detection_areas = areas_opt.value().opposite_detection_areas;
const auto & opposite_conflict_areas = areas_opt.value().opposite_conflict_areas;
debug_data_.detection_areas = detection_areas;
debug_data_.conflict_areas = conflict_areas;
debug_data_.detection_areas.insert(
debug_data_.detection_areas.end(), opposite_detection_areas.begin(),
opposite_detection_areas.end());
debug_data_.conflict_areas.insert(
debug_data_.conflict_areas.end(), opposite_conflict_areas.begin(),
opposite_conflict_areas.end());

autoware_auto_perception_msgs::msg::PredictedObjects objects = *objects_ptr;
cutPredictPathWithDuration(&objects, planner_param_.max_future_movement_time);

// check objects in blind spot areas
for (const auto & object : objects.objects) {
if (!isTargetObjectType(object)) {
continue;
}

// right direction
const bool exist_in_right_detection_area =
std::any_of(detection_areas.begin(), detection_areas.end(), [&object](const auto & area) {
return bg::within(
to_bg2d(object.kinematics.initial_pose_with_covariance.pose.position),
lanelet::utils::to2D(area));
});
// opposite direction
const bool exist_in_opposite_detection_area = std::any_of(
opposite_detection_areas.begin(), opposite_detection_areas.end(),
[&object](const auto & area) {
return bg::within(
to_bg2d(object.kinematics.initial_pose_with_covariance.pose.position),
lanelet::utils::to2D(area));
});
const bool exist_in_detection_area =
exist_in_right_detection_area || exist_in_opposite_detection_area;
if (!exist_in_detection_area) {
continue;
}
const bool exist_in_right_conflict_area =
isPredictedPathInArea(object, conflict_areas, planner_data_->current_odometry->pose);
const bool exist_in_opposite_conflict_area = isPredictedPathInArea(
object, opposite_conflict_areas, planner_data_->current_odometry->pose);
const bool exist_in_conflict_area =
exist_in_right_conflict_area || exist_in_opposite_conflict_area;
if (exist_in_detection_area && exist_in_conflict_area) {
debug_data_.conflicting_targets.objects.push_back(object);
setObjectsOfInterestData(
object.kinematics.initial_pose_with_covariance.pose, object.shape, ColorName::RED);

Check warning on line 413 in planning/behavior_velocity_blind_spot_module/src/scene.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Excess Number of Function Arguments

BlindSpotModule::checkObstacleInBlindSpot has 6 arguments, threshold = 4. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion planning/behavior_velocity_blind_spot_module/src/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BlindSpotModule : public SceneModuleInterface
lanelet::routing::RoutingGraphPtr routing_graph_ptr,
const autoware_auto_planning_msgs::msg::PathWithLaneId & path,
const autoware_auto_perception_msgs::msg::PredictedObjects::ConstSharedPtr objects_ptr,
const int closest_idx, const geometry_msgs::msg::Pose & stop_line_pose) const;
const int closest_idx, const geometry_msgs::msg::Pose & stop_line_pose);

/**
* @brief Create half lanelet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@
continue;
}
const auto & unsafe_info = object_info->is_unsafe().value();
setObjectsOfInterestData(
object_info->predicted_object().kinematics.initial_pose_with_covariance.pose,
object_info->predicted_object().shape, ColorName::RED);

Check notice on line 626 in planning/behavior_velocity_intersection_module/src/scene_intersection_collision.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Complex Method

IntersectionModule::detectCollision already has high cyclomatic complexity, and now it increases in Lines of Code from 81 to 84. 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.
// ==========================================================================================
// if ego is over the pass judge lines, then the visualization as "too_late_objects" or
// "misjudge_objects" is more important than that for "unsafe"
Expand Down Expand Up @@ -910,7 +913,7 @@
}
}
object_ttc_time_array.layout.dim.at(0).size++;
const auto & pos = object.kinematics.initial_pose_with_covariance.pose.position;
const auto & pos = object..position;
const auto & shape = object.shape;
object_ttc_time_array.data.insert(
object_ttc_time_array.data.end(),
Expand Down
Loading