From ad0f9f5adaabd8214d0bf3f58baa5ea4b0072a1d Mon Sep 17 00:00:00 2001 From: Mirko Waechter <mirko.waechter@kit.edu> Date: Mon, 30 Jul 2018 15:13:52 +0200 Subject: [PATCH] pid controller: added missing allocation of vectors --- source/RobotAPI/libraries/core/MultiDimPIDController.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/RobotAPI/libraries/core/MultiDimPIDController.h b/source/RobotAPI/libraries/core/MultiDimPIDController.h index 8c97be3dd..4186cb9b1 100644 --- a/source/RobotAPI/libraries/core/MultiDimPIDController.h +++ b/source/RobotAPI/libraries/core/MultiDimPIDController.h @@ -71,6 +71,12 @@ namespace armarx void update(const double deltaSec, const PIDVectorX& measuredValue, const PIDVectorX& targetValue) { ScopedRecursiveLockPtr lock = getLock(); + if (stackAllocations.zeroVec.rows() == 0) + { + preallocate(measuredValue.rows()); + } + ARMARX_CHECK_EQUAL(measuredValue.rows(), targetValue.rows()); + ARMARX_CHECK_EQUAL(measuredValue.rows(), stackAllocations.zeroVec.rows()); processValue = measuredValue; target = targetValue; @@ -96,7 +102,7 @@ namespace armarx if (!firstRun) { integral += error * deltaSec; - integral = std::min(integral,maxIntegral); + integral = std::min(integral, maxIntegral); if (deltaSec > 0.0) { derivative = (error - previousError) / deltaSec; -- GitLab