Skip to content

Commit 846e412

Browse files
change implementation to not return warning
Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
1 parent e4c38ac commit 846e412

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

common/motion_utils/include/motion_utils/trajectory/trajectory.hpp

+5-14
Original file line numberDiff line numberDiff line change
@@ -607,21 +607,12 @@ double calcLateralOffset(
607607
return std::nan("");
608608
}
609609

610-
if (overlap_removed_points.size() >= seg_idx) {
611-
const std::string error_message(
612-
"[motion_utils] " + std::string(__func__) + ": Overlap points removed exceeded seg_idx.");
613-
tier4_autoware_utils::print_backtrace();
614-
if (throw_exception) {
615-
throw std::runtime_error(error_message);
616-
}
617-
log_error(
618-
error_message +
619-
" Return NaN since no_throw option is enabled. The maintainer must check the code.");
620-
return std::nan("");
621-
}
610+
const auto p_indices = overlap_removed_points.size() - 2;
611+
const auto p_front_idx = (p_indices < seg_idx) ? seg_idx : p_indices;
612+
const auto p_back_idx = p_front_idx + 1;
622613

623-
const auto p_front = tier4_autoware_utils::getPoint(overlap_removed_points.at(seg_idx));
624-
const auto p_back = tier4_autoware_utils::getPoint(overlap_removed_points.at(seg_idx + 1));
614+
const auto p_front = tier4_autoware_utils::getPoint(overlap_removed_points.at(p_front_idx));
615+
const auto p_back = tier4_autoware_utils::getPoint(overlap_removed_points.at(p_back_idx));
625616

626617
const Eigen::Vector3d segment_vec{p_back.x - p_front.x, p_back.y - p_front.y, 0.0};
627618
const Eigen::Vector3d target_vec{p_target.x - p_front.x, p_target.y - p_front.y, 0.0};

0 commit comments

Comments
 (0)