Commit 449ee0d3 authored by rv3Dcv's avatar rv3Dcv

Add TimeStep

Performed debugging to understand the impact of the timestep on constraint solving
parent 1563d0d5
...@@ -67,5 +67,24 @@ public class CollisionTestPerformer : MonoBehaviour ...@@ -67,5 +67,24 @@ public class CollisionTestPerformer : MonoBehaviour
Debug.Log("Velocity at test end: " + simulationLoop.sphereVelocities[1].ToString("e2")); Debug.Log("Velocity at test end: " + simulationLoop.sphereVelocities[1].ToString("e2"));
Debug.Log("End of Pull Phase of Collision Test Two"); Debug.Log("End of Pull Phase of Collision Test Two");
} }
// private IEnumerator PerformCollisionTestThree(float exitVelocity = 4f)
// {
// for (int sphereIndex = 0; sphereIndex < (simulationLoop.SpheresCount - 1); sphereIndex++)
// {
// simulationLoop.sphereExternalForces[sphereIndex] = Vector3.zero;
// }
// simulationLoop.sphereExternalForces[simulationLoop.SpheresCount - 1] = pullForce;
// yield return new WaitForSeconds(applyForceTime);
// simulationLoop.sphereExternalForces[simulationLoop.SpheresCount - 1] = Vector3.zero;
// float timeDiff = Time.time - startTime;
// Debug.Log("Elapsed time of collision test: " + timeDiff);
// Debug.Log("Velocity at test end: " + simulationLoop.sphereVelocities[1].ToString("e2"));
// Debug.Log("End of Pull Phase of Collision Test Two");
// }
} }
} }
\ No newline at end of file
...@@ -415,7 +415,7 @@ PrefabInstance: ...@@ -415,7 +415,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3} - target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3}
propertyPath: timeStep propertyPath: timeStep
value: 0.04 value: 0.002
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3} - target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3}
propertyPath: fixedTimeStep propertyPath: fixedTimeStep
...@@ -435,7 +435,7 @@ PrefabInstance: ...@@ -435,7 +435,7 @@ PrefabInstance:
objectReference: {fileID: 152071858} objectReference: {fileID: 152071858}
- target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3} - target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3}
propertyPath: solveStretchConstraints propertyPath: solveStretchConstraints
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3} - target: {fileID: 4233146888435007091, guid: 0e128b35dc3ea6746b6de609560d672d, type: 3}
propertyPath: solveBendTwistConstraints propertyPath: solveBendTwistConstraints
......
...@@ -31,15 +31,15 @@ public class PredictionStep : MonoBehaviour ...@@ -31,15 +31,15 @@ public class PredictionStep : MonoBehaviour
{ {
// Debug.Log("dt " + Time.deltaTime + " fdt " + Time.fixedDeltaTime); // Debug.Log("dt " + Time.deltaTime + " fdt " + Time.fixedDeltaTime);
Vector3 calc = Time.deltaTime * sphereInverseMasses[1] * sphereExternalForces[1]; Vector3 calc = Time.deltaTime * sphereInverseMasses[1] * sphereExternalForces[1];
Debug.Log("dt " + Time.deltaTime + " invMass " + sphereInverseMasses[1] + " extF " + sphereExternalForces[1].ToString("e3") // Debug.Log("dt " + Time.deltaTime + " invMass " + sphereInverseMasses[1] + " extF " + sphereExternalForces[1].ToString("e3")
+ " calc " + calc.ToString("e3") + " vorherigeVel " + sphereVelocities[1].ToString("e3")); // + " calc " + calc.ToString("e3") + " vorherigeVel " + sphereVelocities[1].ToString("e3"));
for (int sphereIndex = 0; sphereIndex < sphereVelocities.Length; sphereIndex++) for (int sphereIndex = 0; sphereIndex < sphereVelocities.Length; sphereIndex++)
{ {
sphereVelocities[sphereIndex] += Time.deltaTime * sphereInverseMasses[sphereIndex] * sphereExternalForces[sphereIndex]; sphereVelocities[sphereIndex] += Time.deltaTime * sphereInverseMasses[sphereIndex] * sphereExternalForces[sphereIndex];
} }
Debug.Log("velocity " + sphereVelocities[1].ToString("e3")); // Debug.Log("velocity " + sphereVelocities[1].ToString("e3"));
return sphereVelocities; return sphereVelocities;
} }
......
...@@ -88,13 +88,16 @@ public class SimulationLoop : MonoBehaviour ...@@ -88,13 +88,16 @@ public class SimulationLoop : MonoBehaviour
* @attention Make sure that the guidewire setup fulfilles that the distance between two adjacent * @attention Make sure that the guidewire setup fulfilles that the distance between two adjacent
* spheres is #rodElementLength. * spheres is #rodElementLength.
*/ */
[SerializeField] [Range(0.001f, 0.04f)] float timeStep = 0.01f; //!< The fixed time step in seconds at which the simulation runs. [SerializeField] [Range(0.002f, 0.04f)] float timeStep = 0.01f; /**< The fixed time step in seconds at which the simulation runs.
* @note A lower timestep than 0.002 can not be guaranteed by
* the test hardware to be executed in time. Only choose a lower timestep if
* you are certain your hardware can handle it.
*/
public float TimeStep { get { return timeStep; }}
public int SpheresCount { get; private set; } //!< The count of all #spheres of the guidewire. public int SpheresCount { get; private set; } //!< The count of all #spheres of the guidewire.
public int CylinderCount { get; private set; } //!< The count of all #cylinders of the guidewire. public int CylinderCount { get; private set; } //!< The count of all #cylinders of the guidewire.
int counter = 0;
private void Awake() private void Awake()
{ {
Assert.IsFalse(spheres.Length == 0); Assert.IsFalse(spheres.Length == 0);
...@@ -142,12 +145,9 @@ public class SimulationLoop : MonoBehaviour ...@@ -142,12 +145,9 @@ public class SimulationLoop : MonoBehaviour
*/ */
private void FixedUpdate() private void FixedUpdate()
{ {
if (counter > 2) return;
if (ExecuteSingleLoopTest) return; if (ExecuteSingleLoopTest) return;
PerformSimulationLoop(); PerformSimulationLoop();
counter++;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment