From c5d852d5f9c7392dd7e79f91703afcd6bccf1a04 Mon Sep 17 00:00:00 2001 From: LAGNEAU Romain Date: Wed, 4 Sep 2024 15:49:49 +0200 Subject: [PATCH] [FIX] Throw an error when the size of the state does not match the size of the standard deviation vector --- modules/core/include/visp3/core/vpParticleFilter.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/core/include/visp3/core/vpParticleFilter.h b/modules/core/include/visp3/core/vpParticleFilter.h index e22cf08c58..169de74011 100644 --- a/modules/core/include/visp3/core/vpParticleFilter.h +++ b/modules/core/include/visp3/core/vpParticleFilter.h @@ -473,6 +473,9 @@ void vpParticleFilter::init(const vpColVector &x0, const vpPro const vpResamplingConditionFunction &checkResamplingFunc, const vpResamplingFunction &resamplingFunc, const vpFilterFunction &filterFunc, const vpStateAddFunction &addFunc) { + if (x0.size() != m_noiseGenerators[0].size()) { + throw(vpException(vpException::dimensionError, "X0 does not have the same size than the vector of stdevs used to build the object")); + } m_f = f; m_stateFilterFunc = filterFunc; m_likelihood = l; @@ -492,6 +495,9 @@ void vpParticleFilter::init(const vpColVector &x0, const vpCom const vpResamplingConditionFunction &checkResamplingFunc, const vpResamplingFunction &resamplingFunc, const vpFilterFunction &filterFunc, const vpStateAddFunction &addFunc) { + if (x0.size() != m_noiseGenerators[0].size()) { + throw(vpException(vpException::dimensionError, "X0 does not have the same size than the vector of stdevs used to build the object")); + } m_bx = bx; m_stateFilterFunc = filterFunc; m_likelihood = l;