From d1c6b2bd75f3eb3c60d890110ea3838d3d466635 Mon Sep 17 00:00:00 2001 From: Mamoru Sobue Date: Mon, 7 Nov 2022 13:51:07 +0900 Subject: [PATCH] fix(behavior_velocity_planner): int/uint for path index (#2221) * fixed int/uint for path index Signed-off-by: Mamoru Sobue * reflected comments Signed-off-by: Mamoru Sobue Signed-off-by: Mamoru Sobue Signed-off-by: yoshiri --- .../src/scene_module/intersection/util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/planning/behavior_velocity_planner/src/scene_module/intersection/util.cpp b/planning/behavior_velocity_planner/src/scene_module/intersection/util.cpp index 2658c4fb9fcd6..197fcd1bf9d38 100644 --- a/planning/behavior_velocity_planner/src/scene_module/intersection/util.cpp +++ b/planning/behavior_velocity_planner/src/scene_module/intersection/util.cpp @@ -79,7 +79,7 @@ std::optional> findLaneIdInterval( { bool found = false; size_t start = 0; - size_t end = p.points.size() - 1; + size_t end = p.points.size() > 0 ? p.points.size() - 1 : 0; for (size_t i = 0; i < p.points.size(); ++i) { if (hasLaneId(p.points.at(i), lane_id)) { if (!found) { @@ -93,7 +93,7 @@ std::optional> findLaneIdInterval( break; } } - start = std::max(0, start - 1); // the idx of last point before the interval + start = start > 0 ? start - 1 : 0; // the idx of last point before the interval return found ? std::make_optional(std::make_pair(start, end)) : std::nullopt; }