Skip to content

Commit

Permalink
[examples-tests] cleaning scenes, fixes warnings (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
EulalieCoevoet authored Dec 2, 2024
1 parent 07c0f1a commit c8fc9af
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@
def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='SoftRobots')
rootNode.addObject('RequiredPlugin', name='SoftRobots.Inverse')
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Collision.Detection.Algorithm') # Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Collision.Detection.Intersection') # Needed to use components [LocalMinDistance]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Collision.Geometry') # Needed to use components [LineCollisionModel,PointCollisionModel,SphereCollisionModel,TriangleCollisionModel]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Collision.Response.Contact') # Needed to use components [CollisionResponse]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [LinearSolverConstraintCorrection,UncoupledConstraintCorrection]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.IO.Mesh') # Needed to use components [MeshSTLLoader,MeshVTKLoader]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.LinearSolver.Iterative') # Needed to use components [CGLinearSolver]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Mapping.Linear') # Needed to use components [BarycentricMapping]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]
rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel]

rootNode.addObject('VisualStyle',
displayFlags='hideWireframe showVisualModels showBehaviorModels hideCollisionModels '
'hideBoundingCollisionModels hideForceFields showInteractionForceFields')
Expand All @@ -14,10 +49,10 @@ def createScene(rootNode):

rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('QPInverseProblemSolver', printLog=False, epsilon=1e-3, tolerance=1e-4, maxIterations=2500)
rootNode.addObject('DefaultPipeline')
rootNode.addObject('CollisionPipeline')
rootNode.addObject('BruteForceBroadPhase')
rootNode.addObject('BVHNarrowPhase')
rootNode.addObject('DefaultContactManager', response="FrictionContactConstraint", responseParams="mu=0")
rootNode.addObject('CollisionResponse', response="FrictionContactConstraint", responseParams="mu=0")
rootNode.addObject('LocalMinDistance', name="Proximity", alarmDistance=5, contactDistance=3)

##########################################
Expand All @@ -26,7 +61,7 @@ def createScene(rootNode):
goal = rootNode.addChild('goal')
goal.addObject('VisualStyle', displayFlags='showCollisionModels')
goal.addObject('EulerImplicitSolver', firstOrder=True)
goal.addObject('CGLinearSolver', iterations=100)
goal.addObject('CGLinearSolver', iterations=100, tolerance=1e-5, threshold=1e-5)
goal.addObject('MechanicalObject', name='goalMO', showObject=True, showObjectScale=10, drawMode=1,
showColor=[255, 255, 255, 255], position=[40, 30, 30])
goal.addObject('SphereCollisionModel', radius=10, group=[0, 1, 2])
Expand All @@ -44,7 +79,7 @@ def createScene(rootNode):
model.addObject('UniformMass', totalMass=0.03)
model.addObject('TetrahedronFEMForceField', poissonRatio=0.3, youngModulus=180)
model.addObject('BoxROI', name='boxROI', box=[0, 50, -20, 10, 70, 20], drawBoxes=False)
model.addObject('FixedConstraint', indices='@boxROI.indices')
model.addObject('FixedProjectiveConstraint', indices='@boxROI.indices')
model.addObject('LinearSolverConstraintCorrection')

##########################################
Expand All @@ -60,8 +95,8 @@ def createScene(rootNode):
skin.addObject('TetrahedronFEMForceField', poissonRatio=0.3, youngModulus=180)
skin.addObject('BoxROI', name='boxROI1', box=[-100, -5, -30, -90, 5, 30], drawBoxes=False)
skin.addObject('BoxROI', name='boxROI2', box=[100, -5, -30, 90, 5, 30], drawBoxes=False)
skin.addObject('FixedConstraint', name='fix_1', indices='@boxROI1.indices')
skin.addObject('FixedConstraint', name='fix_2', indices='@boxROI2.indices')
skin.addObject('FixedProjectiveConstraint', name='fix_1', indices='@boxROI1.indices')
skin.addObject('FixedProjectiveConstraint', name='fix_2', indices='@boxROI2.indices')
skin.addObject('LinearSolverConstraintCorrection')

##########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@
def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='SoftRobots')
rootNode.addObject('RequiredPlugin', name='SoftRobots.Inverse')
rootNode.addObject('RequiredPlugin', name='ArticulatedSystemPlugin')
rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [UncoupledConstraintCorrection]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Iterative') # Needed to use components [CGLinearSolver]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Setting') # Needed to use components [BackgroundSetting]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Projective') # Needed to use components [FixedProjectiveConstraint]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Generate') # Needed to use components [GenerateRigidMass]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshSTLLoader]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.NonLinear') # Needed to use components [RigidMapping]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
rootNode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel]

rootNode.dt = 0.1
rootNode.gravity = [0., -981., 0.]
Expand All @@ -24,15 +39,15 @@ def createScene(rootNode):
# Target position of the end effector
goal = rootNode.addChild('Goal')
goal.addObject('EulerImplicitSolver', firstOrder=True)
goal.addObject('CGLinearSolver')
goal.addObject('MechanicalObject', name='dofs', template='Rigid3', position=[5, 0, 0, 0, 0, 0, 1],
showObject=1, showObjectScale=1, drawMode=1)
goal.addObject('CGLinearSolver', iterations=25, tolerance=1e-5, threshold=1e-5)
goal.addObject('MechanicalObject', name='dofs', position=[5, 5, 0],
showObject=True, showObjectScale=0.5, drawMode=2)
goal.addObject('UncoupledConstraintCorrection')

# Simulation node
simulation = rootNode.addChild('Simulation')
simulation.addObject('EulerImplicitSolver')
simulation.addObject('CGLinearSolver')
simulation.addObject('CGLinearSolver', iterations=25, tolerance=1e-5, threshold=1e-5)

object = simulation.addChild('Object')
object.addObject('MechanicalObject', name='dofs', template='Vec1', position=0.)
Expand All @@ -42,10 +57,12 @@ def createScene(rootNode):
rigid = object.addChild('Rigid')
rigid.addObject('MechanicalObject', template='Rigid3', name='dofs',
position=[[0., 0., 0., 0., 0., 0., 1.], [4.5, 0., 0., 0., 0., 0., 1.]])
rigid.addObject('PositionEffector', template='Rigid3', indices=1,
effectorGoal=goal.dofs.findData('position').getLinkPath(), useDirections=[1, 1, 0, 0, 0, 0])
rigid.addObject('BeamFEMForceField', name='FEM', radius=0.2, youngModulus=1e3, poissonRatio=0.45)
rigid.addObject('MeshTopology', lines=[0, 1])

effector = rigid.addChild("Effector")
effector.addObject("MechanicalObject")
effector.addObject('PositionEffector', indices=0, effectorGoal=goal.dofs.findData('position').getLinkPath(),
useDirections=[1, 1, 0])
effector.addObject("RigidMapping", index=1)

visual = rigid.addChild('VisualModel')
visual.addObject('MeshSTLLoader', name='loader', filename=dirPath + 'mesh/arm.stl', translation=[-4.5, 0., 0.],
Expand All @@ -55,7 +72,7 @@ def createScene(rootNode):
visual.addObject('RigidMapping', index=1)

rigid.addObject('GenerateRigidMass', name='mass', density=0.002, src=visual.loader.getLinkPath())
rigid.addObject('FixedConstraint', template='Rigid3', indices=0)
rigid.addObject('FixedProjectiveConstraint', template='Rigid3', indices=0)
rigid.addObject('ArticulatedSystemMapping', input1=object.dofs.getLinkPath(), output=rigid.dofs.getLinkPath())
rigid.addObject('UniformMass', vertexMass=rigid.mass.findData('rigidMass').getLinkPath())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ def createScene(rootNode):
rootNode.addObject('RequiredPlugin', name='BeamAdapter')
rootNode.addObject('RequiredPlugin', name='SoftRobots')
rootNode.addObject('RequiredPlugin', name='SoftRobots.Inverse')
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection,UncoupledConstraintCorrection]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Constraint.Projective') # Needed to use components [PartialFixedProjectiveConstraint]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.LinearSolver.Iterative') # Needed to use components [CGLinearSolver]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Mapping.NonLinear') # Needed to use components [RigidMapping]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootNode.addObject('RequiredPlugin',
name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology]
rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]
rootNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels showCollisionModels '
'showForceFields showInteractionForceFields')

Expand Down Expand Up @@ -46,10 +67,10 @@ def createScene(rootNode):

model.addObject('BeamInterpolation', dofsAndBeamsAligned=True, straight=False, defaultYoungModulus=100, radius=0.5)
model.addObject('AdaptiveBeamForceFieldAndMass', computeMass=True, massDensity=0.000001)
# Unfortunatly, the component SlidingActuator needs to be used with a PartialFixedConstraint.
# Unfortunatly, the component SlidingActuator needs to be used with a PartialFixedProjectiveConstraint.
# Ex: if SlidingActuator simulates a single dof (e.g. translation along x),
# the other dofs must be fixed using this component
model.addObject('PartialFixedConstraint', indices=0, fixedDirections=[0, 1, 1, 1, 1, 0])
model.addObject('PartialFixedProjectiveConstraint', indices=0, fixedDirections=[0, 1, 1, 1, 1, 0])
model.addObject('RestShapeSpringsForceField', points=0, angularStiffness=1000, stiffness=1000)

