public override Vector3 StepError(float timeStep, Vector3 error)
{
if (!Enabled) return Vector3.Zero;
// Add up the error so we can integrate over the accumulated errors
RunningIntegration += error * timeStep;
// A simple derivitive is the rate of change from the last error.
Vector3 derivitive = (error - LastError) * timeStep;
LastError = error;
// Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError)
Vector3 ret = error/TimeScale * timeStep * proportionFactor * FactorMix.X
+ RunningIntegration/TimeScale * integralFactor * FactorMix.Y
+ derivitive/TimeScale * derivFactor * FactorMix.Z
;
MDetailLog("{0},BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}",
BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret);
return ret;
}
}