From 6a9af315cfaabb4d232fbfc2667383e78a38f345 Mon Sep 17 00:00:00 2001 From: Peter van Dooren Date: Wed, 13 Apr 2022 15:00:28 +0200 Subject: [PATCH] add check for within bounds --- ed_sensor_integration/include/ed/kinect/fitter.h | 4 ++-- ed_sensor_integration/src/kinect/fitter.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ed_sensor_integration/include/ed/kinect/fitter.h b/ed_sensor_integration/include/ed/kinect/fitter.h index e93cbac9..f53f0785 100644 --- a/ed_sensor_integration/include/ed/kinect/fitter.h +++ b/ed_sensor_integration/include/ed/kinect/fitter.h @@ -233,11 +233,11 @@ class Fitter /** * @brief checkExpectedBeamThroughEntity checks if the expected center beam passes through the entity. If - * not: something went wrong + * not: throw a fitter error * @param model_ranges * @param entity * @param sensor_pose_xya - * @param expected_center_beam + * @param expected_center_beam expected index of the beam through the center of the object. range: any int. indices outside bounds will also throw an error. */ void checkExpectedBeamThroughEntity(const std::vector &model_ranges, ed::EntityConstPtr entity, const geo::Pose3D &sensor_pose_xya, const int expected_center_beam) const; diff --git a/ed_sensor_integration/src/kinect/fitter.cpp b/ed_sensor_integration/src/kinect/fitter.cpp index 0f5dadf5..04d30228 100644 --- a/ed_sensor_integration/src/kinect/fitter.cpp +++ b/ed_sensor_integration/src/kinect/fitter.cpp @@ -463,7 +463,7 @@ void Fitter::checkExpectedBeamThroughEntity(const std::vector& model_ran std::vector expected_identifiers(nr_data_points_, 0); renderEntity(entity, sensor_pose_xya, 1, expected_ranges, expected_identifiers); - if (expected_identifiers[expected_center_beam] != 1) // expected center beam MUST contain the rendered model + if (expected_center_beam < 0 || expected_center_beam >= nr_data_points_ || expected_identifiers[expected_center_beam] != 1) // expected center beam MUST contain the rendered model throw FitterError("Expected beam does not go through entity"); }