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

Apply SOFA PR 4750 changes #148

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions examples/python3/NeedleInsertion-predefinedPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def createScene(rootNode):
rigidBaseNode = cableNode.addChild('rigidBase')
RigidBaseMO = rigidBaseNode.addObject('MechanicalObject', template='Rigid3d', name="RigidBaseMO",
position="0 0 0 0 0 0 1", showObject='1', showObjectScale='5.')
rigidBaseNode.addObject('RestShapeSpringsForceField', name='spring', stiffness="50000",
angularStiffness="50000", external_points="0", mstate="@RigidBaseMO", points="0",
rigidBaseNode.addObject('FixedWeakConstraint', name='spring', stiffness="50000",
angularStiffness="50000", mstate="@RigidBaseMO", indices="0",
template="Rigid3d")

###############
Expand Down
4 changes: 2 additions & 2 deletions examples/python3/PNLS_Example3.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def createScene(rootNode):
showObjectScale=0.3, position=[length, 0, 0, 0, 0, 0, 1], showObject=True)

beamFrame.addObject('RestShapeSpringsForceField', name='spring',
stiffness=1e8, angularStiffness=1e8, external_points=0,
external_rest_shape=controlMo.getLinkPath(), points=nbFrames, template="Rigid3d")
stiffness=1e8, angularStiffness=1e8, externalIndices=0,
external_rest_shape=controlMo.getLinkPath(), indices=nbFrames, template="Rigid3d")

cosseratNode = nonLinearCosserat.legendreControlPointsNode

Expand Down
7 changes: 4 additions & 3 deletions examples/python3/cosserat/CosseratBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ def _addSlidingPointsWithContainer(self):
return slidingPoint

def _addRigidBaseNode(self):

rigidBaseNode = create_rigid_node(self, "RigidBase",
self.translation, self.rotation)

return rigidBaseNode

def _add_cosserat_coordinate(self, initial_curvature: List[float], section_lengths: List[float]):
Expand Down Expand Up @@ -244,13 +246,12 @@ def createScene(rootNode):
# Create a
cosserat = solverNode.addChild(CosseratBase(parent=solverNode, beam_params=Params))
cosserat.rigidBaseNode.addObject(
"RestShapeSpringsForceField",
"FixedWeakConstraint",
name="spring",
stiffness=1e8,
angularStiffness=1.0e8,
external_points=0,
# mstate="@RigidBaseMO",
points=0,
indices=0,
template="Rigid3d"
)

Expand Down
5 changes: 2 additions & 3 deletions examples/python3/cosserat/cosseratObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,12 @@ def addRigidBaseNode(self):
if int(self.attachingToLink.value):
print("Adding the rest shape to the base")
rigidBaseNode.addObject(
"RestShapeSpringsForceField",
"FixedWeakConstraint",
name="spring",
stiffness=1e8,
angularStiffness=1.0e8,
external_points=0,
mstate="@RigidBaseMO",
points=0,
indices=0,
template="Rigid3d",
)
return rigidBaseNode
Expand Down
4 changes: 2 additions & 2 deletions examples/python3/cosserat/createFemRegularGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def createFemCube(parentNode):
gelNode.addObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large',
poissonRatio='0.45', youngModulus='100')
gelNode.addObject('BoxROI', name='ROI1', box='40 -17 -10 100 -14 10', drawBoxes='true')
gelNode.addObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness='1e12')
gelNode.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness='1e12')

surfaceNode = gelNode.addChild("surfaceNode")
surfaceNode.addObject('TriangleSetTopologyContainer', name="surfContainer", src="@../../GelSurface/Container")
Expand Down Expand Up @@ -72,7 +72,7 @@ def createFemCubeWithParams(parentNode, geometry):
gelNode.addObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large',
poissonRatio=geometry.poissonRatio, youngModulus=geometry.youngModulus)
gelNode.addObject('BoxROI', name='ROI1', box=geometry.box, drawBoxes='true')
gelNode.addObject('RestShapeSpringsForceField', points='@ROI1.indices', stiffness='1e12')
gelNode.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness='1e12')

