Skip to content

Commit a92322e

Browse files
committed
[WIP] option to ignore occlusions behind predicted objects
Signed-off-by: Maxime CLEMENT <maxime.clement@tier4.jp>
1 parent e2a6bb6 commit a92322e

File tree

6 files changed

+54
-5
lines changed

6 files changed

+54
-5
lines changed

planning/behavior_velocity_crosswalk_module/config/crosswalk.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,5 @@
8080
free_space_max: 43 # [-] maximum value of a free space cell in the occupancy grid
8181
occupied_min: 58 # [-] minimum value of an occupied cell in the occupancy grid
8282
ignore_with_traffic_light: true # [-] if true, occlusions at crosswalks with traffic lights are ignored
83+
ignore_behind_predicted_objects: true # [-] if true, occlusions behind predicted objects are ignored
84+
min_objects_velocity: 0.5 # [m/s] minimum velocity for a predicted object to be ignored

planning/behavior_velocity_crosswalk_module/src/manager.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ CrosswalkModuleManager::CrosswalkModuleManager(rclcpp::Node & node)
138138
cp.occlusion_occupied_min = getOrDeclareParameter<int>(node, ns + ".occlusion.occupied_min");
139139
cp.occlusion_ignore_with_traffic_light =
140140
getOrDeclareParameter<bool>(node, ns + ".occlusion.ignore_with_traffic_light");
141+
cp.occlusion_ignore_behind_predicted_objects =
142+
getOrDeclareParameter<bool>(node, ns + ".occlusion.ignore_behind_predicted_objects");
143+
cp.occlusion_min_objects_velocity =
144+
getOrDeclareParameter<double>(node, ns + ".occlusion.min_objects_velocity");
141145
}
142146

143147
void CrosswalkModuleManager::launchNewModules(const PathWithLaneId & path)

planning/behavior_velocity_crosswalk_module/src/occluded_crosswalk.cpp

+35-2
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,47 @@ std::vector<lanelet::BasicPolygon2d> calculate_detection_areas(
9494
return detection_areas;
9595
}
9696

