Skip to content

Commit a49ede7

Browse files
feat(crosswalk)!: improve stuck prevention on crosswalk (#6150)
* improve algorithm * sync param Signed-off-by: Yuki Takagi <yuki.takagi@tier4.jp>
1 parent 98f2a71 commit a49ede7

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

planning/behavior_velocity_crosswalk_module/config/crosswalk.param.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
enable_stuck_check_in_intersection: false # [-] flag to enable stuck vehicle checking for crosswalk which is in intersection
3131
stuck_vehicle_velocity: 1.0 # [m/s] threshold velocity whether other vehicles are assumed to be stuck or not.
3232
max_stuck_vehicle_lateral_offset: 2.0 # [m] The feature does not handle the vehicles farther than this value to the ego's path.
33-
stuck_vehicle_attention_range: 10.0 # [m] Ego does not enter the crosswalk area if a stuck vehicle exists within this distance from the end of the crosswalk on the ego's path.
33+
required_clearance: 6.0 # [m] clearance to be secured between the ego and the ahead vehicle
3434
min_acc: -1.0 # min acceleration [m/ss]
3535
min_jerk: -1.0 # min jerk [m/sss]
3636
max_jerk: 1.0 # max jerk [m/sss]

planning/behavior_velocity_crosswalk_module/src/manager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ CrosswalkModuleManager::CrosswalkModuleManager(rclcpp::Node & node)
6868
getOrDeclareParameter<double>(node, ns + ".stuck_vehicle.stuck_vehicle_velocity");
6969
cp.max_stuck_vehicle_lateral_offset =
7070
getOrDeclareParameter<double>(node, ns + ".stuck_vehicle.max_stuck_vehicle_lateral_offset");
71-
cp.stuck_vehicle_attention_range =
72-
getOrDeclareParameter<double>(node, ns + ".stuck_vehicle.stuck_vehicle_attention_range");
71+
cp.required_clearance =
72+
getOrDeclareParameter<double>(node, ns + ".stuck_vehicle.required_clearance");
7373
cp.min_acc_for_stuck_vehicle = getOrDeclareParameter<double>(node, ns + ".stuck_vehicle.min_acc");
7474
cp.max_jerk_for_stuck_vehicle =
7575
getOrDeclareParameter<double>(node, ns + ".stuck_vehicle.max_jerk");

planning/behavior_velocity_crosswalk_module/src/scene_crosswalk.cpp

+27-27
Original file line numberDiff line numberDiff line change
@@ -906,48 +906,48 @@ std::optional<StopFactor> CrosswalkModule::checkStopForStuckVehicles(
906906
continue;
907907
}
908908

909-
const auto & obj_pos = object.kinematics.initial_pose_with_covariance.pose.position;
910-
const auto lateral_offset = calcLateralOffset(ego_path.points, obj_pos);
909+
const auto & obj_pose = object.kinematics.initial_pose_with_covariance.pose;
910+
const auto lateral_offset = calcLateralOffset(ego_path.points, obj_pose.position);
911911
if (p.max_stuck_vehicle_lateral_offset < std::abs(lateral_offset)) {
912912
continue;
913913
}
914914

915-
const auto & ego_pos = planner_data_->current_odometry->pose.position;
916-
const auto ego_vel = planner_data_->current_velocity->twist.linear.x;
917-
const auto ego_acc = planner_data_->current_acceleration->accel.accel.linear.x;
918-
919-
const double near_attention_range =
920-
calcSignedArcLength(ego_path.points, ego_pos, path_intersects.back());
921-
const double far_attention_range = near_attention_range + p.stuck_vehicle_attention_range;
922-
923-
const auto dist_ego2obj = calcSignedArcLength(ego_path.points, ego_pos, obj_pos);
924-
925-
if (near_attention_range < dist_ego2obj && dist_ego2obj < far_attention_range) {
926-
// Plan STOP considering min_acc, max_jerk and min_jerk.
927-
const auto min_feasible_dist_ego2stop = calcDecelDistWithJerkAndAccConstraints(
928-
ego_vel, 0.0, ego_acc, p.min_acc_for_stuck_vehicle, p.max_jerk_for_stuck_vehicle,
929-
p.min_jerk_for_stuck_vehicle);
930-
if (!min_feasible_dist_ego2stop) {
931-
continue;
915+
// check if STOP is required
916+
const double crosswalk_front_to_obj_rear =
917+
calcSignedArcLength(ego_path.points, path_intersects.front(), obj_pose.position) -
918+
object.shape.dimensions.x / 2.0;
919+
const double crosswalk_back_to_obj_rear =
920+
calcSignedArcLength(ego_path.points, path_intersects.back(), obj_pose.position) -
921+
object.shape.dimensions.x / 2.0;
922+
const double required_space_length =
923+
planner_data_->vehicle_info_.vehicle_length_m + planner_param_.required_clearance;
924+
925+
if (crosswalk_front_to_obj_rear > 0.0 && crosswalk_back_to_obj_rear < required_space_length) {
926+
// If there exists at least one vehicle ahead, plan STOP considering min_acc, max_jerk and
927+
// min_jerk. Note that nearest search is not required because the stop pose independents to
928+
// the vehicles.
929+
const auto braking_distance = calcDecelDistWithJerkAndAccConstraints(
930+
planner_data_->current_velocity->twist.linear.x, 0.0,
931+
planner_data_->current_acceleration->accel.accel.linear.x, p.min_acc_for_stuck_vehicle,
932+
p.max_jerk_for_stuck_vehicle, p.min_jerk_for_stuck_vehicle);
933+
if (!braking_distance) {
934+
return {};
932935
}
933936

937+
const auto & ego_pos = planner_data_->current_odometry->pose.position;
934938
const double dist_ego2stop =
935939
calcSignedArcLength(ego_path.points, ego_pos, stop_pose->position);
936-
const double feasible_dist_ego2stop = std::max(*min_feasible_dist_ego2stop, dist_ego2stop);
940+
const double feasible_dist_ego2stop = std::max(*braking_distance, dist_ego2stop);
937941
const double dist_to_ego =
938942
calcSignedArcLength(ego_path.points, ego_path.points.front().point.pose.position, ego_pos);
939-
940943
const auto feasible_stop_pose =
941944
calcLongitudinalOffsetPose(ego_path.points, 0, dist_to_ego + feasible_dist_ego2stop);
942945
if (!feasible_stop_pose) {
943-
continue;
946+
return {};
944947
}
945948

946-
setObjectsOfInterestData(
947-
object.kinematics.initial_pose_with_covariance.pose, object.shape, ColorName::RED);
948-
949-
// early return may not appropriate because the nearest in range object should be handled
950-
return createStopFactor(*feasible_stop_pose, {obj_pos});
949+
setObjectsOfInterestData(obj_pose, object.shape, ColorName::RED);
950+
return createStopFactor(*feasible_stop_pose, {obj_pose.position});
951951
}
952952
}
953953

planning/behavior_velocity_crosswalk_module/src/scene_crosswalk.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class CrosswalkModule : public SceneModuleInterface
124124
bool enable_stuck_check_in_intersection{false};
125125
double stuck_vehicle_velocity;
126126
double max_stuck_vehicle_lateral_offset;
127-
double stuck_vehicle_attention_range;
127+
double required_clearance;
128128
double min_acc_for_stuck_vehicle;
129129
double max_jerk_for_stuck_vehicle;
130130
double min_jerk_for_stuck_vehicle;

0 commit comments

Comments
 (0)