Skip to content

Commit 7db969f

Browse files
zulfaqar-azmi-t4saka1-s
authored andcommitted
fix(motion_utils): check size after overlap points removal (autowarefoundation#6653)
* fix(motion_utils): check size after overlap points removal Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> * change implementation to not return warning Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> * fix comparison sign Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> --------- Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
1 parent 1624ee1 commit 7db969f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,12 @@ double calcLateralOffset(
590590
return std::nan("");
591591
}
592592

593-
const auto p_front = tier4_autoware_utils::getPoint(overlap_removed_points.at(seg_idx));
594-
const auto p_back = tier4_autoware_utils::getPoint(overlap_removed_points.at(seg_idx + 1));
593+
const auto p_indices = overlap_removed_points.size() - 2;
594+
const auto p_front_idx = (p_indices > seg_idx) ? seg_idx : p_indices;
595+
const auto p_back_idx = p_front_idx + 1;
596+
597+
const auto p_front = tier4_autoware_utils::getPoint(overlap_removed_points.at(p_front_idx));
598+
const auto p_back = tier4_autoware_utils::getPoint(overlap_removed_points.at(p_back_idx));
595599

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

0 commit comments

Comments
 (0)