77g_needleRadius = 0.001 #(m)
88g_needleMechanicalParameters = {
99 "radius" :g_needleRadius ,
10- "youngModulus" :4e12 ,
10+ "youngModulus" :4e14 ,
1111 "poissonRatio" :0.3
1212}
13- g_needleTotalMass = 0.04
13+ g_needleTotalMass = 1.0
1414
1515g_gelRegularGridParameters = [
1616 {
3030 }
3131] #Again all in mm
3232g_gelMechanicalParameters = {
33- "youngModulus" :8e5 ,
33+ "youngModulus" :4e7 ,
3434 "poissonRatio" :0.45 ,
3535 "method" :"large"
3636}
37- g_gelTotalMass = 1
37+ g_gelTotalMass = 0. 1
3838g_cubeColor = [[0.8 , 0.34 , 0.34 , 0.3 ],[0.6 , 0.6 , 0 , 0.3 ],[1 , 1 , 1 , 0.3 ]]
3939g_wireColor = [[0.8 , 0.34 , 0.34 , 1 ],[0.6 , 0.6 , 0 , 1 ],[1 , 1 , 1 , 1 ]]
4040g_gelFixedBoxROI = [[- 0.155 , - 0.055 , - 0.255 , - 0.145 , 0.065 , - 0.095 ], [0.155 , - 0.055 , - 0.255 , 0.145 , 0.065 , - 0.095 ]]
4141
4242# Function called when the scene graph is being created
4343def createScene (root ):
4444 root .gravity = [0 ,0 ,0 ]
45- root .dt = 0.01
45+ root .dt = 0.005
4646
4747 root .addObject ("RequiredPlugin" ,pluginName = ['Sofa.Component.AnimationLoop' ,
4848 'Sofa.Component.Constraint.Lagrangian.Solver' ,
@@ -76,15 +76,33 @@ def createScene(root):
7676 root .addObject ("GenericConstraintSolver" , tolerance = 1e-5 , maxIt = 5000 , regularizationTerm = 1e-5 )
7777 root .addObject ("CollisionLoop" )
7878
79- needleBaseMaster = root .addChild ("NeedleBaseMaster" )
80- needleBaseMaster .addObject ("MechanicalObject" , name = "mstate_baseMaster" , position = [0.04 ,0.15 ,- 0.2 , 0 , 0 , 0 , 1 ], template = "Rigid3d" , showObjectScale = 0.002 , showObject = False , drawMode = 1 )
81- needleBaseMaster .addObject ("LinearMovementProjectiveConstraint" ,indices = [0 ], keyTimes = [0 ,1 ,7 ,8 ],movements =
82- [ [0.04 , 0.15 , 0.2 , 0 , 0 , 0 ]
83- , [0.04 , 0.30 , - 0.2 , - 3.14 / 2 , 0 , 0 ]
84- , [0.04 , 0.145 , - 0.2 , - 3.14 / 2 , 0 , 0 ]
85- , [0.03 , 0.145 , - 0.2 , - 3.14 / 2 + 3.14 / 16 , 0 , 0 ]
86- ],relativeMovements = False )
87-
79+ #needleBaseMaster = root.addChild("NeedleBaseMaster")
80+ #needleBaseMaster.addObject("MechanicalObject", name="mstate_baseMaster", position=[0.04,0.15,-0.2, 0, 0, 0, 1], template="Rigid3d", showObjectScale=0.002, showObject=False, drawMode=1)
81+ #needleBaseMaster.addObject("LinearMovementProjectiveConstraint",indices=[0], keyTimes=[0,1,7,8],movements=
82+ # [ [0.04, 0.15, 0.2, 0, 0, 0]
83+ # , [0.04, 0.30, -0.2, -3.14/2, 0, 0]
84+ # , [0.04, 0.145, -0.2, -3.14/2, 0, 0]
85+ # , [0.03, 0.145, -0.2, -3.14/2 + 3.14/16, 0, 0]
86+ #],relativeMovements=False)
87+
88+ toolController = root .addChild ("ToolController" )
89+ toolController .addObject ("GeomagicDriver"
90+ , name = 'GeomagicDevice'
91+ , deviceName = 'Default Device'
92+ , scale = 0.02
93+ , drawDeviceFrame = False
94+ , drawDevice = False
95+ , manualStart = False
96+ , positionBase = [0.12 , 0 , 0 ]
97+ , orientationBase = [0 , 0.174 , 0 , - 0.985 ]
98+ )
99+ toolController .addObject ("MechanicalObject" , name = "mstate_baseMaster"
100+ , position = "@GeomagicDevice.positionDevice"
101+ , template = "Rigid3d"
102+ , showObjectScale = 0.01
103+ , showObject = False
104+ , drawMode = 1
105+ )
88106
89107 needle = root .addChild ("Needle" )
90108 needle .addObject ("EulerImplicitSolver" , firstOrder = True )
@@ -99,11 +117,12 @@ def createScene(root):
99117 needle .addObject ("UniformMass" , totalMass = g_needleTotalMass )
100118 needle .addObject ("BeamFEMForceField" , name = "FEM" , ** g_needleMechanicalParameters )
101119 needle .addObject ("LinearSolverConstraintCorrection" , printLog = False , linearSolver = "@LinearSolver" )
120+ needle .addObject ("RestShapeSpringsForceField" ,points = [0 ], stiffness = 1e8 , angularStiffness = 1e8 , external_points = [0 ], external_rest_shape = "@/ToolController/mstate_baseMaster" )
102121
103122 needleBase = needle .addChild ("needleBase" )
104123 needleBase .addObject ("PointSetTopologyContainer" , name = "Container_base" , position = [0 , 0 , 0 ])
105124 needleBase .addObject ("MechanicalObject" ,name = "mstate_base" , template = "Rigid3d" ,)
106- needleBase .addObject ("RestShapeSpringsForceField" ,points = [0 ],stiffness = 1e8 , angularStiffness = 1e8 ,external_points = [0 ],external_rest_shape = "@/NeedleBaseMaster/mstate_baseMaster" )
125+ # needleBase.addObject("RestShapeSpringsForceField",points=[0],stiffness=1e8, angularStiffness=1e8,external_points=[0],external_rest_shape="@/NeedleBaseMaster/mstate_baseMaster")
107126 needleBase .addObject ("SubsetMapping" , indices = "0" )
108127
109128 needleBodyCollision = needle .addChild ("bodyCollision" )
@@ -136,7 +155,18 @@ def createScene(root):
136155 name = "visualOgl" )
137156 needleOGL .addObject ("IdentityMapping" )
138157
139-
158+ FF = root .addChild ("ForceFeedback" )
159+ FF .addObject ("MechanicalObject" , name = "mstate_lcp" , template = "Rigid3d"
160+ , showObject = False , src = "@../Needle/needleBase/mstate_base" )
161+ FF .addObject ("LCPForceFeedback" , name = "lcp_ff" , activate = 1 , forceCoef = 0.0015 )
162+ FFBody = FF .addChild ("Body" )
163+ FFBody .addObject ("EdgeSetTopologyContainer" , name = "Container" , src = "@../../Needle/bodyCollision/Container_body" )
164+ FFBody .addObject ("MechanicalObject" , name = "mstate_coli" , constraint = "@../../Needle/bodyCollision/mstate_body.constraint" )
165+ FFBody .addObject ("RigidMapping" )
166+ FFTip = FF .addChild ("Tip" )
167+ FFTip .addObject ("PointSetTopologyContainer" , name = "Container" , src = "@../../Needle/tipCollision/Container_tip" )
168+ FFTip .addObject ("MechanicalObject" , name = "mstate_coli" , constraint = "@../../Needle/tipCollision/mstate_tip.constraint" )
169+ FFTip .addObject ("RigidMapping" )
140170
141171 for i in range (0 ,3 ):
142172 gelGridTopoName = "GelGridTopo" + str (i )
@@ -201,7 +231,7 @@ def createScene(root):
201231
202232 for i in range (0 ,3 ):
203233 algo = root .addChild ("algo" + str (i ))
204- punctureForce = 1.5 if i < 2 else 2000
234+ punctureForce = 500 if i < 2 else 2000
205235 algo .addObject ("InsertionAlgorithm" , name = "InsertionAlgo" + str (i ),
206236 tipGeom = "@/Needle/tipCollision/geom_tip" ,
207237 surfGeom = "@/Layer" + str (i )+ "/collision/geom_tri" ,
0 commit comments