Simulating Guidewires in Blood Vessels using Cosserat Rod Theory |

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Properties | Private Member Functions | Private Attributes | List of all members
GuidewireSim.SimulationLoop Class Reference
Inheritance diagram for GuidewireSim.SimulationLoop:

## Public Member Functions
void | PerformSimulationLoop ()

## Public Attributes
GameObject[] | spheres
Vector3[] | spherePositions
| The position at the current frame of each sphere. More...
Vector3[] | sphereVelocities
| The velocity of the current frame of each sphere. Initalized with zero entries. More...
float[] | sphereInverseMasses
Vector3[] | sphereExternalForces
| The sum of all current external forces that are applied per particle/ sphere. More...
Vector3[] | cylinderPositions
| The center of mass of each cylinder. More...
float[] | cylinderScalarWeights
Vector3[] | cylinderExternalTorques
| The sum of all current external torques that are applied per orientation element/ cylinder. More...
Vector3[][] | directors
bool | solveStretchConstraints = true
| Whether or not to perform the constraint solving of the stretch constraint. More...
bool | solveBendTwistConstraints = true
| Whether or not to perform the constraint solving of the bend twist constraint. More...
bool | solveCollisionConstraints = true
| Whether or not to perform the constraint solving of collision constraints. More...

## Properties
bool | ExecuteSingleLoopTest = false`[get, set]`
int | ConstraintSolverSteps`[get, set]`
float | TimeStep`[get]`
int | SpheresCount`[get, private set]`
| The count of all spheres of the guidewire. More...
int | CylinderCount`[get, private set]`
| The count of all cylinders of the guidewire. More...

## Private Member Functions
void | Awake ()
void | Start ()
void | FixedUpdate ()
void | PerformInitializationStep ()
void | PerformConstraintSolvingStep ()
void | PerformUpdateStep ()
void | PerformPredictionStep ()
void | AdaptCalculations ()
void | SetCollidersStep ()

## Private Attributes
InitializationStep | initializationStep
| The component InitializationStep that is responsible for initializing the simulation. More...
PredictionStep | predictionStep
| The component PredictionStep that is responsible for executing the Prediction Step of the algorithm. More...
ConstraintSolvingStep | constraintSolvingStep
UpdateStep | updateStep
| The component UpdateStep that is responsible for executing the Update Step of the algorithm. More...
ObjectSetter | objectSetter
| The component ObjectSetter that is responsible for setting all positions and rotations the the GameObjects. More...
MathHelper | mathHelper
| The component MathHelper that provides math related helper functions. More...
CollisionSolvingStep | collisionSolvingStep
| The component CollisionSolvingStep that solves all collisions. More...
CollisionHandler | collisionHandler
| The component CollisionHandler that tracks all collisions. More...
GameObject[] | cylinders
Vector3[] | spherePositionPredictions
| The prediction of the position at the current frame of each sphere. More...
BSM.Quaternion[] | cylinderOrientations
| The orientation of each cylinder at its center of mass. More...
BSM.Quaternion[] | cylinderOrientationPredictions
| The prediction of the orientation of each cylinder at its center of mass. More...
Vector3[] | discreteRestDarbouxVectors
Vector3[] | cylinderAngularVelocities
float[,] | inertiaTensor
| The inertia tensor. Entries are approximates as in the CoRdE paper. More...
float[,] | inverseInertiaTensor
| The inverse of inertiaTensor. More...
BSM.Quaternion[] | worldSpaceBasis
float | rodElementLength = 10f
int | constraintSolverSteps = 1000
float | timeStep = 0.01f

## Detailed Description

This class executes the outer simuluation loop of the algorithm and calls the implementations of each algorithm step and manages all coherent data.

## Member Function Documentation

## ◆ AdaptCalculations()

void GuidewireSim.SimulationLoop.AdaptCalculations | ( |  | ) |
| private

Adapts the data to the Unity GameObjects. For example, sets the positions of the GameObjects spheres to spherePositions.

Requirements:

  Sets the positions of the GameObjects spheres to spherePositions.

  Calculates cylinderPositions based on spherePositions.

  Sets the positions of the GameObjects cylinders to cylinderPositions.

  Sets the rotations of the GameObjects cylinders to cylinderOrientations.

## ◆ Awake()

void GuidewireSim.SimulationLoop.Awake | ( |  | ) |
| private

## ◆ FixedUpdate()

void GuidewireSim.SimulationLoop.FixedUpdate | ( |  | ) |
| private

Requirements:
  Execute the simulation loop if and only if ExecuteSingleLoopTest is false.

## ◆ PerformConstraintSolvingStep()

void GuidewireSim.SimulationLoop.PerformConstraintSolvingStep | ( |  | ) |
| private

Performs the constraint solving step of the algorithm.

