aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
diff options
context:
space:
mode:
authorRobert Adams2012-12-21 15:21:32 -0800
committerRobert Adams2012-12-21 15:21:32 -0800
commit6dbf9c8ed4ca5646f47043f9937da5acbe124d0e (patch)
tree337ec47d2093834ccef03f83816ec3f203315c6f /OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
parentBulletSim: Move all the parameter variables, tables and get and fetch logic t... (diff)
downloadopensim-SC-6dbf9c8ed4ca5646f47043f9937da5acbe124d0e.zip
opensim-SC-6dbf9c8ed4ca5646f47043f9937da5acbe124d0e.tar.gz
opensim-SC-6dbf9c8ed4ca5646f47043f9937da5acbe124d0e.tar.bz2
opensim-SC-6dbf9c8ed4ca5646f47043f9937da5acbe124d0e.tar.xz
BulletSim: repair vehicle problems introduced in previous 'improvements'. Fix line endings in BSParams.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSMotors.cs14
1 files changed, 10 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
index 34a87c6..8781fe9 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
@@ -268,12 +268,14 @@ public class BSPIDVMotor : BSVMotor
268 public Vector3 proportionFactor { get; set; } 268 public Vector3 proportionFactor { get; set; }
269 public Vector3 integralFactor { get; set; } 269 public Vector3 integralFactor { get; set; }
270 public Vector3 derivFactor { get; set; } 270 public Vector3 derivFactor { get; set; }
271
271 // Arbritrary factor range. 272 // Arbritrary factor range.
272 // EfficiencyHigh means move quickly to the correct number. EfficiencyLow means might over correct. 273 // EfficiencyHigh means move quickly to the correct number. EfficiencyLow means might over correct.
273 public float EfficiencyHigh = 0.4f; 274 public float EfficiencyHigh = 0.4f;
274 public float EfficiencyLow = 4.0f; 275 public float EfficiencyLow = 4.0f;
275 276
276 Vector3 IntegralFactor { get; set; } 277 // Running integration of the error
278 Vector3 RunningIntegration { get; set; }
277 279
278 public BSPIDVMotor(string useName) 280 public BSPIDVMotor(string useName)
279 : base(useName) 281 : base(useName)
@@ -281,7 +283,7 @@ public class BSPIDVMotor : BSVMotor
281 proportionFactor = new Vector3(1.00f, 1.00f, 1.00f); 283 proportionFactor = new Vector3(1.00f, 1.00f, 1.00f);
282 integralFactor = new Vector3(1.00f, 1.00f, 1.00f); 284 integralFactor = new Vector3(1.00f, 1.00f, 1.00f);
283 derivFactor = new Vector3(1.00f, 1.00f, 1.00f); 285 derivFactor = new Vector3(1.00f, 1.00f, 1.00f);
284 IntegralFactor = Vector3.Zero; 286 RunningIntegration = Vector3.Zero;
285 LastError = Vector3.Zero; 287 LastError = Vector3.Zero;
286 } 288 }
287 289
@@ -312,14 +314,18 @@ public class BSPIDVMotor : BSVMotor
312 public override Vector3 Step(float timeStep, Vector3 error) 314 public override Vector3 Step(float timeStep, Vector3 error)
313 { 315 {
314 // Add up the error so we can integrate over the accumulated errors 316 // Add up the error so we can integrate over the accumulated errors
315 IntegralFactor += error * timeStep; 317 RunningIntegration += error * timeStep;
316 318
317 // A simple derivitive is the rate of change from the last error. 319 // A simple derivitive is the rate of change from the last error.
318 Vector3 derivFactor = (error - LastError) * timeStep; 320 Vector3 derivFactor = (error - LastError) * timeStep;
319 LastError = error; 321 LastError = error;
320 322
321 // Correction = -(proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError) 323 // Correction = -(proportionOfPresentError + accumulationOfPastError + rateOfChangeOfError)
322 Vector3 ret = -(error * proportionFactor + IntegralFactor * integralFactor + derivFactor * derivFactor); 324 Vector3 ret = -(
325 error * proportionFactor
326 + RunningIntegration * integralFactor
327 + derivFactor * derivFactor
328 );
323 329
324 return ret; 330 return ret;
325 } 331 }