Skip to content

Commit

Permalink
Fix logging in SparseLDLSolver and update gravity in tutorial
Browse files Browse the repository at this point in the history
- Disabled `printLog` in `SparseLDLSolver` within `header.py` for
cleaner output.
- Set `root_node.gravity` to `[0, -9.81, 0]` in `tuto_5.py` for
realistic gravitational effect.
- Added flexibility in constraint setup for `cable_node` by introducing
`is_constrained` parameter.
- Included missing `return root_node` statement to ensure complete scene
creation in `createScene()`.
  • Loading branch information
adagolodjo committed Oct 30, 2024
1 parent 07fa31e commit 8f54ed3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/python3/useful/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def addSolverNode(parent_node, name='solverNode', template='CompressedRowSparseM
if iterative:
solver_node.addObject('CGLinearSolver', name='Solver', template=template)
else:
solver_node.addObject('SparseLDLSolver', name='Solver', template=template, printLog=True)
solver_node.addObject('SparseLDLSolver', name='Solver', template=template, printLog=False)
if isConstrained:
solver_node.addObject('GenericConstraintCorrection', linearSolver=solver_node.Solver.getLinkPath())

Expand Down
8 changes: 5 additions & 3 deletions tutorial/tuto_scenes/tuto_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
Params = Parameters(beam_geo_params=geoParams, beam_physics_params=physicsParams, simu_params=simuParams)

femPos = [[0.0, 0, 0], [15., 0, 0], [30., 0, 0], [45., 0, 0], [60., 0, 0], [66., 0, 0], [81., 0.0, 0.0]]

is_constrained = False

class ForceController(Sofa.Core.Controller):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -101,9 +101,9 @@ def onKeypressedEvent(self, event):

def createScene(root_node):
addHeader(root_node, is_constrained=True)
root_node.gravity = [0, 0., 0.]
root_node.gravity = [0, -9.81, 0.]

solver_node = addSolverNode(root_node, name="cable_node", isConstrained=True)
solver_node = addSolverNode(root_node, name="cable_node", isConstrained=is_constrained)

# create cosserat Beam
cosserat_beam = solver_node.addChild(CosseratBase(parent=solver_node, params=Params))
Expand All @@ -117,6 +117,8 @@ def createScene(root_node):

finger_node, fem_points_node = addFEMObject(root_node, path=path, name="Finger")

return root_node

# This creates a new node in the scene. This node is appended to the finger's node.
cable_state_node = cosserat_frames_node.addChild('cable_state_node')

Expand Down

0 comments on commit 8f54ed3

Please sign in to comment.