surfaceNode = gelNode.addChild("surfaceNode")
surfaceNode.addObject('TriangleSetTopologyContainer', name="surfContainer",
Expand Down
6 changes: 3 additions & 3 deletions examples/python3/cosserat/nonLinearCosserat.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def addRigidBaseNode(self):
# one can choose to set this to false and directly attach the beam base
# to a control object in order to be able to drive it.
if int(self.attachingToLink.value):
rigidBaseNode.addObject('RestShapeSpringsForceField', name='spring',
stiffness=1e14, angularStiffness=1.e14, external_points=0,
mstate="@RigidBaseMO", points=0, template="Rigid3d")
rigidBaseNode.addObject('FixedWeakConstraint', name='spring',
stiffness=1e14, angularStiffness=1.e14,
mstate="@RigidBaseMO", indices=0, template="Rigid3d")
return rigidBaseNode

def addLegendrePolynomialsNode(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/python3/tutorial/formation/chiba/Actuator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def createScene(rootNode):
finger.addObject('BoxROI', name='boxROISubTopo', box=[23, -10, -8, 26, 10, 8], strict=False, drawBoxes=True)
finger.addObject('BoxROI', name='boxROISubTopo2', box=[0, -10, -4, 28, 10, -2], strict=False, drawBoxes=True)
finger.addObject('BoxROI', name='boxROI', box=[-2, -10, -20, 2, 10, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12, angularStiffness=1e12)
finger.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12)
finger.addObject('LinearSolverConstraintCorrection')
#Plastic Part
modelSubTopo = finger.addChild('modelSubTopo')
Expand Down
2 changes: 1 addition & 1 deletion examples/python3/tutorial/formation/chiba/actuator_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def createScene(root_node):
finger.addObject('BoxROI', name='boxROISubTopo', box=[23, -10, -8, 26, 10, 8], strict=False, drawBoxes=True)
finger.addObject('BoxROI', name='boxROISubTopo2', box=[0, -10, -4, 28, 10, -2], strict=False, drawBoxes=True)
finger.addObject('BoxROI', name='boxROI', box=[-2, -10, -20, 2, 10, 20], drawBoxes=True)
finger.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12, angularStiffness=1e12)
finger.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12)
finger.addObject('LinearSolverConstraintCorrection')
# Plastic Part
modelSubTopo = finger.addChild('modelSubTopo')
Expand Down
4 changes: 2 additions & 2 deletions examples/python3/tutorial/scene_w9991.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def _add_rigid_base(p_node):
rigid_base_node = p_node.addChild('rigid_base')
rigid_base_node.addObject('MechanicalObject', template="Rigid3d", name="cosserat_base_mo",
position="0 0 0 0 0 0. 1", showObject=1, showObjectScale="0.1")
rigid_base_node.addObject('RestShapeSpringsForceField', template="Rigid3d", name="spring",
rigid_base_node.addObject('FixedWeakConstraint', template="Rigid3d", name="spring",
stiffness=stiffness_param, angularStiffness=stiffness_param,
mstate="@cosserat_base_mo", external_points="0", points="0")
mstate="@cosserat_base_mo", externalIndices="0", indices="0")
return rigid_base_node


Expand Down
5 changes: 3 additions & 2 deletions examples/python3/useful/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ def addSolverNode(parent_node, name='solverNode', template='CompressedRowSparseM

def attach_mesh_with_springs(mesh_node, _box='-18 -15 -8 2 -3 8'):
mesh_node.addObject('BoxROI', name='ROI1', box=_box, drawBoxes='true')
mesh_node.addObject('RestShapeSpringsForceField',
points='@ROI1.indices', stiffness='1e12')
mesh_node.addObject('FixedWeakConstraint',
indices='@ROI1.indices', stiffness='1e12')

def attach_3d_points_to_meca_with_barycentric_mapping(parent_node, name='node_name',
list_of_points=[" 0.0 0 0 15 0 0 30 0 0 45 0 0 60 0 0 66 0 0 81 0.0 0.0"]):
Expand Down Expand Up @@ -188,6 +188,7 @@ def add_finger_mesh_force_field_Object(parent_node, path):
poissonRatio='0.45', youngModulus='500')
attach_mesh_with_springs(parent_node)