97+
void clear_behind_objects(
98+
grid_map::GridMap & grid_map,
99+
const std::vector<autoware_auto_perception_msgs::msg::PredictedObject> & objects,
100+
const double min_object_velocity)
101+
{
102+
const lanelet::BasicPoint2d grid_map_position = grid_map.getPosition();
103+
const auto range = grid_map.getLength().maxCoeff() / 2.0;
104+
for (const auto & object : objects) {
105+
const lanelet::BasicPoint2d object_position = {
106+
object.kinematics.initial_pose_with_covariance.pose.position.x,
107+
object.kinematics.initial_pose_with_covariance.pose.position.y};
108+
if (
109+
object.kinematics.initial_twist_with_covariance.twist.linear.x >= min_object_velocity &&
110+
lanelet::geometry::distance2d(grid_map_position, object_position) < range) {
111+
lanelet::BasicPoints2d points;
112+
for (const auto & edge_point : tier4_autoware_utils::toPolygon2d(object).outer())
113+
points.push_back(edge_point);
114+
for (const auto & edge_point : tier4_autoware_utils::toPolygon2d(object).outer())
115+
points.push_back(interpolate_point({object_position, edge_point}, range));
116+
lanelet::BasicPolygon2d polygon_behind_object;
117+
boost::geometry::convex_hull(points, polygon_behind_object);
118+
grid_map::Polygon polygon_to_clear;
119+
for (const auto & p : polygon_behind_object) polygon_to_clear.addVertex(p);
120+
for (grid_map_utils::PolygonIterator it(grid_map, polygon_to_clear); !it.isPastEnd(); ++it)
121+
grid_map.at("layer", *it) = 0;
122+
}
123+
}
124+
}
125+
97126
bool is_crosswalk_occluded(
98127
const lanelet::ConstLanelet & crosswalk_lanelet,
99128
const nav_msgs::msg::OccupancyGrid & occupancy_grid,
100129
const geometry_msgs::msg::Point & path_intersection, const double detection_range,
130+
const std::vector<autoware_auto_perception_msgs::msg::PredictedObject> & dynamic_objects,
101131
const behavior_velocity_planner::CrosswalkModule::PlannerParam & params)
102132
{
103133
grid_map::GridMap grid_map;
104134
grid_map::GridMapRosConverter::fromOccupancyGrid(occupancy_grid, "layer", grid_map);
105135

136+
if (params.occlusion_ignore_behind_predicted_objects)
137+
clear_behind_objects(grid_map, dynamic_objects, params.occlusion_min_objects_velocity);
106138
const auto min_nb_of_cells = std::ceil(params.occlusion_min_size / grid_map.getResolution());
107139
for (const auto & detection_area : calculate_detection_areas(
108140
crosswalk_lanelet, {path_intersection.x, path_intersection.y}, detection_range)) {
@@ -115,11 +147,12 @@ bool is_crosswalk_occluded(
115147
}
116148

117149
double calculate_detection_range(
118-
const double object_velocity, const double dist_ego_to_crosswalk, const double ego_velocity)
150+
const double occluded_object_velocity, const double dist_ego_to_crosswalk,
151+
const double ego_velocity)
119152
{
120153
constexpr double min_ego_velocity = 1.0;
121154
const auto time_to_crosswalk = dist_ego_to_crosswalk / std::max(min_ego_velocity, ego_velocity);
122-
return time_to_crosswalk > 0.0 ? time_to_crosswalk / object_velocity : 20.0;
155+
return time_to_crosswalk > 0.0 ? time_to_crosswalk / occluded_object_velocity : 20.0;
123156
}
124157

125158
void update_occlusion_timers(

planning/behavior_velocity_crosswalk_module/src/occluded_crosswalk.hpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <lanelet2_core/primitives/Point.h>
2828

2929
#include <optional>
30+
#include <vector>
3031

3132
namespace behavior_velocity_planner
3233
{
@@ -60,16 +61,23 @@ bool is_crosswalk_ignored(
6061
/// @param occupancy_grid occupancy grid with the occlusion information
6162
/// @param path_intersection intersection between the crosswalk and the ego path
6263
/// @param detection_range range away from the crosswalk until occlusions are considered
64+
/// @param dynamic_objects dynamic objects
6365
/// @param params parameters
6466
/// @return true if the crosswalk is occluded
6567
bool is_crosswalk_occluded(
6668
const lanelet::ConstLanelet & crosswalk_lanelet,
6769
const nav_msgs::msg::OccupancyGrid & occupancy_grid,
6870
const geometry_msgs::msg::Point & path_intersection, const double detection_range,
71+
const std::vector<autoware_auto_perception_msgs::msg::PredictedObject> & dynamic_objects,
6972
const behavior_velocity_planner::CrosswalkModule::PlannerParam & params);
7073

74+
/// @brief calculate the distance away from the crosswalk that should be checked for occlusions
75+
/// @param occluded_objects_velocity assumed velocity of the objects coming out of occlusions
76+
/// @param dist_ego_to_crosswalk distance between ego and the crosswalk
77+
/// @param ego_velocity current velocity of ego
7178
double calculate_detection_range(
72-
const double object_velocity, const double dist_ego_to_crosswalk, const double ego_velocity);
79+
const double occluded_object_velocity, const double dist_ego_to_crosswalk,
80+
const double ego_velocity);
7381

7482
/// @brief update timers so that the slowdown activates if the initial time is older than the buffer
7583
/// @param initial_time initial time

planning/behavior_velocity_crosswalk_module/src/scene_crosswalk.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,14 @@ bool CrosswalkModule::modifyPathVelocity(PathWithLaneId * path, StopReason * sto
241241
const auto dist_ego_to_crosswalk =
242242
calcSignedArcLength(path->points, ego_pos, path_intersects.front());
243243
const auto detection_range = calculate_detection_range(
244-
planner_param_.min_object_velocity, dist_ego_to_crosswalk,
244+
planner_param_.occlusion_occluded_object_velocity, dist_ego_to_crosswalk,
245245
planner_data_->current_velocity->twist.linear.x);
246246
const auto is_ego_on_the_crosswalk =
247247
dist_ego_to_crosswalk <= planner_data_->vehicle_info_.max_longitudinal_offset_m;
248248
if (!is_ego_on_the_crosswalk) {
249249
if (is_crosswalk_occluded(
250250
crosswalk_, *planner_data_->occupancy_grid, path_intersects.front(), detection_range,
251-
planner_param_))
251+
objects_ptr->objects, planner_param_))
252252
update_occlusion_timers(
253253
current_initial_occlusion_time_, most_recent_occlusion_time_, clock_->now(),
254254
planner_param_.occlusion_time_buffer);

planning/behavior_velocity_crosswalk_module/src/scene_crosswalk.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ class CrosswalkModule : public SceneModuleInterface
164164
int occlusion_free_space_max;
165165
int occlusion_occupied_min;
166166
bool occlusion_ignore_with_traffic_light;
167+
bool occlusion_ignore_behind_predicted_objects;
168+
double occlusion_min_objects_velocity;
167169
};
168170

169171
struct ObjectInfo

0 commit comments

Comments
 (0)