Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename the docs folder to tutorial and testScene to tutorial_scenes and clean scene #117

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions examples/python3/cosserat/CosseratBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from useful.header import addHeader, addVisual, addSolverNode
from useful.params import Parameters, BeamGeometryParameters
from useful.geometry import CosseratGeometry, generate_edge_list
from numpy import array


class CosseratBase(Sofa.Prefab):
Expand All @@ -39,13 +40,13 @@ class CosseratBase(Sofa.Prefab):
"name": "translation",
"type": "Vec3d",
"help": "Cosserat base Rotation",
"default": [0.0, 0.0, 0.0],
"default": array([0.0, 0.0, 0.0]),
},
{
"name": "rotation",
"type": "Vec3d",
"help": "Cosserat base Rotation",
"default": [0.0, 0.0, 0.0],
"default": array([0.0, 0.0, 0.0]),
},
{ # @TODO: to be removed
"name": "attachingToLink",
Expand Down Expand Up @@ -116,13 +117,8 @@ def _addPointCollisionModel(self, nodeName="CollisionPoints"):

def _addSlidingPoints(self):
slidingPoint = self.cosseratFrame.addChild("slidingPoint")
slidingPoint.addObject(
"MechanicalObject",
name="slidingPointMO",
position=self.frames3D,
showObject="0",
showIndices="0",
)
slidingPoint.addObject("MechanicalObject", name="slidingPointMO", position=self.frames3D,
showObject="0", showIndices="0")
slidingPoint.addObject("IdentityMapping")
return slidingPoint

Expand All @@ -142,8 +138,6 @@ def _addSlidingPointsWithContainer(self):

def _addRigidBaseNode(self):
rigidBaseNode = self.addChild("rigidBase")
trans = list(self.translation.value)
rot = list(self.rotation.value)
# To be improved with classes in top
positions = [[self.params.beamGeoParams.init_pos] + [0.0, 0.0, 0.0, 1.0]]

Expand All @@ -152,10 +146,7 @@ def _addRigidBaseNode(self):
template="Rigid3d",
name="RigidBaseMO",
showObjectScale=0.2,
translation=trans, # @Todo: To be removed
position=positions,
rotation=rot, # @Todo: To be removed
# showObject=int(self.showObject.value),
position=positions
)
rigidBaseNodeMo.showObject.setParent(self.showObject)

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions docs/testScene/tuto_1.py → tutorial/tuto_scenes/tuto_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ def _add_cosserat_frame(


def createScene(root_node):
root_node.addObject("RequiredPlugin", name='Sofa.Component.Mass')
root_node.addObject("RequiredPlugin", name='Sofa.Component.SolidMechanics.Spring')
root_node.addObject("RequiredPlugin", name='Sofa.Component.StateContainer')
root_node.addObject("RequiredPlugin", name='Sofa.Component.Visual')

root_node.addObject(
"VisualStyle",
displayFlags="showBehaviorModels showCollisionModels showMechanicalMappings",
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions docs/testScene/tuto_2.py → tutorial/tuto_scenes/tuto_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def _add_cosserat_frame(


def createScene(root_node):
root_node.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver]
root_node.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass]
root_node.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver]
root_node.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField]
root_node.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject]
root_node.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle]

root_node.addObject(
"VisualStyle",
displayFlags="showBehaviorModels showCollisionModels showMechanicalMappings",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions docs/testScene/tuto_5.py → tutorial/tuto_scenes/tuto_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from math import pi
from useful.header import addHeader, addVisual, addSolverNode, Finger
from controller import FingerController
from numpy import array


path = f'{os.path.dirname(os.path.abspath(__file__))}/../../examples/python3/actuators/mesh/'
Expand Down Expand Up @@ -109,11 +110,11 @@ def createScene(root_node):
cosserat_beam = solver_node.addChild(CosseratBase(parent=solver_node, params=Params))
cosserat_frames_node = cosserat_beam.cosseratFrame

# Finger state
# Finger node
femFingerNode = root_node.addChild('femFingerNode')
""" Add FEM finger to the scene"""
finger_node, fem_points_node = Finger(femFingerNode, name="Finger", rotation=[0.0, 180.0, 0.0],
translation=[-17.5, -12.5, 7.5], path=path)
finger_node, fem_points_node = Finger(femFingerNode, name="Finger", rotation=array([0.0, 180.0, 0.0]),
translation=array([-17.5, -12.5, 7.5]), path=path)

# 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
Loading