Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def createScene(rootNode):
bunny.addObject('FastTetrahedralCorotationalForceField', template='Vec3', name='FEM', method='large', poissonRatio='0.3', youngModulus='10000')

bunny.addObject('BoxROI', name='boxROI', box=[-5, -5.0, -5, 5, -4.5, 5], drawBoxes=True)
bunny.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness='1e12')
bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness='1e12')

bunny.addObject('GenericConstraintCorrection')

Expand Down
4 changes: 2 additions & 2 deletions examples/component/constraint/CableConstraint/Finger.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def createScene(rootNode):

# RestShapeSpringsForceField is one way in Sofa to implement fixed point constraint.
# Here the constraints are applied to the DoFs selected by the previously defined BoxROI
finger.addObject('RestShapeSpringsForceField', points=finger.roi.indices.getLinkPath(), stiffness=1e12)
finger.addObject('FixedWeakConstraint', indices=finger.roi.indices.getLinkPath(), stiffness=1e12)

# It is also possible to simply set by hand the indices of the points you want to fix.
# finger.addObject('RestShapeSpringsForceField', points=[0, 1, 2, 11, 55], stiffness=1e12)
# finger.addObject('RestShapeSpringsForceField', indices=[0, 1, 2, 11, 55], stiffness=1e12)

finger.addObject('GenericConstraintCorrection')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def createScene(rootNode):

# RestShapeSpringsForceField is one way in Sofa to implement fixed point constraint.
# Here the constraints are applied to the DoFs selected by the previously defined BoxROI
finger.addObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness=1e12)
finger.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12)

##########################################
# Cable #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def createScene(rootNode):

object = simulation.addChild('Object')
object.addObject('MechanicalObject', template='Vec1', position=0.)
object.addObject("RestShapeSpringsForceField", points=[0], stiffness=1e1)
object.addObject("FixedWeakConstraint", indices=[0], stiffness=1e1)
# Try to change the data field "value" from the GUI
object.addObject('JointConstraint', template='Vec1', index=0, value=0, valueType="displacement",
minDisplacement=-pi, maxDisplacement=pi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def createScene(rootNode):
youngModulus=500)

accordion.addObject('BoxROI', name='ROI1', box=[-2, -2, 0, 2, 2, 0.5], drawBoxes=True)
accordion.addObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness=1e12)
accordion.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12)
# accordion.addObject('FixedProjectiveConstraint', indices='@ROI1.indices')

accordion.addObject('LinearSolverConstraintCorrection')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def createScene(rootNode):

bunny.addObject('BoxROI', name='boxROI', box=[-5, -7, -5, 5, -4.5, 5], drawBoxes=True,
position="@tetras.rest_position", tetrahedra="@container.tetrahedra")
bunny.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12)
bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12)
bunny.addObject('LinearSolverConstraintCorrection')

# bunny/cavity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def createScene(rootNode):
tentacle.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3, youngModulus=200)

tentacle.addObject('BoxROI', name='ROI1', box=[[50, -20, 30],[75, 20, 50]], drawBoxes=True)
tentacle.addObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness=1e12)
tentacle.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12)

tentacle.addObject('LinearSolverConstraintCorrection')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def addAccordion(node, inverse=False):
accordion.addObject('UniformMass', totalMass=0.030)
accordion.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3, youngModulus=500)
accordion.addObject('BoxROI', name='ROI1', box=[-2, -2, 0, 2, 2, 0.5], drawBoxes=True)
accordion.addObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness=1e12)
accordion.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12)
accordion.addObject('LinearSolverConstraintCorrection')

# Pressure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def createScene(rootNode):
youngModulus=500)

accordion.addObject('BoxROI', name='ROI1', box=[-2, -2, 0, 2, 2, 0.5], drawBoxes=True)
accordion.addObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness=1e12)
accordion.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12)

accordion.addObject('LinearSolverConstraintCorrection')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def createScene(rootNode):
beam.addObject('BeamInterpolation', name='interpol', crossSectionShape='rectangular', lengthY=5, lengthZ=5,
defaultYoungModulus=1.8e6)
beam.addObject('AdaptiveBeamForceFieldAndMass', name="BeamForceField", computeMass=1, massDensity=0.001)
beam.addObject('RestShapeSpringsForceField', points=0, stiffness=100e10, angularStiffness=100e10)
beam.addObject('FixedWeakConstraint', indices=0, stiffness=100e10, angularStiffness=100e10)

