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(crosswalk): add option to slowdown at occluded crosswalks #6122

Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
800457f
Add barebone function to add virtual occluded object
maxime-clem Dec 18, 2023
0f8b6f6
Switching to a simpler slowdown based approach
maxime-clem Jan 16, 2024
397196c
add detection areas at the front&back of the crosswalk
maxime-clem Jan 16, 2024
85179bb
Improve time buffer
maxime-clem Jan 17, 2024
0ff684e
Comment out SVG debug code
maxime-clem Jan 17, 2024
baa4eef
Check that ego did not already pass the crosswalk
maxime-clem Jan 18, 2024
99e688f
Add ROS params
maxime-clem Jan 19, 2024
aecd605
Split hpp/cpp
maxime-clem Jan 19, 2024
67f17b9
Add docstring
maxime-clem Jan 19, 2024
39c5861
Small refactor (point2d,point2d) -> segment2d
maxime-clem Jan 19, 2024
cfe7113
Remove svg code
maxime-clem Jan 19, 2024
18d726b
Refactor timers
maxime-clem Jan 19, 2024
fd7633e
Calculate the detection range based on the distance from the crosswalk
maxime-clem Jan 22, 2024
d736dab
Add option to ignore crosswalk with traffic light + apply max decel/jerk
maxime-clem Jan 22, 2024
830ee7e
Small refactor
maxime-clem Jan 23, 2024
610496c
[WIP] option to ignore occlusions behind predicted objects
maxime-clem Jan 23, 2024
882927c
[DEBUG] launch behavior_velocity_planner in gdb+konsole
maxime-clem Jan 24, 2024
6c2e993
Fix masking behind predicted objects
maxime-clem Jan 24, 2024
65687bd
Revert "[DEBUG] launch behavior_velocity_planner in gdb+konsole"
maxime-clem Jan 24, 2024
0622e47
pre-commit
maxime-clem Jan 24, 2024
891dc96
Refactor and add param to NOT ignore behind pedestrians
maxime-clem Jan 26, 2024
ea4193b
Change params to set the ignore vel threshold for each label
maxime-clem Jan 26, 2024
5a8901b
rename param
maxime-clem Jan 29, 2024
20736ad
fix timer
maxime-clem Feb 2, 2024
b681fe7
add ego lateral offset to detection range
maxime-clem Feb 2, 2024
f48deca
ignore occlusions only if the traffic light is red
maxime-clem Feb 3, 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
Prev Previous commit
Next Next commit
Small refactor
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
maxime-clem committed Feb 19, 2024
commit 830ee7e0a0385cd43c9d2b6ddd601794ef0e6a4c
Original file line number Diff line number Diff line change
@@ -61,26 +61,19 @@ bool is_crosswalk_ignored(
return (ignore_with_traffic_light && has_traffic_light) || has_skip_attribute;
}

bool is_crosswalk_occluded(
const lanelet::ConstLanelet & crosswalk_lanelet,
const nav_msgs::msg::OccupancyGrid & occupancy_grid,
const geometry_msgs::msg::Point & path_intersection, const double detection_range,
const behavior_velocity_planner::CrosswalkModule::PlannerParam & params)
std::vector<lanelet::BasicPolygon2d> calculate_detection_areas(
const lanelet::ConstLanelet & crosswalk_lanelet, const lanelet::BasicPoint2d & crosswalk_origin,
const double detection_range)
{
grid_map::GridMap grid_map;
grid_map::GridMapRosConverter::fromOccupancyGrid(occupancy_grid, "layer", grid_map);
const lanelet::BasicPoint2d path_inter(path_intersection.x, path_intersection.y);

const auto min_nb_of_cells = std::ceil(params.occlusion_min_size / grid_map.getResolution());
std::vector<lanelet::BasicPolygon2d> incoming_areas;
std::vector<lanelet::BasicPolygon2d> detection_areas = {
crosswalk_lanelet.polygon2d().basicPolygon()};
const std::vector<std::function<lanelet::BasicSegment2d(lanelet::ConstLineString2d)>>
segment_getters = {
[](const auto & ls) -> lanelet::BasicSegment2d {
return {ls[1].basicPoint2d(), ls[0].basicPoint2d()};
},
[](const auto & ls) -> lanelet::BasicSegment2d {
const auto size = ls.size();
return {ls[size - 2].basicPoint2d(), ls[size - 1].basicPoint2d()};
return {ls[ls.size() - 2].basicPoint2d(), ls[ls.size() - 1].basicPoint2d()};
}};
if (
crosswalk_lanelet.centerline2d().size() > 1 && crosswalk_lanelet.leftBound2d().size() > 1 &&
@@ -89,19 +82,32 @@ bool is_crosswalk_occluded(
const auto center_segment = segment_getter(crosswalk_lanelet.centerline2d());
const auto left_segment = segment_getter(crosswalk_lanelet.leftBound2d());
const auto right_segment = segment_getter(crosswalk_lanelet.rightBound2d());
const auto dist = lanelet::geometry::distance2d(center_segment.second, path_inter);
const auto dist = lanelet::geometry::distance2d(center_segment.second, crosswalk_origin);
if (dist < detection_range) {
const auto target_left = interpolate_point(left_segment, detection_range - dist);
const auto target_right = interpolate_point(right_segment, detection_range - dist);
incoming_areas.push_back(
detection_areas.push_back(
{left_segment.second, target_left, target_right, right_segment.second});
}
}
}
incoming_areas.push_back(crosswalk_lanelet.polygon2d().basicPolygon());
for (const auto & incoming_area : incoming_areas) {
return detection_areas;
}

bool is_crosswalk_occluded(
const lanelet::ConstLanelet & crosswalk_lanelet,
const nav_msgs::msg::OccupancyGrid & occupancy_grid,
const geometry_msgs::msg::Point & path_intersection, const double detection_range,
const behavior_velocity_planner::CrosswalkModule::PlannerParam & params)
{
grid_map::GridMap grid_map;
grid_map::GridMapRosConverter::fromOccupancyGrid(occupancy_grid, "layer", grid_map);

const auto min_nb_of_cells = std::ceil(params.occlusion_min_size / grid_map.getResolution());
for (const auto & detection_area : calculate_detection_areas(
crosswalk_lanelet, {path_intersection.x, path_intersection.y}, detection_range)) {
grid_map::Polygon poly;
for (const auto & p : incoming_area) poly.addVertex(grid_map::Position(p.x(), p.y()));
for (const auto & p : detection_area) poly.addVertex(grid_map::Position(p.x(), p.y()));
for (grid_map_utils::PolygonIterator iter(grid_map, poly); !iter.isPastEnd(); ++iter)
if (is_occluded(grid_map, min_nb_of_cells, *iter, params)) return true;
}