Requirements:

  Performs the constraint solving of every constraint #solverStep many times.

  Solve stretch constraints, if and only if solveStretchConstraints is true.

  Solve bend twist constraints, if and only if solveBendTwistConstraints is true.

  If solveStretchConstraints, then SpheresCount is at least two.

  If solveStretchConstraints, then CylinderCount is at least one.

  If solveBendTwistConstraints, then SpheresCount is at least three.

  If solveBendTwistConstraints, then CylinderCount is at least two.

  If solveStretchConstraints, after the step is complete the deviation between the actual rod element length and the default (rest state) rodElementLength should be close to zero.

  If solveStretchConstraints, after the step is complete the deviation of the stretch constraint to zero should be close to zero.

  If solveCollisionConstraints, after this step is complete clear the list `registeredCollisions`, since these collisions are now resolved.

## ◆ PerformInitializationStep()

void GuidewireSim.SimulationLoop.PerformInitializationStep | ( |  | ) |
| private

Calls every step that is mandatory to declare and initialize all data.

Requirements:

  Set SpheresCount to the length of spheres.

  Set CylinderCount to the length of cylinders.

  Call every init method of initializationStep.

## ◆ PerformPredictionStep()

void GuidewireSim.SimulationLoop.PerformPredictionStep | ( |  | ) |
| private

Performs the prediction step of the algorithm.

Requirements:

  Predict the sphereVelocities.

  Predict the spherePositionPredictions.

  Predict the cylinderAngularVelocities.

  Predict the cylinderOrientationPredictions.

## ◆ PerformSimulationLoop()

void GuidewireSim.SimulationLoop.PerformSimulationLoop | ( |  | ) |

Performs the outer simulation loop of the algorithm.

Note
  In a late version, CollisionDetection and GenerateCollisionConstraints will be added to the algorithm.

## ◆ PerformUpdateStep()

void GuidewireSim.SimulationLoop.PerformUpdateStep | ( |  | ) |
| private

Performs the update step of the algorithm.

Requirements:

  Upate sphereVelocities.

  Upate spherePositions.

  Upate cylinderAngularVelocities.

  Upate cylinderOrientations.

  Upate directors.

## ◆ SetCollidersStep()

void GuidewireSim.SimulationLoop.SetCollidersStep | ( |  | ) |
| private

Sets the position of the collider of each sphere of the guidewire to the sphere's position prediciton.

## ◆ Start()

void GuidewireSim.SimulationLoop.Start | ( |  | ) |
| private

## Member Data Documentation

## ◆ collisionHandler

CollisionHandler GuidewireSim.SimulationLoop.collisionHandler
| private

The component CollisionHandler that tracks all collisions.

## ◆ collisionSolvingStep

CollisionSolvingStep GuidewireSim.SimulationLoop.collisionSolvingStep
| private

The component CollisionSolvingStep that solves all collisions.

## ◆ constraintSolverSteps

int GuidewireSim.SimulationLoop.constraintSolverSteps = 1000
| private

How often the constraint solver iterates over each constraint during the Constraint Solving Step.

Attention
  This value must be positive.

## ◆ constraintSolvingStep

ConstraintSolvingStep GuidewireSim.SimulationLoop.constraintSolvingStep
| private

The component ConstraintSolvingStep that is responsible for correcting the predictions with the collision and model constraints.

## ◆ cylinderAngularVelocities

Vector3 [] GuidewireSim.SimulationLoop.cylinderAngularVelocities
| private

The angular velocity of the current frame of each orientation element/ cylinder. Initalized with zero entries.

## ◆ cylinderExternalTorques

Vector3 [] GuidewireSim.SimulationLoop.cylinderExternalTorques

The sum of all current external torques that are applied per orientation element/ cylinder.

## ◆ cylinderOrientationPredictions

BSM.Quaternion [] GuidewireSim.SimulationLoop.cylinderOrientationPredictions
| private

The prediction of the orientation of each cylinder at its center of mass.

## ◆ cylinderOrientations

BSM.Quaternion [] GuidewireSim.SimulationLoop.cylinderOrientations
| private

The orientation of each cylinder at its center of mass.

## ◆ cylinderPositions

Vector3 [] GuidewireSim.SimulationLoop.cylinderPositions

The center of mass of each cylinder.

## ◆ cylinders

GameObject [] GuidewireSim.SimulationLoop.cylinders
| private

All cylinders that are part of the guidewire.

Attention
  The order in which the cylinders are assigned matters. Assign them such that two adjacent cylinders are adjacent in the array as well.

## ◆ cylinderScalarWeights

float [] GuidewireSim.SimulationLoop.cylinderScalarWeights

The constant scalar weights of each orientation/ quaternion similar to sphereInverseMasses.

Note
  Set to 1 for moving orientations (so that angular motion can be applied) and to 0 for fixed orientations.

## ◆ directors

Vector3 [][] GuidewireSim.SimulationLoop.directors

The orthonormal basis of each orientation element / cylinder, also called directors.

Note
  In the 0th row are the first directors of each orientation element, not in the 1th row. Example: The (i, j)th element holds the (i-1)th director of orientation element j.

## ◆ discreteRestDarbouxVectors