# Visualization
visuNode = beam.addChild('visualization')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def createScene(rootNode):

# RestShapeSpringsForceField is one way in Sofa to implement fixed point constraint.
# Here the constraints are applied to the DoFs selected by the previously defined BoxROI
finger.addObject('RestShapeSpringsForceField', points='@ROI.indices', stiffness=1e12)
finger.addObject('FixedWeakConstraint', indices='@ROI.indices', stiffness=1e12)

# It is also possible to simply set by hand the indices of the points you want to fix.
# finger.addObject('RestShapeSpringsForceField', points=[0, 1, 2, 11, 55], stiffness=1e12)
# finger.addObject('RestShapeSpringsForceField', indices=[0, 1, 2, 11, 55], stiffness=1e12)

finger.addObject('LinearSolverConstraintCorrection')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def createScene(rootNode):

# RestShapeSpringsForceField is one way in Sofa to implement fixed point constraint.
# Here the constraints are applied to the DoFs selected by the previously defined BoxROI
finger.addObject('RestShapeSpringsForceField', points='@ROI.indices', stiffness=1e12)
finger.addObject('FixedWeakConstraint', indices='@ROI.indices', stiffness=1e12)

finger.addObject('LinearSolverConstraintCorrection')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def createScene(rootNode):

bunny.addObject('BoxROI', name='boxROI', box=[-5, -15, -5, 5, -4.5, 5], drawBoxes=True,
position="@tetras.rest_position", tetrahedra="@container.tetrahedra")
bunny.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12)
bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12)
bunny.addObject('LinearSolverConstraintCorrection')

# bunny/cavity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def createScene(rootNode):

bunny.addObject('BoxROI', name='boxROI', box=[-5, -15, -5, 5, -4.5, 5], drawBoxes=True,
position="@tetras.rest_position", tetrahedra="@container.tetrahedra")
bunny.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12)
bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12)
bunny.addObject('LinearSolverConstraintCorrection')

# bunny/cavity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,9 @@ def createScene(rootNode):

robot.addObject('LinearSolverConstraintCorrection')

leg0 = rootNode.addChild('RestPositionLeg0')
leg0.addObject('MechanicalObject', name='meca0', template='Vec3', showObject=True, showObjectScale=15,
showIndices=False, showIndicesScale=4e-5,
position='@../robot/boxROI1.pointsInROI')
leg1 = rootNode.addChild('RestPositionLeg1')
leg1.addObject('MechanicalObject', name='meca1', template='Vec3', showObject=True, showObjectScale=15,
showIndices=False, showIndicesScale=4e-5,
position='@../robot/boxROI2.pointsInROI')
leg2 = rootNode.addChild('RestPositionLeg2')
leg2.addObject('MechanicalObject', name='meca2', template='Vec3', showObject=True, showObjectScale=15,
showIndices=False, showIndicesScale=4e-5,
position='@../robot/boxROI3.pointsInROI')

robot.addObject('RestShapeSpringsForceField', name='fixed1', points="@boxROI1.indices",
external_rest_shape="@RestPositionLeg0/meca0", stiffness=1e3)
robot.addObject('RestShapeSpringsForceField', name='fixed2', points="@boxROI2.indices",
external_rest_shape="@RestPositionLeg1/meca1", stiffness=1e3)
robot.addObject('RestShapeSpringsForceField', name='fixed3', points="@boxROI3.indices",
external_rest_shape="@RestPositionLeg2/meca2", stiffness=1e3)
robot.addObject('FixedWeakConstraint', name='fixed1', indices="@boxROI1.indices", stiffness=1e3)
robot.addObject('FixedWeakConstraint', name='fixed2', indices="@boxROI2.indices", stiffness=1e3)
robot.addObject('FixedWeakConstraint', name='fixed3', indices="@boxROI3.indices", stiffness=1e3)

###############################
# VISUAL MODEL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def createScene(rootNode):
finger.addObject('UniformMass', totalMass=0.04)
boxROISubTopo = finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
boxROI = finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)
finger.addObject('FixedWeakConstraint', indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)