##########################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ def createScene(rootnode):
from splib3.animation import animate, AnimationManager
rootnode.addObject(AnimationManager(rootnode))
rootnode.addObject('RequiredPlugin', pluginName=['SoftRobots', 'SoftRobots.Inverse', 'SofaPython3'])
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop]
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [GenericConstraintCorrection,UncoupledConstraintCorrection]
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.Constraint.Projective') # Needed to use components [PartialFixedProjectiveConstraint]
rootnode.addObject('RequiredPlugin', name='Sofa.Component.IO.Mesh') # Needed to use components [MeshOBJLoader]
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.LinearSolver.Iterative') # Needed to use components [CGLinearSolver]
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.Mapping.NonLinear') # Needed to use components [RigidMapping]
rootnode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
rootnode.addObject('RequiredPlugin',
name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
rootnode.addObject('RequiredPlugin', name='Sofa.GL.Component.Rendering3D') # Needed to use components [OglModel]

rootnode.gravity = [0, 0, 0]
rootnode.addObject('DefaultVisualManagerLoop')
rootnode.addObject('FreeMotionAnimationLoop')
Expand All @@ -14,8 +34,8 @@ def createScene(rootnode):
cube.addObject('GenericConstraintCorrection')
cube.addObject('MechanicalObject', template='Rigid3', position=[-10, 0, 0, 0, 0, 0, 1])
cube.addObject('UniformMass', totalMass=0.01)
# SlidingActuator needs a PartialFixedConstraint to fix the other directions
cube.addObject('PartialFixedConstraint', template='Rigid3', fixedDirections=[0, 1, 1, 1, 1, 1])
# SlidingActuator needs a PartialFixedProjectiveConstraint to fix the other directions
cube.addObject('PartialFixedProjectiveConstraint', template='Rigid3', fixedDirections=[0, 1, 1, 1, 1, 1])
cube.addObject('SlidingActuator', template='Rigid3', indices=0, direction=[1, 0, 0, 0, 0, 0], maxDispVariation=0.1)

visual = cube.addChild('Visu')
Expand All @@ -35,7 +55,7 @@ def createScene(rootnode):
target.addObject('EulerImplicitSolver', firstOrder=True)
target.addObject('CGLinearSolver', tolerance=1e-5, iterations=20, threshold=1e-5)
target.addObject('MechanicalObject', position=[30, 0, 0], showObject=True, drawMode=2, showObjectScale=3)
target.addObject('PartialFixedConstraint', fixedDirections=[0, 1, 1])
target.addObject('PartialFixedProjectiveConstraint', fixedDirections=[0, 1, 1])
target.addObject('UniformMass', totalMass=0.1)
target.addObject('UncoupledConstraintCorrection')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
<RequiredPlugin name="SoftRobots"/>
<RequiredPlugin name="SoftRobots.Inverse"/>
<RequiredPlugin name="BeamAdapter"/>
<RequiredPlugin name="Sofa.Component.AnimationLoop"/> <!-- Needed to use components [FreeMotionAnimationLoop] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Algorithm"/> <!-- Needed to use components [BVHNarrowPhase,BruteForceBroadPhase] -->
<RequiredPlugin name="Sofa.Component.Collision.Detection.Intersection"/> <!-- Needed to use components [MinProximityIntersection] -->
<RequiredPlugin name="Sofa.Component.Constraint.Lagrangian.Correction"/> <!-- Needed to use components [LinearSolverConstraintCorrection] -->
<RequiredPlugin name="Sofa.Component.Constraint.Projective"/> <!-- Needed to use components [FixedProjectiveConstraint] -->
<RequiredPlugin name="Sofa.Component.LinearSolver.Direct"/> <!-- Needed to use components [BTDLinearSolver] -->
<RequiredPlugin name="Sofa.Component.Mapping.Linear"/> <!-- Needed to use components [BeamLinearMapping] -->
<RequiredPlugin name="Sofa.Component.ODESolver.Backward"/> <!-- Needed to use components [EulerImplicitSolver] -->
<RequiredPlugin name="Sofa.Component.SceneUtility"/> <!-- Needed to use components [InfoComponent] -->
<RequiredPlugin name="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
<RequiredPlugin name="Sofa.Component.Topology.Container.Constant"/> <!-- Needed to use components [CubeTopology,MeshTopology] -->
<RequiredPlugin name="Sofa.Component.Visual"/> <!-- Needed to use components [VisualStyle] -->
<RequiredPlugin name="Sofa.GL.Component.Rendering3D"/> <!-- Needed to use components [OglModel] -->
<RequiredPlugin name="Sofa.Component.Collision.Response.Contact"/> <!-- Needed to use components [CollisionResponse] -->

<VisualStyle displayFlags="showForceFields showCollisionModels showBehavior" />
<DefaultPipeline depth="6" verbose="0" draw="0" />
<CollisionPipeline depth="6" verbose="0" draw="0" />
<BruteForceBroadPhase />
<BVHNarrowPhase/>
<MinProximityIntersection name="Proximity" alarmDistance="0.03" contactDistance="0.02" />
<DefaultContactManager/>
<CollisionResponse/>
<FreeMotionAnimationLoop/>
<QPInverseProblemSolver printLog='0'/>

Expand Down Expand Up @@ -47,7 +61,7 @@
<BeamLinearMapping />
</Node>

<FixedConstraint name="FixedConstraint" indices="0" />
<FixedProjectiveConstraint name="FixedProjectiveConstraint" indices="0" />
<AdaptiveBeamForceFieldAndMass name="FEM"/>

<Node name="Visual">
Expand Down
Loading

0 comments on commit c8fc9af

Please sign in to comment.