Vector3 [] GuidewireSim.SimulationLoop.discreteRestDarbouxVectors
| private

The discrete Darboux Vector at the rest configuration, i.e. at frame 0.

Note
  It is important to only take the imaginary part in the calculation for the discrete Darboux Vector, thus we only save it as a Vector3. To use it in a quaternion setting, embedd the Vector3 with scalar part 0, i.e. with EmbeddedVector().

Attention
  There is only CylinderCount - 1 many darboux vectors. The i-th Darboux Vector is between orientation i and orientation i+1.

## ◆ inertiaTensor

float [,] GuidewireSim.SimulationLoop.inertiaTensor
| private

The inertia tensor. Entries are approximates as in the CoRdE paper.

## ◆ initializationStep

InitializationStep GuidewireSim.SimulationLoop.initializationStep
| private

The component InitializationStep that is responsible for initializing the simulation.

## ◆ inverseInertiaTensor

float [,] GuidewireSim.SimulationLoop.inverseInertiaTensor
| private

The inverse of inertiaTensor.

## ◆ mathHelper

MathHelper GuidewireSim.SimulationLoop.mathHelper
| private

The component MathHelper that provides math related helper functions.

## ◆ objectSetter

ObjectSetter GuidewireSim.SimulationLoop.objectSetter
| private

The component ObjectSetter that is responsible for setting all positions and rotations the the GameObjects.

## ◆ predictionStep

PredictionStep GuidewireSim.SimulationLoop.predictionStep
| private

The component PredictionStep that is responsible for executing the Prediction Step of the algorithm.

## ◆ rodElementLength

float GuidewireSim.SimulationLoop.rodElementLength = 10f
| private

The distance between two spheres, also the distance between two orientations. Also the length of one cylinder.

Note
  This should be two times the radius of a sphere.

Attention
  Make sure that the guidewire setup fulfilles that the distance between two adjacent spheres is rodElementLength.

## ◆ solveBendTwistConstraints

bool GuidewireSim.SimulationLoop.solveBendTwistConstraints = true

Whether or not to perform the constraint solving of the bend twist constraint.

## ◆ solveCollisionConstraints

bool GuidewireSim.SimulationLoop.solveCollisionConstraints = true

Whether or not to perform the constraint solving of collision constraints.

## ◆ solveStretchConstraints

bool GuidewireSim.SimulationLoop.solveStretchConstraints = true

Whether or not to perform the constraint solving of the stretch constraint.

## ◆ sphereExternalForces

Vector3 [] GuidewireSim.SimulationLoop.sphereExternalForces

The sum of all current external forces that are applied per particle/ sphere.

## ◆ sphereInverseMasses

float [] GuidewireSim.SimulationLoop.sphereInverseMasses

The constant inverse masses of each sphere.

Note
  Set to 1 for moving spheres and to 0 for fixed spheres.

## ◆ spherePositionPredictions

Vector3 [] GuidewireSim.SimulationLoop.spherePositionPredictions
| private

The prediction of the position at the current frame of each sphere.

## ◆ spherePositions

Vector3 [] GuidewireSim.SimulationLoop.spherePositions

The position at the current frame of each sphere.

## ◆ spheres

GameObject [] GuidewireSim.SimulationLoop.spheres

All spheres that are part of the guidewire.

Attention
  The order in which the spheres are assigned matters. Assign them such that two adjacent spheres are adjacent in the array as well.

## ◆ sphereVelocities

Vector3 [] GuidewireSim.SimulationLoop.sphereVelocities

The velocity of the current frame of each sphere. Initalized with zero entries.

## ◆ timeStep

float GuidewireSim.SimulationLoop.timeStep = 0.01f
| private

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.

## ◆ updateStep

UpdateStep GuidewireSim.SimulationLoop.updateStep
| private

The component UpdateStep that is responsible for executing the Update Step of the algorithm.

## ◆ worldSpaceBasis

BSM.Quaternion [] GuidewireSim.SimulationLoop.worldSpaceBasis
| private

The three basis vectors of the world coordinate system as embedded quaternions with scalar part 0. E.g. the first basis vector is (1, 0, 0), the second (0, 1, 0) and the third (0, 0, 1).

## Property Documentation

## ◆ ConstraintSolverSteps

int GuidewireSim.SimulationLoop.ConstraintSolverSteps
| get set

## ◆ CylinderCount

int GuidewireSim.SimulationLoop.CylinderCount
| get private set

The count of all cylinders of the guidewire.

## ◆ ExecuteSingleLoopTest

bool GuidewireSim.SimulationLoop.ExecuteSingleLoopTest = false
| get set

Whether or not to execute the Single Loop Test, in which the outer simulation loop is exactly executed once.

## ◆ SpheresCount

int GuidewireSim.SimulationLoop.SpheresCount
| get private set

The count of all spheres of the guidewire.

## ◆ TimeStep

float GuidewireSim.SimulationLoop.TimeStep
| get

The documentation for this class was generated from the following file:

- SimulationLoop.cs