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(lane_change): stop point activated too early (#5402) #1037

Closed
wants to merge 1 commit into from
Closed
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 @@ -218,6 +218,23 @@ void NormalLaneChange::insertStopPoint(
const auto target_objects = getTargetObjects(status_.current_lanes, status_.target_lanes);
double stopping_distance = distance_to_terminal - lane_change_buffer - stop_point_buffer;

const auto is_valid_start_point = std::invoke([&]() -> bool {
auto lc_start_point = lanelet::utils::conversion::toLaneletPoint(
status_.lane_change_path.info.lane_changing_start.position);
const auto target_neighbor_preferred_lane_poly_2d =
utils::lane_change::getTargetNeighborLanesPolygon(
*route_handler, status_.current_lanes, type_);
return boost::geometry::covered_by(
lanelet::traits::to2D(lc_start_point), target_neighbor_preferred_lane_poly_2d);
});

if (!is_valid_start_point) {
const auto stop_point = utils::insertStopPoint(stopping_distance, path);
setStopPose(stop_point.point.pose);

return;
}

// calculate minimum distance from path front to the stationary object on the ego lane.
const auto distance_to_ego_lane_obj = [&]() -> double {
double distance_to_obj = distance_to_terminal;
Expand Down Expand Up @@ -642,7 +659,8 @@ double NormalLaneChange::calcMaximumLaneChangeLength(
const auto shift_intervals =
getRouteHandler()->getLateralIntervalsToPreferredLane(current_terminal_lanelet);
return utils::lane_change::calcMaximumLaneChangeLength(
getEgoVelocity(), getCommonParam(), shift_intervals, max_acc);
std::max(getCommonParam().minimum_lane_changing_velocity, getEgoVelocity()), getCommonParam(),
shift_intervals, max_acc);
}

std::vector<double> NormalLaneChange::sampleLongitudinalAccValues(
Expand Down Expand Up @@ -1247,6 +1265,20 @@ bool NormalLaneChange::getLaneChangePaths(
boost::geometry::covered_by(lc_start_point, target_neighbor_preferred_lane_poly_2d) ||
boost::geometry::covered_by(lc_start_point, target_lane_poly_2d);

LaneChangeInfo lane_change_info;
lane_change_info.longitudinal_acceleration =
LaneChangePhaseInfo{longitudinal_acc_on_prepare, longitudinal_acc_on_lane_changing};
lane_change_info.duration = LaneChangePhaseInfo{prepare_duration, lane_changing_time};
lane_change_info.velocity =
LaneChangePhaseInfo{prepare_velocity, initial_lane_changing_velocity};
lane_change_info.length = LaneChangePhaseInfo{prepare_length, lane_changing_length};
lane_change_info.current_lanes = current_lanes;
lane_change_info.target_lanes = target_lanes;
lane_change_info.lane_changing_start = prepare_segment.points.back().point.pose;
lane_change_info.lane_changing_end = target_segment.points.front().point.pose;
lane_change_info.lateral_acceleration = lateral_acc;
lane_change_info.terminal_lane_changing_velocity = terminal_lane_changing_velocity;

if (!is_valid_start_point) {
debug_print(
"Reject: lane changing points are not inside of the target preferred lanes or its "
Expand All @@ -1266,21 +1298,8 @@ bool NormalLaneChange::getLaneChangePaths(
continue;
}

LaneChangeInfo lane_change_info;
lane_change_info.longitudinal_acceleration =
LaneChangePhaseInfo{longitudinal_acc_on_prepare, longitudinal_acc_on_lane_changing};
lane_change_info.duration = LaneChangePhaseInfo{prepare_duration, lane_changing_time};
lane_change_info.velocity =
LaneChangePhaseInfo{prepare_velocity, initial_lane_changing_velocity};
lane_change_info.length = LaneChangePhaseInfo{prepare_length, lane_changing_length};
lane_change_info.current_lanes = current_lanes;
lane_change_info.target_lanes = target_lanes;
lane_change_info.lane_changing_start = prepare_segment.points.back().point.pose;
lane_change_info.lane_changing_end = target_segment.points.front().point.pose;
lane_change_info.shift_line = utils::lane_change::getLaneChangingShiftLine(
prepare_segment, target_segment, target_lane_reference_path, shift_length);
lane_change_info.lateral_acceleration = lateral_acc;
lane_change_info.terminal_lane_changing_velocity = terminal_lane_changing_velocity;

const auto candidate_path = utils::lane_change::constructCandidatePath(
lane_change_info, prepare_segment, target_segment, target_lane_reference_path,
Expand Down
Loading