diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs index 1214703..7693195 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |||
@@ -188,6 +188,8 @@ public class BSVMotor : BSMotor | |||
188 | CurrentValue = current; | 188 | CurrentValue = current; |
189 | return Step(timeStep); | 189 | return Step(timeStep); |
190 | } | 190 | } |
191 | // Given and error, computer a correction for this step. | ||
192 | // Simple scaling of the error by the timestep. | ||
191 | public virtual Vector3 StepError(float timeStep, Vector3 error) | 193 | public virtual Vector3 StepError(float timeStep, Vector3 error) |
192 | { | 194 | { |
193 | if (!Enabled) return Vector3.Zero; | 195 | if (!Enabled) return Vector3.Zero; |
@@ -221,7 +223,7 @@ public class BSVMotor : BSMotor | |||
221 | CurrentValue, TargetValue); | 223 | CurrentValue, TargetValue); |
222 | 224 | ||
223 | LastError = BSMotor.InfiniteVector; | 225 | LastError = BSMotor.InfiniteVector; |
224 | while (maxOutput-- > 0 && !LastError.ApproxEquals(Vector3.Zero, ErrorZeroThreshold)) | 226 | while (maxOutput-- > 0 && !ErrorIsZero()) |
225 | { | 227 | { |
226 | Vector3 lastStep = Step(timeStep); | 228 | Vector3 lastStep = Step(timeStep); |
227 | MDetailLog("{0},BSVMotor.Test,{1},cur={2},tgt={3},lastError={4},lastStep={5}", | 229 | MDetailLog("{0},BSVMotor.Test,{1},cur={2},tgt={3},lastError={4},lastStep={5}", |
@@ -375,7 +377,6 @@ public class BSPIDVMotor : BSVMotor | |||
375 | // The factors are vectors for the three dimensions. This is the proportional of each | 377 | // The factors are vectors for the three dimensions. This is the proportional of each |
376 | // that is applied. This could be multiplied through the actual factors but it | 378 | // that is applied. This could be multiplied through the actual factors but it |
377 | // is sometimes easier to manipulate the factors and their mix separately. | 379 | // is sometimes easier to manipulate the factors and their mix separately. |
378 | // to | ||
379 | public Vector3 FactorMix; | 380 | public Vector3 FactorMix; |
380 | 381 | ||
381 | // Arbritrary factor range. | 382 | // Arbritrary factor range. |
@@ -413,14 +414,14 @@ public class BSPIDVMotor : BSVMotor | |||
413 | // If efficiency is high (1f), use a factor value that moves the error value to zero with little overshoot. | 414 | // If efficiency is high (1f), use a factor value that moves the error value to zero with little overshoot. |
414 | // If efficiency is low (0f), use a factor value that overcorrects. | 415 | // If efficiency is low (0f), use a factor value that overcorrects. |
415 | // TODO: might want to vary contribution of different factor depending on efficiency. | 416 | // TODO: might want to vary contribution of different factor depending on efficiency. |
416 | float factor = ((1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow) / 3f; | 417 | // float factor = ((1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow) / 3f; |
417 | // float factor = (1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow; | 418 | float factor = (1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow; |
418 | 419 | ||
419 | proportionFactor = new Vector3(factor, factor, factor); | 420 | proportionFactor = new Vector3(factor, factor, factor); |
420 | integralFactor = new Vector3(factor, factor, factor); | 421 | integralFactor = new Vector3(factor, factor, factor); |
421 | derivFactor = new Vector3(factor, factor, factor); | 422 | derivFactor = new Vector3(factor, factor, factor); |
422 | 423 | ||
423 | MDetailLog("{0},BSPIDVMotor.setEfficiency,eff={1},factor={2}", BSScene.DetailLogZero, Efficiency, factor); | 424 | MDetailLog("{0}, BSPIDVMotor.setEfficiency,eff={1},factor={2}", BSScene.DetailLogZero, Efficiency, factor); |
424 | } | 425 | } |
425 | } | 426 | } |
426 | 427 | ||
@@ -441,8 +442,8 @@ public class BSPIDVMotor : BSVMotor | |||
441 | + derivitive / TimeScale * derivFactor * FactorMix.Z | 442 | + derivitive / TimeScale * derivFactor * FactorMix.Z |
442 | ; | 443 | ; |
443 | 444 | ||
444 | MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", | 445 | MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},lerr={3},runnInt={4},deriv={5},ret={6}", |
445 | BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); | 446 | BSScene.DetailLogZero, timeStep, error, LastError, RunningIntegration, derivitive, ret); |
446 | 447 | ||
447 | return ret; | 448 | return ret; |
448 | } | 449 | } |