From 1f26900d5f29c5563dbd9efa699c446a40349b0c Mon Sep 17 00:00:00 2001 From: Seungsoo Lee Date: Thu, 30 May 2024 01:39:33 +0900 Subject: [PATCH] Prevent invalid accesses on paths in path_longer_on_approach (#4375) * Prevent invalid accesses on paths in path_longer_on_approach * Fix format of the change --- .../plugins/decorator/path_longer_on_approach.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nav2_behavior_tree/plugins/decorator/path_longer_on_approach.cpp b/nav2_behavior_tree/plugins/decorator/path_longer_on_approach.cpp index 1b3f8abd56..403c007fb0 100644 --- a/nav2_behavior_tree/plugins/decorator/path_longer_on_approach.cpp +++ b/nav2_behavior_tree/plugins/decorator/path_longer_on_approach.cpp @@ -63,7 +63,9 @@ inline BT::NodeStatus PathLongerOnApproach::tick() getInput("length_factor", length_factor_); if (first_time_ == false) { - if (old_path_.poses.back() != new_path_.poses.back()) { + if (old_path_.poses.empty() || new_path_.poses.empty() || + old_path_.poses.back() != new_path_.poses.back()) + { first_time_ = true; } }