Skip to content

Commit e553faa

Browse files
committed
feat(start_planner): check current_pose and estimated_stop_pose for isPreventingRearVehicleFromPassingThrough (autowarefoundation#8112)
1 parent bd9038c commit e553faa

File tree

3 files changed

+69
-5
lines changed

3 files changed

+69
-5
lines changed

planning/behavior_path_planner/autoware_behavior_path_start_planner_module/include/autoware/behavior_path_start_planner_module/data_structs.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ struct StartPlannerDebugData
9090
std::vector<Pose> start_pose_candidates;
9191
size_t selected_start_pose_candidate_index;
9292
double margin_for_start_pose_candidate;
93+
94+
// for isPreventingRearVehicleFromPassingThrough
95+
std::optional<Pose> estimated_stop_pose;
9396
};
9497

9598
struct StartPlannerParameters

planning/behavior_path_planner/autoware_behavior_path_start_planner_module/include/autoware/behavior_path_start_planner_module/start_planner_module.hpp

+23
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,31 @@ class StartPlannerModule : public SceneModuleInterface
229229

230230
bool isModuleRunning() const;
231231
bool isCurrentPoseOnMiddleOfTheRoad() const;
232+
233+
/**
234+
* @brief Check if the ego vehicle is preventing the rear vehicle from passing through.
235+
*
236+
* This function just call isPreventingRearVehicleFromPassingThrough(const Pose & ego_pose) with
237+
* two poses. If rear vehicle is obstructed by ego vehicle at either of the two poses, it returns
238+
* true.
239+
*
240+
* @return true if the ego vehicle is preventing the rear vehicle from passing through with the
241+
* current pose or the pose if it stops.
242+
*/
232243
bool isPreventingRearVehicleFromPassingThrough() const;
233244

245+
/**
246+
* @brief Check if the ego vehicle is preventing the rear vehicle from passing through.
247+
*
248+
* This function measures the distance to the lane boundary from the current pose and the pose if
249+
it stops, and determines whether there is enough space for the rear vehicle to pass through. If
250+
* it is obstructing at either of the two poses, it returns true.
251+
*
252+
* @return true if the ego vehicle is preventing the rear vehicle from passing through with given
253+
ego pose.
254+
*/
255+
bool isPreventingRearVehicleFromPassingThrough(const Pose & ego_pose) const;
256+
234257
bool isCloseToOriginalStartPose() const;
235258
bool hasArrivedAtGoal() const;
236259
bool isMoving() const;

planning/behavior_path_planner/autoware_behavior_path_start_planner_module/src/start_planner_module.cpp

+43-5
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,35 @@ bool StartPlannerModule::isCurrentPoseOnMiddleOfTheRoad() const
368368

369369
bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
370370
{
371+
// prepare poses for preventing check
372+
// - current_pose
373+
// - estimated_stop_pose (The position assumed when stopped with the minimum stop distance,
374+
// although it is NOT actually stopped)
371375
const auto & current_pose = planner_data_->self_odometry->pose.pose;
376+
std::vector<Pose> preventing_check_pose{current_pose};
377+
const auto min_stop_distance =
378+
autoware::behavior_path_planner::utils::parking_departure::calcFeasibleDecelDistance(
379+
planner_data_, parameters_->maximum_deceleration_for_stop, parameters_->maximum_jerk_for_stop,
380+
0.0);
381+
debug_data_.estimated_stop_pose.reset(); // debug
382+
if (min_stop_distance.has_value()) {
383+
const auto current_path = getCurrentPath();
384+
const auto estimated_stop_pose = calcLongitudinalOffsetPose(
385+
current_path.points, current_pose.position, min_stop_distance.value());
386+
if (estimated_stop_pose.has_value()) {
387+
preventing_check_pose.push_back(estimated_stop_pose.value());
388+
debug_data_.estimated_stop_pose = estimated_stop_pose.value(); // debug
389+
}
390+
}
391+
392+
// check if any of the preventing check poses are preventing rear vehicle from passing through
393+
return std::any_of(
394+
preventing_check_pose.begin(), preventing_check_pose.end(),
395+
[&](const auto & pose) { return isPreventingRearVehicleFromPassingThrough(pose); });
396+
}
397+
398+
bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough(const Pose & ego_pose) const
399+
{
372400
const auto & dynamic_object = planner_data_->dynamic_object;
373401
const auto & route_handler = planner_data_->route_handler;
374402
const Pose start_pose = planner_data_->route_handler->getOriginalStartPose();
@@ -414,8 +442,8 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
414442
geometry_msgs::msg::Pose & ego_overhang_point_as_pose,
415443
const bool ego_is_merging_from_the_left) -> std::optional<std::pair<double, double>> {
416444
const auto local_vehicle_footprint = vehicle_info_.createFootprint();
417-
const auto vehicle_footprint = transformVector(
418-
local_vehicle_footprint, autoware::universe_utils::pose2transform(current_pose));
445+
const auto vehicle_footprint =
446+
transformVector(local_vehicle_footprint, autoware::universe_utils::pose2transform(ego_pose));
419447
double smallest_lateral_gap_between_ego_and_border = std::numeric_limits<double>::max();
420448
double corresponding_lateral_gap_with_other_lane_bound = std::numeric_limits<double>::max();
421449

@@ -481,7 +509,7 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
481509
// Check backwards just in case the Vehicle behind ego is in a different lanelet
482510
constexpr double backwards_length = 200.0;
483511
const auto prev_lanes = autoware::behavior_path_planner::utils::getBackwardLanelets(
484-
*route_handler, target_lanes, current_pose, backwards_length);
512+
*route_handler, target_lanes, ego_pose, backwards_length);
485513
// return all the relevant lanelets
486514
lanelet::ConstLanelets relevant_lanelets{closest_lanelet_const};
487515
relevant_lanelets.insert(relevant_lanelets.end(), prev_lanes.begin(), prev_lanes.end());
@@ -491,7 +519,7 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
491519

492520
// filtering objects with velocity, position and class
493521
const auto filtered_objects = utils::path_safety_checker::filterObjects(
494-
dynamic_object, route_handler, relevant_lanelets.value(), current_pose.position,
522+
dynamic_object, route_handler, relevant_lanelets.value(), ego_pose.position,
495523
objects_filtering_params_);
496524
if (filtered_objects.objects.empty()) return false;
497525

@@ -508,7 +536,7 @@ bool StartPlannerModule::isPreventingRearVehicleFromPassingThrough() const
508536
target_objects_on_lane.on_current_lane.begin(), target_objects_on_lane.on_current_lane.end(),
509537
[&](const auto & o) {
510538
const auto arc_length = autoware::motion_utils::calcSignedArcLength(
511-
centerline_path.points, current_pose.position, o.initial_pose.pose.position);
539+
centerline_path.points, ego_pose.position, o.initial_pose.pose.position);
512540
if (arc_length > 0.0) return;
513541
if (std::abs(arc_length) >= std::abs(arc_length_to_closet_object)) return;
514542
arc_length_to_closet_object = arc_length;
@@ -1723,6 +1751,16 @@ void StartPlannerModule::setDebugData()
17231751
info_marker_);
17241752
add(showPolygon(debug_data_.collision_check, "ego_and_target_polygon_relation"), info_marker_);
17251753

1754+
// visualize estimated_stop_pose for isPreventingRearVehicleFromPassingThrough()
1755+
if (debug_data_.estimated_stop_pose.has_value()) {
1756+
auto footprint_marker = createDefaultMarker(
1757+
"map", rclcpp::Clock{RCL_ROS_TIME}.now(), "estimated_stop_pose", 0, Marker::LINE_STRIP,
1758+
createMarkerScale(0.2, 0.2, 0.2), purple_color);
1759+
footprint_marker.lifetime = rclcpp::Duration::from_seconds(1.5);
1760+
addFootprintMarker(footprint_marker, debug_data_.estimated_stop_pose.value(), vehicle_info_);
1761+
debug_marker_.markers.push_back(footprint_marker);
1762+
}
1763+
17261764
// set objects of interest
17271765
for (const auto & [uuid, data] : debug_data_.collision_check) {
17281766
const auto color = data.is_safe ? ColorName::GREEN : ColorName::RED;

0 commit comments

Comments
 (0)