From 3b51664b59e1851ff0cd46118b86cbfd2d62d2fd Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 10 Dec 2024 15:28:07 +0100 Subject: [PATCH 1/4] Apply data name changes --- .../constraint/CableConstraint/CableSmoothActuation.py | 2 +- examples/component/constraint/CableConstraint/Finger.py | 4 ++-- .../component/constraint/CableConstraint/FingerWithSTLIB.py | 2 +- .../component/constraint/JointConstraint/JointConstraint.py | 2 +- .../constraint/SurfacePressureConstraint/Springy.py | 2 +- .../SurfacePressureConstraint/SurfacePressureConstraint.py | 2 +- .../UnilateralPlaneConstraint/ArticulatedTentacle.py | 2 +- .../CommunicationController/modules/accordion3.py | 2 +- .../controller/DataVariationLimiter/DataVariationLimiter.py | 2 +- .../thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py | 2 +- .../T4-DirectActuation/Actuators/Cable/CableDisplacement.py | 4 ++-- .../T4-DirectActuation/Actuators/Cable/CableForce.py | 2 +- .../Actuators/Pneumatic/SurfaceConstraintPressure.py | 2 +- .../Actuators/Pneumatic/SurfaceConstraintVolume.py | 2 +- .../T4-DirectActuation/DriveTheRobot/Simulation.py | 6 +++--- .../PneunetGripper/details/step4-boundaryConditions.py | 2 +- .../details/step5-timeIntegrationAndMatrixSolver.py | 2 +- .../step6-pneumaticActuatorAndPythonScriptController.py | 2 +- .../tutorials/PneunetGripper/details/step7-grabTheCube.py | 2 +- .../tutorials/PneunetGripper/details/step7-withSTLIB.py | 2 +- examples/tutorials/PneunetGripper/pneunetgripper-tuto.md | 6 +++--- examples/tutorials/SoftArmGripper/scene.py | 4 ++-- examples/tutorials/SoftFingerDesign/details/fixing_box.py | 2 +- examples/tutorials/SoftFingerDesign/details/s90_servo.py | 2 +- examples/tutorials/Tripod/details/fixingbox.py | 2 +- examples/tutorials/Tripod/details/maze.py | 2 +- examples/tutorials/Tripod/details/s90servo.py | 2 +- examples/tutorials/Tripod/details/step8-maze.py | 2 +- examples/tutorials/Tripod/myproject/fixingbox.py | 2 +- examples/tutorials/Tripod/myproject/maze.py | 2 +- examples/tutorials/Tripod/myproject/parts/fixingbox.py | 2 +- examples/tutorials/Tripod/myproject/parts/maze.py | 2 +- examples/tutorials/Tripod/myproject/parts/s90servo.py | 2 +- examples/tutorials/Tripod/myproject/s90servo.py | 2 +- examples/tutorials/Tripod/myproject/step8-maze.py | 2 +- .../constraint/scenes/SurfacePressureConstraint.scn | 2 +- 36 files changed, 43 insertions(+), 43 deletions(-) diff --git a/examples/component/constraint/CableConstraint/CableSmoothActuation.py b/examples/component/constraint/CableConstraint/CableSmoothActuation.py index 30ea4db1..e2d17de1 100644 --- a/examples/component/constraint/CableConstraint/CableSmoothActuation.py +++ b/examples/component/constraint/CableConstraint/CableSmoothActuation.py @@ -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('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness='1e12') bunny.addObject('GenericConstraintCorrection') diff --git a/examples/component/constraint/CableConstraint/Finger.py b/examples/component/constraint/CableConstraint/Finger.py index 57def8b5..d252965d 100644 --- a/examples/component/constraint/CableConstraint/Finger.py +++ b/examples/component/constraint/CableConstraint/Finger.py @@ -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('RestShapeSpringsForceField', 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') diff --git a/examples/component/constraint/CableConstraint/FingerWithSTLIB.py b/examples/component/constraint/CableConstraint/FingerWithSTLIB.py index 98e256b4..0953930d 100644 --- a/examples/component/constraint/CableConstraint/FingerWithSTLIB.py +++ b/examples/component/constraint/CableConstraint/FingerWithSTLIB.py @@ -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('RestShapeSpringsForceField', indices='@ROI1.indices', stiffness=1e12) ########################################## # Cable # diff --git a/examples/component/constraint/JointConstraint/JointConstraint.py b/examples/component/constraint/JointConstraint/JointConstraint.py index d96431ba..0ed11ec6 100644 --- a/examples/component/constraint/JointConstraint/JointConstraint.py +++ b/examples/component/constraint/JointConstraint/JointConstraint.py @@ -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("RestShapeSpringsForceField", d_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) diff --git a/examples/component/constraint/SurfacePressureConstraint/Springy.py b/examples/component/constraint/SurfacePressureConstraint/Springy.py index 47cdec2a..ad900a3f 100644 --- a/examples/component/constraint/SurfacePressureConstraint/Springy.py +++ b/examples/component/constraint/SurfacePressureConstraint/Springy.py @@ -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('RestShapeSpringsForceField', indices='@ROI1.indices', stiffness=1e12) # accordion.addObject('FixedProjectiveConstraint', indices='@ROI1.indices') accordion.addObject('LinearSolverConstraintCorrection') diff --git a/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py b/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py index 51ca68f5..3a90f82e 100644 --- a/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py +++ b/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py @@ -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('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness=1e12) bunny.addObject('LinearSolverConstraintCorrection') # bunny/cavity diff --git a/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py b/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py index b4e3223b..8f06be9a 100644 --- a/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py +++ b/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py @@ -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('RestShapeSpringsForceField', indices='@ROI1.indices', stiffness=1e12) tentacle.addObject('LinearSolverConstraintCorrection') diff --git a/examples/component/controller/CommunicationController/modules/accordion3.py b/examples/component/controller/CommunicationController/modules/accordion3.py index d40c1f5c..6eaec093 100644 --- a/examples/component/controller/CommunicationController/modules/accordion3.py +++ b/examples/component/controller/CommunicationController/modules/accordion3.py @@ -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('RestShapeSpringsForceField', indices='@ROI1.indices', stiffness=1e12) accordion.addObject('LinearSolverConstraintCorrection') # Pressure diff --git a/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py b/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py index da4c5c37..2f5651d6 100644 --- a/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py +++ b/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py @@ -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('RestShapeSpringsForceField', indices='@ROI1.indices', stiffness=1e12) accordion.addObject('LinearSolverConstraintCorrection') diff --git a/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py b/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py index 823e9567..f8b3a932 100644 --- a/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py +++ b/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py @@ -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('RestShapeSpringsForceField', indices=0, stiffness=100e10, angularStiffness=100e10) # Visualization visuNode = beam.addChild('visualization') diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py index a67ebb8e..813f8c2d 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py @@ -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('RestShapeSpringsForceField', 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') diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py index 9269c1df..2131addc 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py @@ -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('RestShapeSpringsForceField', indices='@ROI.indices', stiffness=1e12) finger.addObject('LinearSolverConstraintCorrection') diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py index 726ea218..392ab864 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py @@ -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('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness=1e12) bunny.addObject('LinearSolverConstraintCorrection') # bunny/cavity diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py index fa3fa709..50d288a5 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py @@ -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('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness=1e12) bunny.addObject('LinearSolverConstraintCorrection') # bunny/cavity diff --git a/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py b/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py index d5958820..8593f190 100644 --- a/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py +++ b/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py @@ -63,11 +63,11 @@ def createScene(rootNode): showIndices=False, showIndicesScale=4e-5, position='@../robot/boxROI3.pointsInROI') - robot.addObject('RestShapeSpringsForceField', name='fixed1', points="@boxROI1.indices", + robot.addObject('RestShapeSpringsForceField', name='fixed1', indices="@boxROI1.indices", external_rest_shape="@RestPositionLeg0/meca0", stiffness=1e3) - robot.addObject('RestShapeSpringsForceField', name='fixed2', points="@boxROI2.indices", + robot.addObject('RestShapeSpringsForceField', name='fixed2', indices="@boxROI2.indices", external_rest_shape="@RestPositionLeg1/meca1", stiffness=1e3) - robot.addObject('RestShapeSpringsForceField', name='fixed3', points="@boxROI3.indices", + robot.addObject('RestShapeSpringsForceField', name='fixed3', indices="@boxROI3.indices", external_rest_shape="@RestPositionLeg2/meca2", stiffness=1e3) ############################### diff --git a/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py b/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py index bbe188b2..8e2d3f7a 100644 --- a/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py +++ b/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py @@ -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('RestShapeSpringsForceField', indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12) modelSubTopo = finger.addChild('SubTopology') modelSubTopo.addObject('MeshTopology', position='@loader.position', name='container', diff --git a/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py b/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py index 089b2a22..d7444693 100644 --- a/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py +++ b/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py @@ -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('RestShapeSpringsForceField', indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12) modelSubTopo = finger.addChild('SubTopology') modelSubTopo.addObject('MeshTopology', position='@loader.position', tetrahedra=boxROISubTopo.tetrahedraInROI.linkpath, diff --git a/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py b/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py index f8ae1416..da74c693 100644 --- a/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py +++ b/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py @@ -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('RestShapeSpringsForceField', indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12) finger.addObject('GenericConstraintCorrection') modelSubTopo = finger.addChild('SubTopology') diff --git a/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py b/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py index 831d5fd0..8ce4c7e7 100644 --- a/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py +++ b/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py @@ -115,7 +115,7 @@ def createScene(rootNode): 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, + indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12) finger.addObject('GenericConstraintCorrection') diff --git a/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py b/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py index 5d3d5971..3435dfc9 100644 --- a/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py +++ b/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py @@ -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('RestShapeSpringsForceField', indices='@../Finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) PneumaticCavity(surfaceMeshFileName=fingersCavitySurfaceMesh, diff --git a/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md b/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md index 060053bf..fcd8295a 100644 --- a/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md +++ b/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md @@ -62,7 +62,7 @@ To easily define the indices of the points which will be fixed, we use the boxRO ```python finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20]) -finger.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) +finger.addObject('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) ``` [Step4](details/step4-boundaryConditions.py) @@ -286,9 +286,9 @@ def createScene(rootNode): finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20]) finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False) if i == 0: - finger.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) + finger.addObject('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) else: - finger.addObject('RestShapeSpringsForceField', points='@../finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) + finger.addObject('RestShapeSpringsForceField', indices='@../finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) finger.addObject('LinearSolverConstraintCorrection', solverName='preconditioner') diff --git a/examples/tutorials/SoftArmGripper/scene.py b/examples/tutorials/SoftArmGripper/scene.py index c0d11a4f..920d13b5 100644 --- a/examples/tutorials/SoftArmGripper/scene.py +++ b/examples/tutorials/SoftArmGripper/scene.py @@ -39,7 +39,7 @@ def addArm(node): arm.addObject('MechanicalObject', template='Rigid3', name='dofs', showObject=True, showObjectScale=10) arm.addObject('UniformMass', indices=[4 * i + 1 for i in range(size)], totalMass=0.003 * size, showAxisSizeFactor=0.03) # set mass of each piece that connect the ribs - arm.addObject('RestShapeSpringsForceField', stiffness=1e12, angularStiffness=1e12, points=0) # fix base of the arm + arm.addObject('RestShapeSpringsForceField', stiffness=1e12, angularStiffness=1e12, indices=0) # fix base of the arm # sub topology to allow different ribs thickness for each section for i in range(params.Arm.nbSection): @@ -84,7 +84,7 @@ def addFinger(node, fingerId, translation, rotation): finger.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3, youngModulus=1.8e6) finger.addObject('BoxROI', name='boxROI', box=[-100, -20, -50, 100, 20, 50], drawBoxes=True) - finger.addObject('RestShapeSpringsForceField', points=finger.boxROI.indices.getLinkPath(), stiffness=1e12) + finger.addObject('RestShapeSpringsForceField', indices=finger.boxROI.indices.getLinkPath(), stiffness=1e12) visu[fingerId] = finger.addChild('Visualization') visu[fingerId].addObject('MeshSTLLoader', name="loader", filename=params.Simulation.path + "/mesh/finger.stl", diff --git a/examples/tutorials/SoftFingerDesign/details/fixing_box.py b/examples/tutorials/SoftFingerDesign/details/fixing_box.py index 4db1b924..09ae3e4b 100644 --- a/examples/tutorials/SoftFingerDesign/details/fixing_box.py +++ b/examples/tutorials/SoftFingerDesign/details/fixing_box.py @@ -21,5 +21,5 @@ def __init__(self, parent, target, name='FixingBox', target.addChild(c) c.addObject('RestShapeSpringsForceField', - points=self.node.BoxROI.getData('indices').getLinkPath(), + indices=self.node.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) diff --git a/examples/tutorials/SoftFingerDesign/details/s90_servo.py b/examples/tutorials/SoftFingerDesign/details/s90_servo.py index 0c7a81c0..4d089c2a 100644 --- a/examples/tutorials/SoftFingerDesign/details/s90_servo.py +++ b/examples/tutorials/SoftFingerDesign/details/s90_servo.py @@ -74,7 +74,7 @@ def init(self): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[self.getData('angleIn')]], rest_position=self.getData('angleIn').getLinkPath()) - angle.addObject('RestShapeSpringsForceField', points=0, stiffness=1e9) + angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/details/fixingbox.py b/examples/tutorials/Tripod/details/fixingbox.py index 5eb73d56..606c735b 100644 --- a/examples/tutorials/Tripod/details/fixingbox.py +++ b/examples/tutorials/Tripod/details/fixingbox.py @@ -18,6 +18,6 @@ def FixingBox(parent, target, name='FixingBox', target.addChild(c) c.addObject('RestShapeSpringsForceField', - points=self.BoxROI.getData('indices').getLinkPath(), + indices=self.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) return self diff --git a/examples/tutorials/Tripod/details/maze.py b/examples/tutorials/Tripod/details/maze.py index b751b25e..7f211dca 100644 --- a/examples/tutorials/Tripod/details/maze.py +++ b/examples/tutorials/Tripod/details/maze.py @@ -78,7 +78,7 @@ def createScene(rootNode): effector.addObject('CGLinearSolver', iterations=100, threshold=1e-5, tolerance=1e-5) effector.addObject('MechanicalObject', template='Rigid3', name='goalMO', position=[0, 40, 0, 0, 0, 0, 1], showObject=True, showObjectScale=10) - effector.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1e5, stiffness=1e5) + effector.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) effector.addObject('UncoupledConstraintCorrection', compliance='1e-10 1e-10 0 0 1e-10 0 1e-10 ') # Open maze planning from JSON file diff --git a/examples/tutorials/Tripod/details/s90servo.py b/examples/tutorials/Tripod/details/s90servo.py index 42ef2332..7a198fa5 100644 --- a/examples/tutorials/Tripod/details/s90servo.py +++ b/examples/tutorials/Tripod/details/s90servo.py @@ -75,7 +75,7 @@ def __init__(self, *args, **kwargs): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[0]], rest_position=self.angleIn.getLinkPath()) - angle.addObject('RestShapeSpringsForceField', points=0, stiffness=1e9) + angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/details/step8-maze.py b/examples/tutorials/Tripod/details/step8-maze.py index 29feccd9..dd0c140a 100644 --- a/examples/tutorials/Tripod/details/step8-maze.py +++ b/examples/tutorials/Tripod/details/step8-maze.py @@ -16,7 +16,7 @@ def EffectorGoal(node, position): goal.addObject('EulerImplicitSolver', firstOrder=True) goal.addObject('CGLinearSolver', iterations=100, threshold=1e-12, tolerance=1e-10) goal.addObject('MechanicalObject', name='goalMO', template='Rigid3', position=position+[0., 0., 0., 1.], showObject=True, showObjectScale=10) - goal.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1e5, stiffness=1e5) + goal.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) goal.addObject('UncoupledConstraintCorrection', compliance=[1e-10] * 7) return goal diff --git a/examples/tutorials/Tripod/myproject/fixingbox.py b/examples/tutorials/Tripod/myproject/fixingbox.py index 5eb73d56..606c735b 100644 --- a/examples/tutorials/Tripod/myproject/fixingbox.py +++ b/examples/tutorials/Tripod/myproject/fixingbox.py @@ -18,6 +18,6 @@ def FixingBox(parent, target, name='FixingBox', target.addChild(c) c.addObject('RestShapeSpringsForceField', - points=self.BoxROI.getData('indices').getLinkPath(), + indices=self.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) return self diff --git a/examples/tutorials/Tripod/myproject/maze.py b/examples/tutorials/Tripod/myproject/maze.py index b751b25e..7f211dca 100644 --- a/examples/tutorials/Tripod/myproject/maze.py +++ b/examples/tutorials/Tripod/myproject/maze.py @@ -78,7 +78,7 @@ def createScene(rootNode): effector.addObject('CGLinearSolver', iterations=100, threshold=1e-5, tolerance=1e-5) effector.addObject('MechanicalObject', template='Rigid3', name='goalMO', position=[0, 40, 0, 0, 0, 0, 1], showObject=True, showObjectScale=10) - effector.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1e5, stiffness=1e5) + effector.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) effector.addObject('UncoupledConstraintCorrection', compliance='1e-10 1e-10 0 0 1e-10 0 1e-10 ') # Open maze planning from JSON file diff --git a/examples/tutorials/Tripod/myproject/parts/fixingbox.py b/examples/tutorials/Tripod/myproject/parts/fixingbox.py index 6d42783a..cd9d3921 100644 --- a/examples/tutorials/Tripod/myproject/parts/fixingbox.py +++ b/examples/tutorials/Tripod/myproject/parts/fixingbox.py @@ -20,6 +20,6 @@ def FixingBox(parent, target, name='FixingBox', target.addChild(c) c.addObject('RestShapeSpringsForceField', - points=self.BoxROI.getData('indices').getLinkPath(), + indices=self.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) return self diff --git a/examples/tutorials/Tripod/myproject/parts/maze.py b/examples/tutorials/Tripod/myproject/parts/maze.py index 9dba6ffc..949ca39d 100644 --- a/examples/tutorials/Tripod/myproject/parts/maze.py +++ b/examples/tutorials/Tripod/myproject/parts/maze.py @@ -56,7 +56,7 @@ def createScene(rootNode): effector.addObject('CGLinearSolver', iterations=100, threshold=1e-5, tolerance=1e-5) effector.addObject('MechanicalObject', template='Rigid3', name='goalMO', position=[0, 40, 0, 0, 0, 0, 1], showObject=True, showObjectScale=10) - effector.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1e5, stiffness=1e5) + effector.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) effector.addObject('UncoupledConstraintCorrection', compliance='1e-10 1e-10 0 0 1e-10 0 1e-10 ') # Open maze planning from JSON file diff --git a/examples/tutorials/Tripod/myproject/parts/s90servo.py b/examples/tutorials/Tripod/myproject/parts/s90servo.py index 6f7b900d..51e6a5b0 100644 --- a/examples/tutorials/Tripod/myproject/parts/s90servo.py +++ b/examples/tutorials/Tripod/myproject/parts/s90servo.py @@ -75,7 +75,7 @@ def init(self): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[0]], rest_position=self.getData('angleIn').getLinkPath()) - angle.addObject('RestShapeSpringsForceField', points=0, stiffness=1e9) + angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/myproject/s90servo.py b/examples/tutorials/Tripod/myproject/s90servo.py index 42ef2332..7a198fa5 100644 --- a/examples/tutorials/Tripod/myproject/s90servo.py +++ b/examples/tutorials/Tripod/myproject/s90servo.py @@ -75,7 +75,7 @@ def __init__(self, *args, **kwargs): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[0]], rest_position=self.angleIn.getLinkPath()) - angle.addObject('RestShapeSpringsForceField', points=0, stiffness=1e9) + angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/myproject/step8-maze.py b/examples/tutorials/Tripod/myproject/step8-maze.py index 40891e15..64d28912 100644 --- a/examples/tutorials/Tripod/myproject/step8-maze.py +++ b/examples/tutorials/Tripod/myproject/step8-maze.py @@ -16,7 +16,7 @@ def EffectorGoal(node, position): goal.addObject('EulerImplicitSolver', firstOrder=True) goal.addObject('CGLinearSolver', iterations=100, threshold=1e-12, tolerance=1e-10) goal.addObject('MechanicalObject', name='goalMO', template='Rigid3', position=position+[0., 0., 0., 1.], showObject=True, showObjectScale=10) - goal.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1e5, stiffness=1e5) + goal.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) goal.addObject('UncoupledConstraintCorrection', compliance=[1e-10] * 7) return goal diff --git a/tests/component/constraint/scenes/SurfacePressureConstraint.scn b/tests/component/constraint/scenes/SurfacePressureConstraint.scn index 937afbb6..4dcb6300 100644 --- a/tests/component/constraint/scenes/SurfacePressureConstraint.scn +++ b/tests/component/constraint/scenes/SurfacePressureConstraint.scn @@ -25,7 +25,7 @@ - + From 86e2b8d7bbcbbfc4f6d0e339ad14ee9e798b941e Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 10 Dec 2024 15:54:32 +0100 Subject: [PATCH 2/4] Fix name --- .../component/constraint/JointConstraint/JointConstraint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/component/constraint/JointConstraint/JointConstraint.py b/examples/component/constraint/JointConstraint/JointConstraint.py index 0ed11ec6..10ad8d7d 100644 --- a/examples/component/constraint/JointConstraint/JointConstraint.py +++ b/examples/component/constraint/JointConstraint/JointConstraint.py @@ -38,7 +38,7 @@ def createScene(rootNode): object = simulation.addChild('Object') object.addObject('MechanicalObject', template='Vec1', position=0.) - object.addObject("RestShapeSpringsForceField", d_indices[0], stiffness=1e1) + object.addObject("RestShapeSpringsForceField", 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) From 6778a68a86b1fa7c1ebeab7b44de3de174cfa71c Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Tue, 4 Mar 2025 17:25:54 +0100 Subject: [PATCH 3/4] Use FixedweakConstraint instead when possible --- .../constraint/CableConstraint/CableSmoothActuation.py | 2 +- examples/component/constraint/CableConstraint/Finger.py | 2 +- .../constraint/CableConstraint/FingerWithSTLIB.py | 2 +- .../constraint/JointConstraint/JointConstraint.py | 2 +- .../constraint/SurfacePressureConstraint/Springy.py | 2 +- .../SurfacePressureConstraint.py | 2 +- .../UnilateralPlaneConstraint/ArticulatedTentacle.py | 2 +- .../CommunicationController/modules/accordion3.py | 2 +- .../DataVariationLimiter/DataVariationLimiter.py | 2 +- .../thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py | 2 +- .../Actuators/Cable/CableDisplacement.py | 2 +- .../T4-DirectActuation/Actuators/Cable/CableForce.py | 2 +- .../Actuators/Pneumatic/SurfaceConstraintPressure.py | 2 +- .../Actuators/Pneumatic/SurfaceConstraintVolume.py | 2 +- .../PneunetGripper/details/step4-boundaryConditions.py | 2 +- .../details/step5-timeIntegrationAndMatrixSolver.py | 2 +- .../step6-pneumaticActuatorAndPythonScriptController.py | 2 +- .../tutorials/PneunetGripper/details/step7-grabTheCube.py | 2 +- .../tutorials/PneunetGripper/details/step7-withSTLIB.py | 2 +- .../tutorials/PneunetGripper/pneunetgripper-tuto.html | 8 ++++---- examples/tutorials/PneunetGripper/pneunetgripper-tuto.md | 8 ++++---- examples/tutorials/SoftArmGripper/scene.py | 4 ++-- examples/tutorials/SoftFingerDesign/details/fixing_box.py | 2 +- examples/tutorials/SoftFingerDesign/details/s90_servo.py | 2 +- examples/tutorials/Tripod/details/closedLoopController.py | 2 +- examples/tutorials/Tripod/details/fixingbox.py | 2 +- examples/tutorials/Tripod/details/maze.py | 2 +- examples/tutorials/Tripod/details/s90servo.py | 2 +- examples/tutorials/Tripod/details/step8-maze.py | 2 +- examples/tutorials/Tripod/details/tripodcontroller.py | 2 +- .../tutorials/Tripod/myproject/closedLoopController.py | 2 +- examples/tutorials/Tripod/myproject/fixingbox.py | 2 +- examples/tutorials/Tripod/myproject/maze.py | 2 +- examples/tutorials/Tripod/myproject/parts/fixingbox.py | 2 +- examples/tutorials/Tripod/myproject/parts/maze.py | 2 +- examples/tutorials/Tripod/myproject/parts/s90servo.py | 2 +- .../tutorials/Tripod/myproject/parts/tripodcontroller.py | 2 +- examples/tutorials/Tripod/myproject/s90servo.py | 2 +- examples/tutorials/Tripod/myproject/step8-maze.py | 2 +- examples/tutorials/Tripod/myproject/tripodcontroller.py | 2 +- examples/tutorials/Tripod/tripod-tuto.html | 6 +++--- examples/tutorials/Tripod/tripod-tuto.md | 2 +- .../constraint/scenes/SurfacePressureConstraint.scn | 2 +- 43 files changed, 52 insertions(+), 52 deletions(-) diff --git a/examples/component/constraint/CableConstraint/CableSmoothActuation.py b/examples/component/constraint/CableConstraint/CableSmoothActuation.py index e2d17de1..534cf787 100644 --- a/examples/component/constraint/CableConstraint/CableSmoothActuation.py +++ b/examples/component/constraint/CableConstraint/CableSmoothActuation.py @@ -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', indices='@boxROI.indices', stiffness='1e12') + bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness='1e12') bunny.addObject('GenericConstraintCorrection') diff --git a/examples/component/constraint/CableConstraint/Finger.py b/examples/component/constraint/CableConstraint/Finger.py index d252965d..c161ae88 100644 --- a/examples/component/constraint/CableConstraint/Finger.py +++ b/examples/component/constraint/CableConstraint/Finger.py @@ -73,7 +73,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', indices=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', indices=[0, 1, 2, 11, 55], stiffness=1e12) diff --git a/examples/component/constraint/CableConstraint/FingerWithSTLIB.py b/examples/component/constraint/CableConstraint/FingerWithSTLIB.py index 0953930d..0eb950dd 100644 --- a/examples/component/constraint/CableConstraint/FingerWithSTLIB.py +++ b/examples/component/constraint/CableConstraint/FingerWithSTLIB.py @@ -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', indices='@ROI1.indices', stiffness=1e12) + finger.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12) ########################################## # Cable # diff --git a/examples/component/constraint/JointConstraint/JointConstraint.py b/examples/component/constraint/JointConstraint/JointConstraint.py index 10ad8d7d..7f023a7d 100644 --- a/examples/component/constraint/JointConstraint/JointConstraint.py +++ b/examples/component/constraint/JointConstraint/JointConstraint.py @@ -38,7 +38,7 @@ def createScene(rootNode): object = simulation.addChild('Object') object.addObject('MechanicalObject', template='Vec1', position=0.) - object.addObject("RestShapeSpringsForceField", indices=[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) diff --git a/examples/component/constraint/SurfacePressureConstraint/Springy.py b/examples/component/constraint/SurfacePressureConstraint/Springy.py index ad900a3f..19fd864e 100644 --- a/examples/component/constraint/SurfacePressureConstraint/Springy.py +++ b/examples/component/constraint/SurfacePressureConstraint/Springy.py @@ -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', indices='@ROI1.indices', stiffness=1e12) + accordion.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12) # accordion.addObject('FixedProjectiveConstraint', indices='@ROI1.indices') accordion.addObject('LinearSolverConstraintCorrection') diff --git a/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py b/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py index 3a90f82e..b03e88ef 100644 --- a/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py +++ b/examples/component/constraint/SurfacePressureConstraint/SurfacePressureConstraint.py @@ -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', indices='@boxROI.indices', stiffness=1e12) + bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12) bunny.addObject('LinearSolverConstraintCorrection') # bunny/cavity diff --git a/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py b/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py index 8f06be9a..29832ae0 100644 --- a/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py +++ b/examples/component/constraint/UnilateralPlaneConstraint/ArticulatedTentacle.py @@ -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', indices='@ROI1.indices', stiffness=1e12) + tentacle.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12) tentacle.addObject('LinearSolverConstraintCorrection') diff --git a/examples/component/controller/CommunicationController/modules/accordion3.py b/examples/component/controller/CommunicationController/modules/accordion3.py index 6eaec093..940bc753 100644 --- a/examples/component/controller/CommunicationController/modules/accordion3.py +++ b/examples/component/controller/CommunicationController/modules/accordion3.py @@ -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', indices='@ROI1.indices', stiffness=1e12) + accordion.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12) accordion.addObject('LinearSolverConstraintCorrection') # Pressure diff --git a/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py b/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py index 2f5651d6..e88eb1ac 100644 --- a/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py +++ b/examples/component/controller/DataVariationLimiter/DataVariationLimiter.py @@ -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', indices='@ROI1.indices', stiffness=1e12) + accordion.addObject('FixedWeakConstraint', indices='@ROI1.indices', stiffness=1e12) accordion.addObject('LinearSolverConstraintCorrection') diff --git a/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py b/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py index f8b3a932..684d799e 100644 --- a/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py +++ b/examples/thematicalDocs/T1-Elements_TetraHexaBeam/Beam/Beam.py @@ -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', indices=0, stiffness=100e10, angularStiffness=100e10) + beam.addObject('FixedWeakConstraint', indices=0, stiffness=100e10, angularStiffness=100e10) # Visualization visuNode = beam.addChild('visualization') diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py index 813f8c2d..90ef2344 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableDisplacement.py @@ -53,7 +53,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', indices='@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', indices=[0, 1, 2, 11, 55], stiffness=1e12) diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py index 2131addc..7fc37d20 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Cable/CableForce.py @@ -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', indices='@ROI.indices', stiffness=1e12) + finger.addObject('FixedWeakConstraint', indices='@ROI.indices', stiffness=1e12) finger.addObject('LinearSolverConstraintCorrection') diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py index 392ab864..14e6c191 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintPressure.py @@ -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', indices='@boxROI.indices', stiffness=1e12) + bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12) bunny.addObject('LinearSolverConstraintCorrection') # bunny/cavity diff --git a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py index 50d288a5..52bc52c4 100644 --- a/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py +++ b/examples/thematicalDocs/T4-DirectActuation/Actuators/Pneumatic/SurfaceConstraintVolume.py @@ -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', indices='@boxROI.indices', stiffness=1e12) + bunny.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12) bunny.addObject('LinearSolverConstraintCorrection') # bunny/cavity diff --git a/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py b/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py index 8e2d3f7a..3c0ef196 100644 --- a/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py +++ b/examples/tutorials/PneunetGripper/details/step4-boundaryConditions.py @@ -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', indices=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', diff --git a/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py b/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py index d7444693..782ed65d 100644 --- a/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py +++ b/examples/tutorials/PneunetGripper/details/step5-timeIntegrationAndMatrixSolver.py @@ -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', indices=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, diff --git a/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py b/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py index da74c693..c297fd02 100644 --- a/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py +++ b/examples/tutorials/PneunetGripper/details/step6-pneumaticActuatorAndPythonScriptController.py @@ -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', indices=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') diff --git a/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py b/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py index 8ce4c7e7..426e2ce2 100644 --- a/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py +++ b/examples/tutorials/PneunetGripper/details/step7-grabTheCube.py @@ -114,7 +114,7 @@ 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', + finger.addObject('FixedWeakConstraint', indices=boxROI.indices.linkpath, stiffness=1e12, angularStiffness=1e12) finger.addObject('GenericConstraintCorrection') diff --git a/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py b/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py index 3435dfc9..5b6aabb6 100644 --- a/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py +++ b/examples/tutorials/PneunetGripper/details/step7-withSTLIB.py @@ -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', indices='@../Finger1/boxROI.indices', stiffness=1e12, + finger.addObject('FixedWeakConstraint', indices='@../Finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) PneumaticCavity(surfaceMeshFileName=fingersCavitySurfaceMesh, diff --git a/examples/tutorials/PneunetGripper/pneunetgripper-tuto.html b/examples/tutorials/PneunetGripper/pneunetgripper-tuto.html index 099151bc..bc2a557f 100644 --- a/examples/tutorials/PneunetGripper/pneunetgripper-tuto.html +++ b/examples/tutorials/PneunetGripper/pneunetgripper-tuto.html @@ -105,9 +105,9 @@

