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

fix(start_planner): publish stop path when goal is behind from ego #4214

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ class StartPlannerModule : public SceneModuleInterface
bool isStopped();
bool hasFinishedCurrentPath();

// check if the goal is located behind the ego in the same route segment.
bool IsGoalBehindOfEgoInSameRouteSegment() const;

// generate BehaviorPathOutput with stopping path.
BehaviorModuleOutput generateStopOutput() const;

void setDebugData() const;
};
} // namespace behavior_path_planner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ ModuleStatus StartPlannerModule::updateState()

BehaviorModuleOutput StartPlannerModule::plan()
{
if (IsGoalBehindOfEgoInSameRouteSegment()) {
RCLCPP_WARN_THROTTLE(
getLogger(), *clock_, 5000, "Start plan for a backward goal is not supported now");
return generateStopOutput();
}

if (isWaitingApproval()) {
clearWaitingApproval();
resetPathCandidate();
Expand Down Expand Up @@ -294,6 +300,12 @@ BehaviorModuleOutput StartPlannerModule::planWaitingApproval()
updatePullOutStatus();
waitApproval();

if (IsGoalBehindOfEgoInSameRouteSegment()) {
RCLCPP_WARN_THROTTLE(
getLogger(), *clock_, 5000, "Start plan for a backward goal is not supported now");
return generateStopOutput();
}

BehaviorModuleOutput output;
if (!status_.is_safe) {
RCLCPP_WARN_THROTTLE(
Expand Down Expand Up @@ -832,6 +844,46 @@ TurnSignalInfo StartPlannerModule::calcTurnSignalInfo() const
return turn_signal;
}

bool StartPlannerModule::IsGoalBehindOfEgoInSameRouteSegment() const
{
const auto & rh = planner_data_->route_handler;

// Check if the goal and ego are in the same route segment. If not, this is out of scope of this
// function. Return false.
lanelet::ConstLanelet ego_lanelet;
rh->getClosestLaneletWithinRoute(getEgoPose(), &ego_lanelet);
const auto is_ego_in_goal_route_section = rh->isInGoalRouteSection(ego_lanelet);

if (!is_ego_in_goal_route_section) {
return false;
}

// If the goal and ego are in the same route segment, check the goal and ego pose relation.
// Return true when the goal is located behind of ego.
const auto ego_lane_path = rh->getCenterLinePath(
lanelet::ConstLanelets{ego_lanelet}, 0.0, std::numeric_limits<double>::max());
const auto dist_ego_to_goal = motion_utils::calcSignedArcLength(
ego_lane_path.points, getEgoPosition(), rh->getGoalPose().position);

const bool is_goal_behind_of_ego = (dist_ego_to_goal < 0.0);
return is_goal_behind_of_ego;
}

// NOTE: this must be called after updatePullOutStatus(). This must be fixed.
BehaviorModuleOutput StartPlannerModule::generateStopOutput() const
{
BehaviorModuleOutput output;
output.path = std::make_shared<PathWithLaneId>(generateStopPath());

DrivableAreaInfo current_drivable_area_info;
current_drivable_area_info.drivable_lanes = status_.lanes;
output.drivable_area_info = utils::combineDrivableAreaInfo(
current_drivable_area_info, getPreviousModuleOutput().drivable_area_info);

output.reference_path = getPreviousModuleOutput().reference_path;
return output;
}

void StartPlannerModule::setDebugData() const
{
using marker_utils::createPathMarkerArray;
Expand Down