Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update scene needleInteractionTest.py #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading