Skip to content

Commit eef62cd

Browse files
authored
feat(crosswalk_module): consider objects on crosswalk when pedestrian traffic light is red (#10332)
Signed-off-by: Mehmet Dogru <42mehmetdogru42@gmail.com>
1 parent 986ee78 commit eef62cd

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

planning/behavior_velocity_planner/autoware_behavior_velocity_crosswalk_module/config/crosswalk.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
ego_pass_later_additional_margin: 0.5 # [s] additional time margin for object pass first situation to suppress chattering
4747
ego_min_assumed_speed: 2.0 # [m/s] assumed speed to calculate the time to collision point
4848

49+
consider_obj_on_crosswalk_on_red_light: true # consider and do not ignore objects if they are on the crosswalk when the crosswalk pedestrian traffic light is red
50+
4951
no_stop_decision: # parameters to determine stop cancel. {-$overrun_threshold_length + f($min_acc, $min_jerk)} is compared against distance to stop pose.
5052
min_acc: -1.5 # min acceleration [m/ss]
5153
min_jerk: -1.5 # min jerk [m/sss]

planning/behavior_velocity_planner/autoware_behavior_velocity_crosswalk_module/src/manager.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ CrosswalkModuleManager::CrosswalkModuleManager(rclcpp::Node & node)
106106
get_or_declare_parameter<double>(node, ns + ".pass_judge.ego_pass_later_additional_margin");
107107
cp.ego_min_assumed_speed =
108108
get_or_declare_parameter<double>(node, ns + ".pass_judge.ego_min_assumed_speed");
109+
cp.consider_obj_on_crosswalk_on_red_light =
110+
get_or_declare_parameter<bool>(node, ns + ".pass_judge.consider_obj_on_crosswalk_on_red_light");
109111
cp.min_acc_for_no_stop_decision =
110112
get_or_declare_parameter<double>(node, ns + ".pass_judge.no_stop_decision.min_acc");
111113
cp.min_jerk_for_no_stop_decision =

planning/behavior_velocity_planner/autoware_behavior_velocity_crosswalk_module/src/scene_crosswalk.cpp

+25-12
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ void CrosswalkModule::updateObjectState(
11121112
const double dist_ego_to_stop, const PathWithLaneId & sparse_resample_path,
11131113
const std::pair<double, double> & crosswalk_attention_range, const Polygon2d & attention_area)
11141114
{
1115+
const auto & p = planner_param_;
11151116
const auto & objects_ptr = planner_data_->predicted_objects;
11161117

11171118
const auto traffic_lights_reg_elems =
@@ -1120,37 +1121,48 @@ void CrosswalkModule::updateObjectState(
11201121

11211122
// Check if ego is yielding
11221123
const bool is_ego_yielding = [&]() {
1123-
const auto has_reached_stop_point = dist_ego_to_stop < planner_param_.stop_position_threshold;
1124+
const auto has_reached_stop_point = dist_ego_to_stop < p.stop_position_threshold;
11241125

1125-
return planner_data_->isVehicleStopped(planner_param_.timeout_ego_stop_for_yield) &&
1126-
has_reached_stop_point;
1126+
return planner_data_->isVehicleStopped(p.timeout_ego_stop_for_yield) && has_reached_stop_point;
11271127
}();
11281128

1129-
const auto ignore_crosswalk = isRedSignalForPedestrians();
1130-
debug_data_.ignore_crosswalk = ignore_crosswalk;
1129+
const auto is_red_signal_for_pedestrians = isRedSignalForPedestrians();
1130+
auto ignore_crosswalk = is_red_signal_for_pedestrians;
11311131

11321132
// Update object state
11331133
object_info_manager_.init();
11341134
for (const auto & object : objects_ptr->objects) {
1135-
const auto obj_uuid = to_hex_string(object.object_id);
1136-
const auto & obj_pos = object.kinematics.initial_pose_with_covariance.pose.position;
1137-
const auto & obj_vel = object.kinematics.initial_twist_with_covariance.twist.linear;
1138-
1139-
// calculate collision point and state
11401135
if (!isCrosswalkUserType(object)) {
11411136
continue;
11421137
}
1143-
if (ignore_crosswalk) {
1138+
1139+
auto ignore_obj = is_red_signal_for_pedestrians;
1140+
if (p.consider_obj_on_crosswalk_on_red_light && is_red_signal_for_pedestrians) {
1141+
const auto is_object_on_crosswalk =
1142+
bg::intersects(autoware_utils::to_polygon2d(object), crosswalk_.polygon2d().basicPolygon());
1143+
1144+
if (is_object_on_crosswalk) {
1145+
ignore_obj = false;
1146+
ignore_crosswalk = false;
1147+
}
1148+
}
1149+
1150+
if (ignore_obj) {
11441151
continue;
11451152
}
11461153

1154+
const auto obj_uuid = to_hex_string(object.object_id);
1155+
const auto & obj_pos = object.kinematics.initial_pose_with_covariance.pose.position;
1156+
const auto & obj_vel = object.kinematics.initial_twist_with_covariance.twist.linear;
1157+
1158+
// calculate collision point and state
11471159
const auto collision_point =
11481160
getCollisionPoint(sparse_resample_path, object, crosswalk_attention_range, attention_area);
11491161
const std::optional<double> ego_crosswalk_passage_direction =
11501162
findEgoPassageDirectionAlongPath(sparse_resample_path);
11511163
object_info_manager_.update(
11521164
obj_uuid, obj_pos, std::hypot(obj_vel.x, obj_vel.y), clock_->now(), is_ego_yielding,
1153-
has_traffic_light, collision_point, object.classification.front().label, planner_param_,
1165+
has_traffic_light, collision_point, object.classification.front().label, p,
11541166
crosswalk_.polygon2d().basicPolygon(), attention_area, ego_crosswalk_passage_direction);
11551167

11561168
const auto collision_state = object_info_manager_.getCollisionState(obj_uuid);
@@ -1178,6 +1190,7 @@ void CrosswalkModule::updateObjectState(
11781190
getLabelColor(collision_state));
11791191
}
11801192

1193+
debug_data_.ignore_crosswalk = ignore_crosswalk;
11811194
object_info_manager_.finalize();
11821195
}
11831196

planning/behavior_velocity_planner/autoware_behavior_velocity_crosswalk_module/src/scene_crosswalk.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class CrosswalkModule : public SceneModuleInterfaceWithRTC
149149
std::vector<double> ego_pass_later_margin_y;
150150
double ego_pass_later_additional_margin;
151151
double ego_min_assumed_speed;
152+
bool consider_obj_on_crosswalk_on_red_light;
152153
double min_acc_for_no_stop_decision;
153154
double min_jerk_for_no_stop_decision;
154155
double overrun_threshold_length_for_no_stop_decision;

0 commit comments

Comments
 (0)