From 208bd92efd507cf15d67dcdea0c5e99bc5d16b3e Mon Sep 17 00:00:00 2001 From: Captain Yoshi Date: Thu, 21 Sep 2023 13:41:20 -0400 Subject: [PATCH] [fix] out of bound access of trajectory points The filter needs at least 2 samples to interpolate the input trajectory. --- industrial_trajectory_filters/src/uniform_sample_filter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/industrial_trajectory_filters/src/uniform_sample_filter.cpp b/industrial_trajectory_filters/src/uniform_sample_filter.cpp index e598f433..2f7a9934 100644 --- a/industrial_trajectory_filters/src/uniform_sample_filter.cpp +++ b/industrial_trajectory_filters/src/uniform_sample_filter.cpp @@ -77,6 +77,12 @@ template trajectory_out = trajectory_in; + if(size_in <= 1) + { + ROS_WARN("A minimal trajectory of 2 points is required to apply a uniform sampling filter"); + return false; + } + // Clear out the trajectory points trajectory_out.request.trajectory.points.clear();