Skip to content

Commit

Permalink
update scene needleInteractionTest.py
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger committed Dec 3, 2024
1 parent ad8b012 commit e495554
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions examples/python3/wip/needleInteractionTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Based on the work done with SofaPython. See POEMapping.py
"""

from params import NeedleParameters
from cosserat.needle.params import NeedleParameters, GeometryParams, PhysicsParams, FemParams, ContactParams
from cosserat.usefulFunctions import pluginList
from cosserat.createFemRegularGrid import createFemCubeWithParams
from cosserat.cosseratObject import Cosserat
Expand All @@ -20,12 +20,9 @@
__copyright__ = "(c) 2021,Inria"
__date__ = "March 8 2021"


params = NeedleParameters()

needleGeometryConfig = {'init_pos': [0., 0., 0.], 'tot_length': params.Geometry.totalLength,
'nbSectionS': params.Geometry.nbSections, 'nbFramesF': params.Geometry.nbFrames,
'buildCollisionModel': 1, 'beamMass': params.Physics.mass}
needleGeometryConfig = {'init_pos': [0., 0., 0.], 'tot_length': GeometryParams.totalLength,
'nbSectionS': GeometryParams.nbSections, 'nbFramesF': GeometryParams.nbFrames,
'buildCollisionModel': 1, 'beamMass': PhysicsParams.mass}


class Animation(Sofa.Core.Controller):
Expand Down Expand Up @@ -142,18 +139,18 @@ def createScene(rootNode):
'RequiredPlugin', pluginName=pluginList, printLog='0')

rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels hideCollisionModels '
'hideBoundingCollisionModels hireForceFields '
'hideBoundingCollisionModels hideForceFields '
'hideInteractionForceFields hideWireframe showMechanicalMappings')
rootNode.addObject('DefaultPipeline')
rootNode.addObject('CollisionPipeline')
rootNode.addObject("DefaultVisualManagerLoop")
rootNode.addObject('RuleBasedContactManager',
responseParams='mu=0.1', response='FrictionContactConstraint')
rootNode.addObject('BruteForceBroadPhase')
rootNode.addObject('BVHNarrowPhase')
# rootNode.addObject('LocalMinDistance', alarmDistance=1.0, contactDistance=0.01)
rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance=0.5,
contactDistance=params.contact.contactDistance,
coneFactor=params.contact.coneFactor, angleCone=0.1)
contactDistance=ContactParams.contactDistance,
coneFactor=ContactParams.coneFactor, angleCone=0.1)

rootNode.addObject('FreeMotionAnimationLoop')
generic = rootNode.addObject('GenericConstraintSolver', tolerance="1e-20",
Expand All @@ -168,16 +165,15 @@ def createScene(rootNode):
###############
solverNode = rootNode.addChild('solverNode')
solverNode.addObject('EulerImplicitSolver',
rayleighStiffness=params.Physics.rayleighStiffness)
rayleighStiffness=PhysicsParams.rayleighStiffness)
solverNode.addObject('SparseLDLSolver', name='solver',
template="CompressedRowSparseMatrixd")
solverNode.addObject('GenericConstraintCorrection')

needle = solverNode.addChild(
Cosserat(parent=solverNode, cosseratGeometry=needleGeometryConfig, radius=params.Geometry.radius,
name="needle", youngModulus=params.Physics.youngModulus, poissonRatio=params.Physics.poissonRatio,
rayleighStiffness=params.Physics.rayleighStiffness))
needleCollisionModel = needle.addPointCollisionModel()
needle = Cosserat(parent=solverNode, cosseratGeometry=needleGeometryConfig, radius=GeometryParams.radius,
name="needle", youngModulus=PhysicsParams.youngModulus, poissonRatio=PhysicsParams.poissonRatio,
rayleighStiffness=PhysicsParams.rayleighStiffness)
needleCollisionModel = needle.addPointCollisionModel("needleCollision")
slidingPoint = needle.addSlidingPoints()

# Create FEM Node
Expand All @@ -186,7 +182,7 @@ def createScene(rootNode):
# TODO: @Paul is in charge of creating this in python
#
femPos = []
cubeNode = createFemCubeWithParams(rootNode, params.FemParams)
cubeNode = createFemCubeWithParams(rootNode, FemParams)
gelNode = cubeNode.getChild('gelNode')
femPoints = gelNode.addChild('femPoints')
inputFEMCable = femPoints.addObject(
Expand All @@ -204,7 +200,7 @@ def createScene(rootNode):

conttactL = rootNode.addObject('ContactListener', name="contactListener",
collisionModel1=cubeNode.gelNode.surfaceNode.surface.getLinkPath(),
collisionModel2=needleCollisionModel.pointColli.getLinkPath())
collisionModel2=needleCollisionModel.collisionStats.getLinkPath())
rootNode.addObject(Animation(needle.rigidBaseNode.RigidBaseMO, needle.cosseratCoordinateNode.cosseratCoordinateMO,
conttactL, generic, needleCollisionModel, inputFEMCable))
mappedPointsNode.addObject(
Expand Down

0 comments on commit e495554

Please sign in to comment.