# Mapped points inside the finger volume, these points attached to the FE model
# are constrained to slide on the cable.
points_node = attach_3d_points_to_meca_with_barycentric_mapping(parent_node)
Expand Down
4 changes: 2 additions & 2 deletions examples/python3/wip/completDirectNeedleInsertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def createScene(rootNode):
RigidBaseMO = rigidBaseNode.addObject('MechanicalObject', template='Rigid3d', name="RigidBaseMO",
position="0 0 0 0 0 0 1", translation="-40. 0. 0.", showObject='1',
showObjectScale='5.')
rigidBaseNode.addObject('RestShapeSpringsForceField', name='spring', stiffness="50000",
angularStiffness="50000", external_points="0", mstate="@RigidBaseMO", points="0",
rigidBaseNode.addObject('FixedWeakConstraint', name='spring', stiffness="50000",
angularStiffness="50000", mstate="@RigidBaseMO", indices="0",
template="Rigid3d")

#############################################
Expand Down
2 changes: 1 addition & 1 deletion tutorial/text/cosserat_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Now, we'll dive into the essential part – configuring the Cosserat plugin with
def _add_rigid_base(p_node):
rigid_base_node = p_node.addChild('rigid_base')
rigid_base_node.addObject('MechanicalObject', template='Rigid3d', name="cosserat_base_mo", position="0 0 0 0 0 0. 1", showObject=1, showObjectScale='0.1')
rigid_base_node.addObject('RestShapeSpringsForceField', name='spring', stiffness=stiffness_param, angularStiffness=stiffness_param, external_points="0", mstate="@cosserat_base_mo", points="0", template="Rigid3d")
rigid_base_node.addObject('FixedWeakConstraint', name='spring', stiffness=stiffness_param, angularStiffness=stiffness_param, mstate="@cosserat_base_mo", indices="0", template="Rigid3d")
return rigid_base_node
```

Expand Down
5 changes: 2 additions & 3 deletions tutorial/tuto_scenes/geo_cable_driven_cosserat_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ def createScene(root_node):
beam = solver_node.addChild(CosseratBase(parent=solver_node, beam_params=Params))
# Attach beam base using a spring force field
beam.rigidBaseNode.addObject(
"RestShapeSpringsForceField",
"FixedWeakConstraint",
name="spring",
stiffness=1e8,
angularStiffness=1.0e8,
external_points=0,
points=0,
indices=0,
template="Rigid3d"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,11 @@ def createScene(root_node):
beam = solver_node.addChild(CosseratBase(parent=solver_node, beam_params=Params))
# Attach beam base using a spring force field
beam.rigidBaseNode.addObject(
"RestShapeSpringsForceField",
"FixedWeakConstraint",
name="spring",
stiffness=1e8,
angularStiffness=1.0e8,
external_points=0,
points=0,
indices=0,
template="Rigid3d"
)

Expand Down
6 changes: 3 additions & 3 deletions tutorial/tuto_scenes/step1.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def _add_rigid_base(p_node):
rigid_base_node.addObject('MechanicalObject', template='Rigid3d', name="cosserat_base_mo",
position="0 0 0 0 0 0. 1",
showObject=1, showObjectScale='0.1')
rigid_base_node.addObject('RestShapeSpringsForceField', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, external_points="0", mstate="@cosserat_base_mo",
points="0", template="Rigid3d")
rigid_base_node.addObject('FixedWeakConstraint', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, mstate="@cosserat_base_mo",
indices="0", template="Rigid3d")
return rigid_base_node


Expand Down
5 changes: 2 additions & 3 deletions tutorial/tuto_scenes/tuto_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ def _add_rigid_base(p_node, positions=None):
showObjectScale="0.1",
)
rigid_base_node.addObject(
"RestShapeSpringsForceField",
"FixedWeakConstraint",
name="spring",
stiffness=stiffness_param,
angularStiffness=stiffness_param,
external_points="0",
mstate="@cosserat_base_mo",
points="0",
indices="0",
template="Rigid3d",
)
return rigid_base_node
Expand Down
6 changes: 3 additions & 3 deletions tutorial/tuto_scenes/tuto_1_6dofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def _add_rigid_base(p_node):
rigid_base_node.addObject('MechanicalObject', template='Rigid3d', name="cosserat_base_mo",
position="0 0 0 0 0 0. 1",
showObject=1, showObjectScale='0.1')
rigid_base_node.addObject('RestShapeSpringsForceField', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, external_points="0", mstate="@cosserat_base_mo",
points="0", template="Rigid3d")
rigid_base_node.addObject('FixedWeakConstraint', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, mstate="@cosserat_base_mo",
indices="0", template="Rigid3d")
return rigid_base_node


Expand Down
1 change: 1 addition & 0 deletions tutorial/tuto_scenes/tuto_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from tuto_1 import _add_rigid_base, _add_cosserat_state, _add_cosserat_frame


stiffness_param: float = 1.e10
beam_radius: float = 1.

Expand Down
6 changes: 3 additions & 3 deletions tutorial/tuto_scenes/tuto_2_6dofs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def _add_rigid_base(p_node):
rigid_base_node.addObject('MechanicalObject', template='Rigid3d', name="cosserat_base_mo",
position="0 0 0 0 0 0. 1",
showObject=1, showObjectScale='0.1')
rigid_base_node.addObject('RestShapeSpringsForceField', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, external_points="0", mstate="@cosserat_base_mo",
points="0", template="Rigid3d", activeDirections=[0,1,1,1,1,1,1])
rigid_base_node.addObject('FixedWeakConstraint', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, mstate="@cosserat_base_mo",
indices="0", template="Rigid3d", activeDirections=[0,1,1,1,1,1,1])
return rigid_base_node


Expand Down
5 changes: 2 additions & 3 deletions tutorial/tuto_scenes/tuto_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ def createScene(root_node):
beam = solver_node.addChild(CosseratBase(parent=solver_node, params=Params))
# Attach beam base using a spring force field
beam.rigidBaseNode.addObject(
"RestShapeSpringsForceField",
"FixedWeakConstraint",
name="spring",
stiffness=1e8,
angularStiffness=1.0e8,
external_points=0,
points=0,
indices=0,
template="Rigid3d"
)

Expand Down
10 changes: 5 additions & 5 deletions tutorial/tuto_scenes/tuto_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,11 @@ def createScene(root_node):
# create cosserat Beam
cosserat_beam = solver_node.addChild(CosseratBase(parent=solver_node, params=Params))
cosserat_beam.rigidBaseNode.addObject(
"RestShapeSpringsForceField",
"FixedWeakConstraint",
name="spring",
stiffness=1e8,
angularStiffness=1.0e8,
external_points=0,
points=0,
indices=0,
template="Rigid3d"
)
cosserat_frames = cosserat_beam.cosseratFrame
Expand All @@ -132,8 +131,9 @@ def createScene(root_node):
showObject=True)
if controller_type == 3:
cosserat_frames.addObject('RestShapeSpringsForceField', name='spring', stiffness=0., angularStiffness=1.e8,
external_points=0, external_rest_shape=controller_state.getLinkPath(),
points=geoParams.nb_frames, template="Rigid3d")
externalIndices=0, external_rest_shape=controller_state.getLinkPath(),
indices=geoParams.nbFrames, template="Rigid3d")


solver_node.addObject(ForceController(forceNode=const_force_node, frame_node=cosserat_frames,
force_type=controller_type, tip_controller=controller_state))
Expand Down
4 changes: 2 additions & 2 deletions tutorial/tuto_scenes/tuto_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def createScene(root_node):
# showObject=True)
#
# cosserat_frames.addObject('RestShapeSpringsForceField', name='spring', stiffness=1e8, angularStiffness=1e8,
# external_points=0, external_rest_shape=controller_state.getLinkPath(),
# points=geoParams.nbFrames, template="Rigid3d")
# externalIndices=0, external_rest_shape=controller_state.getLinkPath(),
# indices=geoParams.nbFrames, template="Rigid3d")
#
# solver_node.addObject(ForceController(forceNode=const_force_node, frame_node=cosserat_frames, force_type=3,
# tip_controller=controller_state))
Expand Down
6 changes: 3 additions & 3 deletions tutorial/tuto_scenes/tuto_compare_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def _add_rigid_base(p_node, _name='rigid_base'):
rigid_base_node.addObject('MechanicalObject', template='Rigid3d', name="cosserat_base_mo",
position="0 0 0 0 0 0. 1",
showObject=0, showObjectScale='0.')
rigid_base_node.addObject('RestShapeSpringsForceField', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, external_points="0", mstate="@cosserat_base_mo",
points="0", template="Rigid3d", activeDirections=[1,1,1,1,1,1,1])
rigid_base_node.addObject('FixedWeakConstraint', name='spring', stiffness=stiffness_param,
angularStiffness=stiffness_param, mstate="@cosserat_base_mo",
indices="0", template="Rigid3d", activeDirections=[1,1,1,1,1,1,1])
return rigid_base_node


Expand Down
Loading