Stiff layer

modelSubTopo.addObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio=0.3, youngModulus=1500)

Step3

Boundary Conditions

-

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:

+

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:

+finger.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12)

Step4

Implicit Time Integration and Matrix Solver

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:

@@ -271,9 +271,9 @@

Appendix

finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20]) finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False) if i == 0: - finger.addObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) + finger.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) else: - finger.addObject('RestShapeSpringsForceField', points='@../finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) + finger.addObject('FixedWeakConstraint', indices='@../finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) finger.addObject('LinearSolverConstraintCorrection', solverName='preconditioner') diff --git a/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md b/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md index fcd8295a..02304e73 100644 --- a/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md +++ b/examples/tutorials/PneunetGripper/pneunetgripper-tuto.md @@ -57,12 +57,12 @@ modelSubTopo.addObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', ## Boundary Conditions -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 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: ```python finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20]) -finger.addObject('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) +finger.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) ``` [Step4](details/step4-boundaryConditions.py) @@ -286,9 +286,9 @@ def createScene(rootNode): finger.addObject('BoxROI', name='boxROI', box=[-10, 0, -20, 0, 30, 20]) finger.addObject('BoxROI', name='boxROISubTopo', box=[-100, 22.5, -8, -19, 28, 8], strict=False) if i == 0: - finger.addObject('RestShapeSpringsForceField', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) + finger.addObject('FixedWeakConstraint', indices='@boxROI.indices', stiffness=1e12, angularStiffness=1e12) else: - finger.addObject('RestShapeSpringsForceField', indices='@../finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) + finger.addObject('FixedWeakConstraint', indices='@../finger1/boxROI.indices', stiffness=1e12, angularStiffness=1e12) finger.addObject('LinearSolverConstraintCorrection', solverName='preconditioner') diff --git a/examples/tutorials/SoftArmGripper/scene.py b/examples/tutorials/SoftArmGripper/scene.py index 920d13b5..d014bc0b 100644 --- a/examples/tutorials/SoftArmGripper/scene.py +++ b/examples/tutorials/SoftArmGripper/scene.py @@ -39,7 +39,7 @@ def addArm(node): arm.addObject('MechanicalObject', template='Rigid3', name='dofs', showObject=True, showObjectScale=10) arm.addObject('UniformMass', indices=[4 * i + 1 for i in range(size)], totalMass=0.003 * size, showAxisSizeFactor=0.03) # set mass of each piece that connect the ribs - arm.addObject('RestShapeSpringsForceField', stiffness=1e12, angularStiffness=1e12, indices=0) # fix base of the arm + arm.addObject('FixedWeakConstraint', stiffness=1e12, angularStiffness=1e12, indices=0) # fix base of the arm # sub topology to allow different ribs thickness for each section for i in range(params.Arm.nbSection): @@ -84,7 +84,7 @@ def addFinger(node, fingerId, translation, rotation): finger.addObject('TetrahedronFEMForceField', template='Vec3', name='FEM', method='large', poissonRatio=0.3, youngModulus=1.8e6) finger.addObject('BoxROI', name='boxROI', box=[-100, -20, -50, 100, 20, 50], drawBoxes=True) - finger.addObject('RestShapeSpringsForceField', indices=finger.boxROI.indices.getLinkPath(), stiffness=1e12) + finger.addObject('FixedWeakConstraint', indices=finger.boxROI.indices.getLinkPath(), stiffness=1e12) visu[fingerId] = finger.addChild('Visualization') visu[fingerId].addObject('MeshSTLLoader', name="loader", filename=params.Simulation.path + "/mesh/finger.stl", diff --git a/examples/tutorials/SoftFingerDesign/details/fixing_box.py b/examples/tutorials/SoftFingerDesign/details/fixing_box.py index 09ae3e4b..53786b1c 100644 --- a/examples/tutorials/SoftFingerDesign/details/fixing_box.py +++ b/examples/tutorials/SoftFingerDesign/details/fixing_box.py @@ -20,6 +20,6 @@ def __init__(self, parent, target, name='FixingBox', c = self.node.addChild('Constraint') target.addChild(c) - c.addObject('RestShapeSpringsForceField', + c.addObject('FixedWeakConstraint', indices=self.node.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) diff --git a/examples/tutorials/SoftFingerDesign/details/s90_servo.py b/examples/tutorials/SoftFingerDesign/details/s90_servo.py index 4d089c2a..fd4e443e 100644 --- a/examples/tutorials/SoftFingerDesign/details/s90_servo.py +++ b/examples/tutorials/SoftFingerDesign/details/s90_servo.py @@ -74,7 +74,7 @@ def init(self): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[self.getData('angleIn')]], rest_position=self.getData('angleIn').getLinkPath()) - angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) + angle.addObject('FixedWeakConstraint', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/details/closedLoopController.py b/examples/tutorials/Tripod/details/closedLoopController.py index 7b0c2c42..a220d028 100644 --- a/examples/tutorials/Tripod/details/closedLoopController.py +++ b/examples/tutorials/Tripod/details/closedLoopController.py @@ -172,7 +172,7 @@ def onKeypressedEvent(self, event): key = event['key'] if key == Key.I: for i in range(3): - self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.RestShapeSpringsForceField.stiffness.value = [ + self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.FixedWeakConstraint.stiffness.value = [ 0.] self.activate = True for node in self.nodesInverseComponents: diff --git a/examples/tutorials/Tripod/details/fixingbox.py b/examples/tutorials/Tripod/details/fixingbox.py index 606c735b..a8bba702 100644 --- a/examples/tutorials/Tripod/details/fixingbox.py +++ b/examples/tutorials/Tripod/details/fixingbox.py @@ -17,7 +17,7 @@ def FixingBox(parent, target, name='FixingBox', c = self.addChild('Constraint') target.addChild(c) - c.addObject('RestShapeSpringsForceField', + c.addObject('FixedWeakConstraint', indices=self.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) return self diff --git a/examples/tutorials/Tripod/details/maze.py b/examples/tutorials/Tripod/details/maze.py index 7f211dca..9062df5b 100644 --- a/examples/tutorials/Tripod/details/maze.py +++ b/examples/tutorials/Tripod/details/maze.py @@ -78,7 +78,7 @@ def createScene(rootNode): effector.addObject('CGLinearSolver', iterations=100, threshold=1e-5, tolerance=1e-5) effector.addObject('MechanicalObject', template='Rigid3', name='goalMO', position=[0, 40, 0, 0, 0, 0, 1], showObject=True, showObjectScale=10) - effector.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) + effector.addObject('FixedWeakConstraint', indices=0, angularStiffness=1e5, stiffness=1e5) effector.addObject('UncoupledConstraintCorrection', compliance='1e-10 1e-10 0 0 1e-10 0 1e-10 ') # Open maze planning from JSON file diff --git a/examples/tutorials/Tripod/details/s90servo.py b/examples/tutorials/Tripod/details/s90servo.py index 7a198fa5..ca7c6fdc 100644 --- a/examples/tutorials/Tripod/details/s90servo.py +++ b/examples/tutorials/Tripod/details/s90servo.py @@ -75,7 +75,7 @@ def __init__(self, *args, **kwargs): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[0]], rest_position=self.angleIn.getLinkPath()) - angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) + angle.addObject('FixedWeakConstraint', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/details/step8-maze.py b/examples/tutorials/Tripod/details/step8-maze.py index dd0c140a..ce821e17 100644 --- a/examples/tutorials/Tripod/details/step8-maze.py +++ b/examples/tutorials/Tripod/details/step8-maze.py @@ -16,7 +16,7 @@ def EffectorGoal(node, position): goal.addObject('EulerImplicitSolver', firstOrder=True) goal.addObject('CGLinearSolver', iterations=100, threshold=1e-12, tolerance=1e-10) goal.addObject('MechanicalObject', name='goalMO', template='Rigid3', position=position+[0., 0., 0., 1.], showObject=True, showObjectScale=10) - goal.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) + goal.addObject('FixedWeakConstraint', indices=0, angularStiffness=1e5, stiffness=1e5) goal.addObject('UncoupledConstraintCorrection', compliance=[1e-10] * 7) return goal diff --git a/examples/tutorials/Tripod/details/tripodcontroller.py b/examples/tutorials/Tripod/details/tripodcontroller.py index 8a18563a..bb9fce98 100644 --- a/examples/tutorials/Tripod/details/tripodcontroller.py +++ b/examples/tutorials/Tripod/details/tripodcontroller.py @@ -183,7 +183,7 @@ def onKeypressedEvent(self, event): key = event['key'] if key == Key.I: for i in range(3): - self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.RestShapeSpringsForceField.stiffness.value = [ + self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.FixedWeakConstraint.stiffness.value = [ 0.] self.activate = True for node in self.nodesInverseComponents: diff --git a/examples/tutorials/Tripod/myproject/closedLoopController.py b/examples/tutorials/Tripod/myproject/closedLoopController.py index 9d9f05b0..92e7d0b5 100644 --- a/examples/tutorials/Tripod/myproject/closedLoopController.py +++ b/examples/tutorials/Tripod/myproject/closedLoopController.py @@ -161,7 +161,7 @@ def onKeypressedEvent(self, event): key = event['key'] if key == Key.I: for i in range(3): - self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.RestShapeSpringsForceField.stiffness.value = [ + self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.FixedWeakConstraint.stiffness.value = [ 0.] self.activate = True for node in self.nodesInverseComponents: diff --git a/examples/tutorials/Tripod/myproject/fixingbox.py b/examples/tutorials/Tripod/myproject/fixingbox.py index 606c735b..a8bba702 100644 --- a/examples/tutorials/Tripod/myproject/fixingbox.py +++ b/examples/tutorials/Tripod/myproject/fixingbox.py @@ -17,7 +17,7 @@ def FixingBox(parent, target, name='FixingBox', c = self.addChild('Constraint') target.addChild(c) - c.addObject('RestShapeSpringsForceField', + c.addObject('FixedWeakConstraint', indices=self.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) return self diff --git a/examples/tutorials/Tripod/myproject/maze.py b/examples/tutorials/Tripod/myproject/maze.py index 7f211dca..9062df5b 100644 --- a/examples/tutorials/Tripod/myproject/maze.py +++ b/examples/tutorials/Tripod/myproject/maze.py @@ -78,7 +78,7 @@ def createScene(rootNode): effector.addObject('CGLinearSolver', iterations=100, threshold=1e-5, tolerance=1e-5) effector.addObject('MechanicalObject', template='Rigid3', name='goalMO', position=[0, 40, 0, 0, 0, 0, 1], showObject=True, showObjectScale=10) - effector.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) + effector.addObject('FixedWeakConstraint', indices=0, angularStiffness=1e5, stiffness=1e5) effector.addObject('UncoupledConstraintCorrection', compliance='1e-10 1e-10 0 0 1e-10 0 1e-10 ') # Open maze planning from JSON file diff --git a/examples/tutorials/Tripod/myproject/parts/fixingbox.py b/examples/tutorials/Tripod/myproject/parts/fixingbox.py index cd9d3921..6f61268a 100644 --- a/examples/tutorials/Tripod/myproject/parts/fixingbox.py +++ b/examples/tutorials/Tripod/myproject/parts/fixingbox.py @@ -19,7 +19,7 @@ def FixingBox(parent, target, name='FixingBox', c = self.addChild('Constraint') target.addChild(c) - c.addObject('RestShapeSpringsForceField', + c.addObject('FixedWeakConstraint', indices=self.BoxROI.getData('indices').getLinkPath(), stiffness=1e12) return self diff --git a/examples/tutorials/Tripod/myproject/parts/maze.py b/examples/tutorials/Tripod/myproject/parts/maze.py index 949ca39d..284f61ec 100644 --- a/examples/tutorials/Tripod/myproject/parts/maze.py +++ b/examples/tutorials/Tripod/myproject/parts/maze.py @@ -56,7 +56,7 @@ def createScene(rootNode): effector.addObject('CGLinearSolver', iterations=100, threshold=1e-5, tolerance=1e-5) effector.addObject('MechanicalObject', template='Rigid3', name='goalMO', position=[0, 40, 0, 0, 0, 0, 1], showObject=True, showObjectScale=10) - effector.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) + effector.addObject('FixedWeakConstraint', indices=0, angularStiffness=1e5, stiffness=1e5) effector.addObject('UncoupledConstraintCorrection', compliance='1e-10 1e-10 0 0 1e-10 0 1e-10 ') # Open maze planning from JSON file diff --git a/examples/tutorials/Tripod/myproject/parts/s90servo.py b/examples/tutorials/Tripod/myproject/parts/s90servo.py index 51e6a5b0..360f94a7 100644 --- a/examples/tutorials/Tripod/myproject/parts/s90servo.py +++ b/examples/tutorials/Tripod/myproject/parts/s90servo.py @@ -75,7 +75,7 @@ def init(self): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[0]], rest_position=self.getData('angleIn').getLinkPath()) - angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) + angle.addObject('FixedWeakConstraint', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/myproject/parts/tripodcontroller.py b/examples/tutorials/Tripod/myproject/parts/tripodcontroller.py index a6c3b005..5c43c69c 100644 --- a/examples/tutorials/Tripod/myproject/parts/tripodcontroller.py +++ b/examples/tutorials/Tripod/myproject/parts/tripodcontroller.py @@ -177,7 +177,7 @@ def onKeypressedEvent(self, event): key = event['key'] if key == Key.I: for i in range(3): - self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.RestShapeSpringsForceField.stiffness.value = [0.] + self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.FixedWeakConstraint.stiffness.value = [0.] self.activate = True for node in self.nodesInverseComponents: node.activated = bool(self.activate) diff --git a/examples/tutorials/Tripod/myproject/s90servo.py b/examples/tutorials/Tripod/myproject/s90servo.py index 7a198fa5..ca7c6fdc 100644 --- a/examples/tutorials/Tripod/myproject/s90servo.py +++ b/examples/tutorials/Tripod/myproject/s90servo.py @@ -75,7 +75,7 @@ def __init__(self, *args, **kwargs): angle = self.addChild('Articulation') angle.addObject('MechanicalObject', name='dofs', template='Vec1', position=[[0]], rest_position=self.angleIn.getLinkPath()) - angle.addObject('RestShapeSpringsForceField', indices=0, stiffness=1e9) + angle.addObject('FixedWeakConstraint', indices=0, stiffness=1e9) angle.addObject('UniformMass', totalMass=0.01) servoWheel = angle.addChild('ServoWheel') diff --git a/examples/tutorials/Tripod/myproject/step8-maze.py b/examples/tutorials/Tripod/myproject/step8-maze.py index 64d28912..ae6c0883 100644 --- a/examples/tutorials/Tripod/myproject/step8-maze.py +++ b/examples/tutorials/Tripod/myproject/step8-maze.py @@ -16,7 +16,7 @@ def EffectorGoal(node, position): goal.addObject('EulerImplicitSolver', firstOrder=True) goal.addObject('CGLinearSolver', iterations=100, threshold=1e-12, tolerance=1e-10) goal.addObject('MechanicalObject', name='goalMO', template='Rigid3', position=position+[0., 0., 0., 1.], showObject=True, showObjectScale=10) - goal.addObject('RestShapeSpringsForceField', indices=0, angularStiffness=1e5, stiffness=1e5) + goal.addObject('FixedWeakConstraint', indices=0, angularStiffness=1e5, stiffness=1e5) goal.addObject('UncoupledConstraintCorrection', compliance=[1e-10] * 7) return goal diff --git a/examples/tutorials/Tripod/myproject/tripodcontroller.py b/examples/tutorials/Tripod/myproject/tripodcontroller.py index 8a18563a..bb9fce98 100644 --- a/examples/tutorials/Tripod/myproject/tripodcontroller.py +++ b/examples/tutorials/Tripod/myproject/tripodcontroller.py @@ -183,7 +183,7 @@ def onKeypressedEvent(self, event): key = event['key'] if key == Key.I: for i in range(3): - self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.RestShapeSpringsForceField.stiffness.value = [ + self.nodeTripod.actuatedarms[i].ServoMotor.Articulation.FixedWeakConstraint.stiffness.value = [ 0.] self.activate = True for node in self.nodesInverseComponents: diff --git a/examples/tutorials/Tripod/tripod-tuto.html b/examples/tutorials/Tripod/tripod-tuto.html index e9a25f94..52d08a7d 100644 --- a/examples/tutorials/Tripod/tripod-tuto.html +++ b/examples/tutorials/Tripod/tripod-tuto.html @@ -425,7 +425,7 @@

At the end of this ste

Exploring the scene

    -
  • The constraint implemented by the FixingBox prefab, named RestShapeSpringForceField, applies in fact elastic spring forces on the points of the mechanical object (the degrees of freedom) included in the FixingBox, to bring them back to their resting position whenever a modification is computed (due to gravity forces for example). The stiffness of these ‘springs’ is set at a very high level, which produces immediate correction of any change in position: the constrained points cannot move anymore.
  • +
  • The constraint implemented by the FixingBox prefab, named FixedWeakConstraint, applies in fact elastic spring forces on the points of the mechanical object (the degrees of freedom) included in the FixingBox, to bring them back to their resting position whenever a modification is computed (due to gravity forces for example). The stiffness of these ‘springs’ is set at a very high level, which produces immediate correction of any change in position: the constrained points cannot move anymore.
  • The box can be moved anywhere to constraint another area. For example, the translation [30.0,0.0,30.0] allows to constraint the end of the arm connected to servo 2.
  • By clicking on the [Animate] button, it can be observed that the FixingBox indeed prevents the silicone piece to fall under gravity force. The unconstrained tips of the piece, however, experience a light bending.
  • It is possible to deform the silicone piece with the mouse, by pressing Maj while left-clicking on the piece, then dragging the mouse. This can be used to observe how elastic the material is. By changing the value of the Young modulus, you can compare the rendering of the simulated piece with the real one (for example, test values from 10 to 2000 for the Young modulus after having manipulated the silicone piece on the real robot a bit, to get an idea of its elasticity).
  • @@ -1783,7 +1783,7 @@

    STEP 8.2: Defining a motio effector.addObject('CGLinearSolver', iterations=100, threshold=1e-5, tolerance=1e-5) effector.addObject('MechanicalObject', template='Rigid3', name='goalMO', position=[0, 40, 0, 0, 0, 0, 1], showObject=True, showObjectScale=10) - effector.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1e5, stiffness=1e5) + effector.addObject('FixedWeakConstraint', indices=0, angularStiffness=1e5, stiffness=1e5) effector.addObject('UncoupledConstraintCorrection', compliance='1e-10 1e-10 0 0 1e-10 0 1e-10 ') # Open maze planning from JSON file @@ -1831,7 +1831,7 @@

    STEP 8.3: I goal.addObject('EulerImplicitSolver', firstOrder=True) goal.addObject('CGLinearSolver', iterations=100, threshold=1e-12, tolerance=1e-10) goal.addObject('MechanicalObject', name='goalMO', template='Rigid3', position=position+[0., 0., 0., 1.], showObject=True, showObjectScale=10) - goal.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1e5, stiffness=1e5) + goal.addObject('FixedWeakConstraint', indices=0, angularStiffness=1e5, stiffness=1e5) goal.addObject('UncoupledConstraintCorrection') return goal diff --git a/examples/tutorials/Tripod/tripod-tuto.md b/examples/tutorials/Tripod/tripod-tuto.md index 5352d1e5..e91adea5 100644 --- a/examples/tutorials/Tripod/tripod-tuto.md +++ b/examples/tutorials/Tripod/tripod-tuto.md @@ -180,7 +180,7 @@ Such a function is defined at the beginning of the scene, and can be called as o ## Exploring the scene -- The constraint implemented by the FixingBox *prefab*, named `RestShapeSpringForceField`, applies in fact elastic spring forces on the points of the mechanical object (the degrees of freedom) included in the `FixingBox`, to bring them back to their resting position whenever a modification is computed (due to gravity forces for example). The stiffness of these 'springs' is set at a very high level, which produces immediate correction of any change in position: the constrained points cannot move anymore. +- The constraint implemented by the FixingBox *prefab*, named `FixedWeakConstraint`, applies in fact elastic spring forces on the points of the mechanical object (the degrees of freedom) included in the `FixingBox`, to bring them back to their resting position whenever a modification is computed (due to gravity forces for example). The stiffness of these 'springs' is set at a very high level, which produces immediate correction of any change in position: the constrained points cannot move anymore. - The box can be moved anywhere to constraint another area. For example, the translation `[30.0,0.0,30.0]`{.python} allows to constraint the end of the arm connected to servo 2. - By clicking on the [*Animate*] button, it can be observed that the FixingBox indeed prevents the silicone piece to fall under gravity force. The unconstrained tips of the piece, however, experience a light bending. - It is possible to deform the silicone piece with the mouse, by pressing *Maj* while left-clicking on the piece, then dragging the mouse. This can be used to observe how elastic the material is. By changing the value of the Young modulus, you can compare the rendering of the simulated piece with the real one (for example, test values from 10 to 2000 for the Young modulus after having manipulated the silicone piece on the real robot a bit, to get an idea of its elasticity). diff --git a/tests/component/constraint/scenes/SurfacePressureConstraint.scn b/tests/component/constraint/scenes/SurfacePressureConstraint.scn index 4dcb6300..868dadab 100644 --- a/tests/component/constraint/scenes/SurfacePressureConstraint.scn +++ b/tests/component/constraint/scenes/SurfacePressureConstraint.scn @@ -25,7 +25,7 @@ - + From 9d8fd0fe201c62d1c2ca29f5a6bf0ef78457befc Mon Sep 17 00:00:00 2001 From: Paul Baksic Date: Thu, 3 Apr 2025 14:29:33 +0200 Subject: [PATCH 4/4] Fix scene --- .../DriveTheRobot/Simulation.py | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py b/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py index 8593f190..fe404713 100644 --- a/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py +++ b/examples/thematicalDocs/T4-DirectActuation/DriveTheRobot/Simulation.py @@ -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', indices="@boxROI1.indices", - external_rest_shape="@RestPositionLeg0/meca0", stiffness=1e3) - robot.addObject('RestShapeSpringsForceField', name='fixed2', indices="@boxROI2.indices", - external_rest_shape="@RestPositionLeg1/meca1", stiffness=1e3) - robot.addObject('RestShapeSpringsForceField', name='fixed3', indices="@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