diff options
Diffstat (limited to '')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs index ef662b5..1214703 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |||
@@ -144,7 +144,6 @@ public class BSVMotor : BSMotor | |||
144 | 144 | ||
145 | Vector3 correction = Vector3.Zero; | 145 | Vector3 correction = Vector3.Zero; |
146 | Vector3 error = TargetValue - CurrentValue; | 146 | Vector3 error = TargetValue - CurrentValue; |
147 | LastError = error; | ||
148 | if (!ErrorIsZero(error)) | 147 | if (!ErrorIsZero(error)) |
149 | { | 148 | { |
150 | correction = StepError(timeStep, error); | 149 | correction = StepError(timeStep, error); |
@@ -179,6 +178,7 @@ public class BSVMotor : BSMotor | |||
179 | MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}", | 178 | MDetailLog("{0}, BSVMotor.Step,zero,{1},origTgt={2},origCurr={3},currTgt={4},currCurr={5}", |
180 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue); | 179 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, TargetValue, CurrentValue); |
181 | } | 180 | } |
181 | LastError = error; | ||
182 | 182 | ||
183 | return correction; | 183 | return correction; |
184 | } | 184 | } |
@@ -293,7 +293,6 @@ public class BSFMotor : BSMotor | |||
293 | 293 | ||
294 | float correction = 0f; | 294 | float correction = 0f; |
295 | float error = TargetValue - CurrentValue; | 295 | float error = TargetValue - CurrentValue; |
296 | LastError = error; | ||
297 | if (!ErrorIsZero(error)) | 296 | if (!ErrorIsZero(error)) |
298 | { | 297 | { |
299 | correction = StepError(timeStep, error); | 298 | correction = StepError(timeStep, error); |
@@ -328,6 +327,7 @@ public class BSFMotor : BSMotor | |||
328 | MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", | 327 | MDetailLog("{0}, BSFMotor.Step,zero,{1},origTgt={2},origCurr={3},ret={4}", |
329 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); | 328 | BSScene.DetailLogZero, UseName, origCurrVal, origTarget, CurrentValue); |
330 | } | 329 | } |
330 | LastError = error; | ||
331 | 331 | ||
332 | return CurrentValue; | 332 | return CurrentValue; |
333 | } | 333 | } |
@@ -363,7 +363,7 @@ public class BSFMotor : BSMotor | |||
363 | 363 | ||
364 | // ============================================================================ | 364 | // ============================================================================ |
365 | // ============================================================================ | 365 | // ============================================================================ |
366 | // Proportional, Integral, Derivitive Motor | 366 | // Proportional, Integral, Derivitive ("PID") Motor |
367 | // Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors. | 367 | // Good description at http://www.answers.com/topic/pid-controller . Includes processes for choosing p, i and d factors. |
368 | public class BSPIDVMotor : BSVMotor | 368 | public class BSPIDVMotor : BSVMotor |
369 | { | 369 | { |
@@ -434,15 +434,14 @@ public class BSPIDVMotor : BSVMotor | |||
434 | 434 | ||
435 | // A simple derivitive is the rate of change from the last error. | 435 | // A simple derivitive is the rate of change from the last error. |
436 | Vector3 derivitive = (error - LastError) * timeStep; | 436 | Vector3 derivitive = (error - LastError) * timeStep; |
437 | LastError = error; | ||
438 | 437 | ||
439 | // Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError) | 438 | // Correction = (proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError) |
440 | Vector3 ret = error * timeStep * proportionFactor * FactorMix.X | 439 | Vector3 ret = error / TimeScale * timeStep * proportionFactor * FactorMix.X |
441 | + RunningIntegration * integralFactor * FactorMix.Y | 440 | + RunningIntegration / TimeScale * integralFactor * FactorMix.Y |
442 | + derivitive * derivFactor * FactorMix.Z | 441 | + derivitive / TimeScale * derivFactor * FactorMix.Z |
443 | ; | 442 | ; |
444 | 443 | ||
445 | MDetailLog("{0},BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", | 444 | MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", |
446 | BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); | 445 | BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); |
447 | 446 | ||
448 | return ret; | 447 | return ret; |