modelSubTopo = finger.addChild('SubTopology')
modelSubTopo.addObject('MeshTopology', position='@loader.position', name='container',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def createScene(rootNode):
finger.addObject('UniformMass', totalMass=0.04)
boxROISubTopo = finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
boxROI = finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)
finger.addObject('FixedWeakConstraint', indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)

modelSubTopo = finger.addChild('SubTopology')
modelSubTopo.addObject('MeshTopology', position='@loader.position', tetrahedra=boxROISubTopo.tetrahedraInROI.linkpath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def createScene(rootNode):
finger.addObject('UniformMass', totalMass=0.04)
boxROISubTopo = finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
boxROI = finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)
finger.addObject('FixedWeakConstraint', indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12)
finger.addObject('GenericConstraintCorrection')

modelSubTopo = finger.addChild('SubTopology')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ def createScene(rootNode):
if i == 0:
boxROI = finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20], doUpdate=False)
boxROISubTopo = finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False)
finger.addObject('RestShapeSpringsForceField',
points=boxROI.indices.linkpath,
finger.addObject('FixedWeakConstraint',
indices=boxROI.indices.linkpath,
stiffness=1e12, angularStiffness=1e12)
finger.addObject('GenericConstraintCorrection')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def createScene(rootNode):
finger.integration.rayleighMass = 0.1

finger.addObject('BoxROI', name='boxROI', box=fingersParameters[i]['ROIBox'], drawBoxes=True, doUpdate=False)
finger.addObject('RestShapeSpringsForceField', points='@../Finger1/boxROI.indices', stiffness=1e12,
finger.addObject('FixedWeakConstraint', indices='@../Finger1/boxROI.indices', stiffness=1e12,
angularStiffness=1e12)

PneumaticCavity(surfaceMeshFileName=fingersCavitySurfaceMesh,
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorials/PneunetGripper/pneunetgripper-tuto.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ <h3 id="stiff-layer">Stiff layer</h3>
<a class="sourceLine" id="cb6-4" title="4">modelSubTopo.addObject(<span class="st">&#39;TetrahedronFEMForceField&#39;</span>, template<span class="op">=</span><span class="st">&#39;Vec3d&#39;</span>, name<span class="op">=</span><span class="st">&#39;FEM&#39;</span>, method<span class="op">=</span><span class="st">&#39;large&#39;</span>, poissonRatio<span class="op">=</span><span class="fl">0.3</span>, youngModulus<span class="op">=</span><span class="dv">1500</span>)</a></code></pre></div>
<p><a href="details/step3-stiffLayer.py">Step3</a></p>
<h2 id="boundary-conditions">Boundary Conditions</h2>
<p>To fix the finger in space, it is necessary to define boundary conditions on some parts of the object. This can be done in several ways in SOFA. In this case, we use the component RestShapeSpringsForceField, which creates springs between the current position of a part of the body and its initial position. The stiffness of these springs can be adjusted. In particular, setting a very large stiffness will be equivalent to fixing the points in space. To easily define the indices of the points which will be fixed, we use the boxROI component:</p>
<p>To fix the finger in space, it is necessary to define boundary conditions on some parts of the object. This can be done in several ways in SOFA. In this case, we use the component FixedWeakConstraint, which creates springs between the current position of a part of the body and its initial position. The stiffness of these springs can be adjusted. In particular, setting a very large stiffness will be equivalent to fixing the points in space. To easily define the indices of the points which will be fixed, we use the boxROI component:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb7-1" title="1">finger.addObject(<span class="st">&#39;BoxROI&#39;</span>, name<span class="op">=</span><span class="st">&#39;boxROI&#39;</span>, box<span class="op">=</span>[<span class="op">-</span><span class="dv">10</span>, <span class="dv">0</span>, <span class="dv">-20</span>, <span class="dv">0</span>, <span class="dv">30</span>, <span class="dv">20</span>])</a>
<a class="sourceLine" id="cb7-2" title="2">finger.addObject(<span class="st">&#39;RestShapeSpringsForceField&#39;</span>, points<span class="op">=</span><span class="st">&#39;@boxROI.indices&#39;</span>, stiffness<span class="op">=</span><span class="fl">1e12</span>, angularStiffness<span class="op">=</span><span class="fl">1e12</span>)</a></code></pre></div>
<a class="sourceLine" id="cb7-2" title="2">finger.addObject(<span class="st">&#39;FixedWeakConstraint&#39;</span>, indices<span class="op">=</span><span class="st">&#39;@boxROI.indices&#39;</span>, stiffness<span class="op">=</span><span class="fl">1e12</span>, angularStiffness<span class="op">=</span><span class="fl">1e12</span>)</a></code></pre></div>
<p><a href="details/step4-boundaryConditions.py">Step4</a></p>
<h2 id="implicit-time-integration-and-matrix-solver">Implicit Time Integration and Matrix Solver</h2>
<p>Now that all the minimal elements of the scene have been described, it is already possible to simulate the deformation of the finger. To do that, we need to define a time integration scheme, which will define the system to be solved at each time step of the simulation, as well as a matrix solver, to solve that system and compute the updated velocities and positions of the nodes of the robot. In this case, we choose to use an Implicit Euler Scheme and a sparse direct Solver base on an LDL matrix decomposition:</p>
Expand Down Expand Up @@ -271,9 +271,9 @@ <h2 id="appendix">Appendix</h2>
<a class="sourceLine" id="cb18-84" title="84"> finger.addObject(<span class="st">&#39;BoxROI&#39;</span>, name<span class="op">=</span><span class="st">&#39;boxROI&#39;</span>, box<span class="op">=</span>[<span class="op">-</span><span class="dv">10</span>, <span class="dv">0</span>, <span class="dv">-20</span>, <span class="dv">0</span>, <span class="dv">30</span>, <span class="dv">20</span>])</a>
<a class="sourceLine" id="cb18-85" title="85"> finger.addObject(<span class="st">&#39;BoxROI&#39;</span>, name<span class="op">=</span><span class="st">&#39;boxROISubTopo&#39;</span>, box<span class="op">=</span>[<span class="op">-</span><span class="dv">100</span>, <span class="fl">22.5</span>, <span class="dv">-8</span>, <span class="dv">-19</span>, <span class="dv">28</span>, <span class="dv">8</span>], strict<span class="op">=</span><span class="va">False</span>)</a>
<a class="sourceLine" id="cb18-86" title="86"> <span class="cf">if</span> i <span class="op">==</span> <span class="dv">0</span>:</a>
<a class="sourceLine" id="cb18-87" title="87"> finger.addObject(<span class="st">&#39;RestShapeSpringsForceField&#39;</span>, points<span class="op">=</span><span class="st">&#39;@boxROI.indices&#39;</span>, stiffness<span class="op">=</span><span class="fl">1e12</span>, angularStiffness<span class="op">=</span><span class="fl">1e12</span>)</a>
<a class="sourceLine" id="cb18-87" title="87"> finger.addObject(<span class="st">&#39;FixedWeakConstraint&#39;</span>, indices<span class="op">=</span><span class="st">&#39;@boxROI.indices&#39;</span>, stiffness<span class="op">=</span><span class="fl">1e12</span>, angularStiffness<span class="op">=</span><span class="fl">1e12</span>)</a>
<a class="sourceLine" id="cb18-88" title="88"> <span class="cf">else</span>:</a>
<a class="sourceLine" id="cb18-89" title="89"> finger.addObject(<span class="st">&#39;RestShapeSpringsForceField&#39;</span>, points<span class="op">=</span><span class="st">&#39;@../finger1/boxROI.indices&#39;</span>, stiffness<span class="op">=</span><span class="fl">1e12</span>, angularStiffness<span class="op">=</span><span class="fl">1e12</span>)</a>
<a class="sourceLine" id="cb18-89" title="89"> finger.addObject(<span class="st">&#39;FixedWeakConstraint&#39;</span>, indices<span class="op">=</span><span class="st">&#39;@../finger1/boxROI.indices&#39;</span>, stiffness<span class="op">=</span><span class="fl">1e12</span>, angularStiffness<span class="op">=</span><span class="fl">1e12</span>)</a>
<a class="sourceLine" id="cb18-90" title="90"></a>
<a class="sourceLine" id="cb18-91" title="91"> finger.addObject(<span class="st">&#39;LinearSolverConstraintCorrection&#39;</span>, solverName<span class="op">=</span><span class="st">&#39;preconditioner&#39;</span>)</a>
<a class="sourceLine" id="cb18-92" title="92"></a>
Expand Down
Loading
Loading