38 template <
int dimensions = Eigen::Dynamic>
68 stackAllocations.zeroVec = PIDVectorX::Zero(size);
69 stackAllocations.errorVec = stackAllocations.zeroVec;
70 stackAllocations.direction = stackAllocations.zeroVec;
71 stackAllocations.oldControlValue = stackAllocations.zeroVec;
83 ScopedRecursiveLockPtr lock = getLock();
84 if (stackAllocations.zeroVec.rows() == 0)
98 for (
size_t i = 0; i <
limitless.size(); i++)
102 stackAllocations.errorVec(i) =
109 double error = stackAllocations.errorVec.norm();
124 stackAllocations.direction = targetValue;
128 stackAllocations.direction = stackAllocations.errorVec.normalized();
132 stackAllocations.direction.setZero();
141 stackAllocations.oldControlValue = stackAllocations.zeroVec;
149 float maxNewJointAcc = accVec.maxCoeff();
150 float minNewJointAcc = accVec.minCoeff();
151 maxNewJointAcc = std::max<float>(fabs(minNewJointAcc), fabs(maxNewJointAcc));
154 auto newValue = stackAllocations.oldControlValue +
158 <<
VAROUT(stackAllocations.oldControlValue) <<
VAROUT(newValue);
166 max = std::max<float>(fabs(
min), fabs(
max));
178 <<
" dt: " << deltaSec;
187 ScopedRecursiveLockPtr lock = getLock();
196 update(
dt, measuredValue, targetValue);
209 ScopedRecursiveLockPtr lock = getLock();
216 ScopedRecursiveLockPtr lock = getLock();
245 struct StackAllocationHelper
265 return ScopedRecursiveLockPtr();
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
void update(const double deltaSec, const PIDVectorX &measuredValue, const PIDVectorX &targetValue)
MultiDimPIDControllerTemplate(float Kp, float Ki, float Kd, double maxControlValue=std::numeric_limits< double >::max(), double maxDerivation=std::numeric_limits< double >::max(), bool threadSafe=true, std::vector< bool > limitless={})
void preallocate(size_t size)
~MultiDimPIDControllerTemplate()
std::recursive_mutex mutex
void update(const PIDVectorX &measuredValue, const PIDVectorX &targetValue)
const PIDVectorX & getControlValue() const
void setMaxControlValue(double value)
IceUtil::Time lastUpdateTime
std::vector< bool > limitless
Eigen::Matrix< float, dimensions, 1 > PIDVectorX
static IceUtil::Time GetTime(TimeMode timeMode=TimeMode::VirtualTime)
Get the current time.
static float angleModPI(float value)
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
RecursiveMutex::scoped_lock ScopedRecursiveLock
std::shared_ptr< ScopedRecursiveLock > ScopedRecursiveLockPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
MultiDimPIDControllerTemplate<> MultiDimPIDController
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::shared_ptr< MultiDimPIDControllerTemplate<> > MultiDimPIDControllerPtr
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)