diff --git a/examples/python3/cosserat/CosseratBase.py b/examples/python3/cosserat/CosseratBase.py index c4e29950..d0948d82 100644 --- a/examples/python3/cosserat/CosseratBase.py +++ b/examples/python3/cosserat/CosseratBase.py @@ -146,7 +146,9 @@ def _addRigidBaseNode(self): template="Rigid3d", name="RigidBaseMO", showObjectScale=0.2, - position=positions + position=positions, + translation=self.translation, + rotation=self.rotation ) rigidBaseNodeMo.showObject.setParent(self.showObject) @@ -226,8 +228,8 @@ def _addCosseratFrame(self, framesF, curv_abs_inputS, curv_abs_outputF): template="Rigid3d", name="FramesMO", position=framesF, - showIndices=self.params.beamGeoParams.showFramesObject, - showObject=self.params.beamGeoParams.showFramesObject, + showIndices=self.params.beamGeoParams.show_frames_indices, + showObject=self.params.beamGeoParams.show_frames_object, showObjectScale=1.8, # Todo: remove this hard code ) diff --git a/examples/python3/useful/geometry.py b/examples/python3/useful/geometry.py index bb8d86f7..4bec898b 100644 --- a/examples/python3/useful/geometry.py +++ b/examples/python3/useful/geometry.py @@ -67,7 +67,7 @@ def calculate_frame_parameters(beamGeoParams): return frames_f, curv_abs_output_f, cable_position_f -def generate_edge_list(cable3DPos: List[List[float]]) -> List[int]: +def generate_edge_list(cable3DPos: List[List[float]]) -> list[list[int]]: """ Generate an edge list required in the EdgeSetTopologyContainer component. @@ -78,7 +78,11 @@ def generate_edge_list(cable3DPos: List[List[float]]) -> List[int]: List[int]: A list of indices forming edges in the EdgeSetTopologyContainer. """ number_of_points = len(cable3DPos) - return [i for i in range(number_of_points - 1) for _ in range(2)] + edges = [] + for i in range(number_of_points - 1): + edges.append([i,i+1]) + return edges + class CosseratGeometry: diff --git a/examples/python3/useful/header.py b/examples/python3/useful/header.py index ea77ced6..aceac414 100644 --- a/examples/python3/useful/header.py +++ b/examples/python3/useful/header.py @@ -17,7 +17,7 @@ import os -def addHeader(parentNode, multithreading=False, inverse=False, isConstrained=False, isContact=False): +def addHeader(parentNode, multithreading=False, inverse=False, isConstrained=False, isContact=False, params=None): """ Adds to rootNode the default headers for a simulation with contact. Also adds and returns three nodes: - Settings @@ -68,7 +68,7 @@ def addHeader(parentNode, multithreading=False, inverse=False, isConstrained=Fal parentNode.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels showCollisionModels ' 'hideBoundingCollisionModels hideForceFields ' - 'hideInteractionForceFields hideWireframe showMechanicalMappings') + 'showInteractionForceFields hideWireframe showMechanicalMappings') if isConstrained: parentNode.addObject('FreeMotionAnimationLoop', parallelCollisionDetectionAndFreeMotion=multithreading, parallelODESolving=multithreading) @@ -78,20 +78,26 @@ def addHeader(parentNode, multithreading=False, inverse=False, isConstrained=Fal multithreading=multithreading, epsilon=1) else: parentNode.addObject('GenericConstraintSolver', name='ConstraintSolver', tolerance=1e-8, maxIterations=100, - multithreading=multithreading) + multithreading=multithreading, printLog=1) if isContact: - contactHeader(parentNode) + contactHeader(parentNode, _contact_params=params.contactParams) # components needed for contact modeling -def contactHeader(parentNode): +def contactHeader(parentNode, _contact_params=None): parentNode.addObject('CollisionPipeline') parentNode.addObject("DefaultVisualManagerLoop") - parentNode.addObject('RuleBasedContactManager', responseParams='mu=0.8', response='FrictionContactConstraint') parentNode.addObject('BruteForceBroadPhase') parentNode.addObject('BVHNarrowPhase') - parentNode.addObject('LocalMinDistance', alarmDistance=0.05, contactDistance=0.01) + if not _contact_params == None: + parentNode.addObject('RuleBasedContactManager', responseParams=_contact_params.responseParams, + response='FrictionContactConstraint') + parentNode.addObject('LocalMinDistance', alarmDistance=_contact_params.alarmDistance, + contactDistance=_contact_params.contactDistance) + else : + parentNode.addObject('RuleBasedContactManager', responseParams='mu=0.1', response='FrictionContactConstraint') + parentNode.addObject('LocalMinDistance', alarmDistance=0.05, contactDistance=0.01) def addVisual(node): @@ -105,7 +111,7 @@ def addVisual(node): """ node.addObject('VisualStyle', displayFlags='showVisualModels showBehaviorModels hideCollisionModels ' 'hideBoundingCollisionModels hideForceFields ' - 'hideInteractionForceFields hideWireframe showMechanicalMappings') + 'showInteractionForceFields hideWireframe showMechanicalMappings') return node @@ -134,7 +140,7 @@ def addSolverNode(node, name='solverNode', template='CompressedRowSparseMatrixd' if iterative: solverNode.addObject('CGLinearSolver', name='Solver', template=template) else: - solverNode.addObject('SparseLDLSolver', name='Solver', template=template) + solverNode.addObject('SparseLDLSolver', name='Solver', template=template, printLog=True) if isConstrained: solverNode.addObject('GenericConstraintCorrection', linearSolver=solverNode.Solver.getLinkPath()) diff --git a/examples/python3/useful/params.py b/examples/python3/useful/params.py index 2f553ed4..25e4805b 100644 --- a/examples/python3/useful/params.py +++ b/examples/python3/useful/params.py @@ -18,7 +18,8 @@ class BeamGeometryParameters: ) # The beam rigid base position as a list [x, y, z] """Parameters for the visualisation of the beam""" - showFramesObject: int = 1 + show_frames_object: bool = True + show_frames_indices: bool = False showRigidBaseObject: int = 1 @@ -71,7 +72,7 @@ class VisualParameters: class ContactParameters: """Contact parameters""" - responseParams: str = "mu=0.8" + responseParams: str = "mu=0.0" response: str = "FrictionContactConstraint" alarmDistance: float = 0.05 contactDistance: float = 0.01