Skip to content

Commit

Permalink
refactor(lane_change): refactor debug print when computing paths (aut…
Browse files Browse the repository at this point in the history
…owarefoundation#8358)

Refactor debug print

Signed-off-by: Zulfaqar Azmi <[email protected]>
  • Loading branch information
zulfaqar-azmi-t4 authored Aug 7, 2024
1 parent 12e4ae5 commit f064f0e
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,6 @@ PathWithLaneId NormalLaneChange::getTargetSegment(
std::min(dist_from_start, dist_from_end), s_start + std::numeric_limits<double>::epsilon());
});

RCLCPP_DEBUG(logger_, "in %s start: %f, end: %f", __func__, s_start, s_end);

PathWithLaneId target_segment = route_handler.getCenterLinePath(target_lanes, s_start, s_end);
for (auto & point : target_segment.points) {
point.point.longitudinal_velocity_mps =
Expand Down Expand Up @@ -1391,12 +1389,6 @@ bool NormalLaneChange::getLaneChangePaths(

for (const auto & prepare_duration : prepare_durations) {
for (const auto & sampled_longitudinal_acc : longitudinal_acc_sampling_values) {
const auto debug_print = [&](const auto & s) {
RCLCPP_DEBUG_STREAM(
logger_, " - " << s << " : prep_time = " << prepare_duration
<< ", lon_acc = " << sampled_longitudinal_acc);
};

// get path on original lanes
const auto prepare_velocity = std::clamp(
current_velocity + sampled_longitudinal_acc * prepare_duration,
Expand All @@ -1412,6 +1404,12 @@ bool NormalLaneChange::getLaneChangePaths(

auto prepare_segment = getPrepareSegment(current_lanes, backward_path_length, prepare_length);

const auto debug_print = [&](const auto & s) {
RCLCPP_DEBUG(
logger_, "%s | prep_time: %.5f | lon_acc sampled: %.5f, actual: %.5f | prep_len: %.5f", s,
prepare_duration, sampled_longitudinal_acc, longitudinal_acc_on_prepare, prepare_length);
};

if (prepare_segment.points.empty()) {
debug_print("prepare segment is empty...? Unexpected.");
continue;
Expand Down Expand Up @@ -1453,13 +1451,8 @@ bool NormalLaneChange::getLaneChangePaths(
}
RCLCPP_DEBUG(logger_, " - sampling num for lat_acc: %lu", sample_lat_acc.size());

debug_print("Prepare path satisfy constraints");
for (const auto & lateral_acc : sample_lat_acc) {
const auto debug_print_lat = [&](const auto & s) {
RCLCPP_DEBUG_STREAM(
logger_, " - " << s << " : prep_time = " << prepare_duration << ", lon_acc = "
<< sampled_longitudinal_acc << ", lat_acc = " << lateral_acc);
};

const auto lane_changing_time = PathShifter::calcShiftTimeFromJerk(
shift_length, lane_change_parameters_->lane_changing_lateral_jerk, lateral_acc);
const double longitudinal_acc_on_lane_changing =
Expand All @@ -1475,6 +1468,14 @@ bool NormalLaneChange::getLaneChangePaths(
utils::lane_change::setPrepareVelocity(
prepare_segment, current_velocity, terminal_lane_changing_velocity);

const auto debug_print_lat = [&](const auto & s) {
RCLCPP_DEBUG(
logger_,
" - %s | lc_time: %.5f | lon_acc sampled: %.5f, actual: %.5f | lc_len: %.5f", s,
lane_changing_time, sampled_longitudinal_acc, longitudinal_acc_on_lane_changing,
lane_changing_length);
};

if (lane_changing_length + prepare_length > dist_to_end_of_current_lanes) {
debug_print_lat("Reject: length of lane changing path is longer than length to goal!!");
continue;
Expand Down

0 comments on commit f064f0e

Please sign in to comment.