-
Notifications
You must be signed in to change notification settings - Fork 57
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
[constraint] adds JointConstraint #274
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d0bbaf2
Fix v23.06 ci (#230)
olivier-roussel a62ec4c
Fix install SofaPython3 CI action. (#231)
olivier-roussel fbbbe3f
Fix source code archives assets from release branch and not master.
olivier-roussel 9e155f3
Merge pull request #234 from olivier-roussel/fix_23.06_wrong_assets_s…
olivier-roussel 1b3ef9d
First commit for JointConstraint
TanguyNav f414ef7
Solve bug in angle displacement in JointConstraint
TanguyNav 48ff4cd
Merge branch 'refs/heads/master' into JointConstraint_v23.06
EulalieCoevoet 2b9a1be
[constraint] JointConstraint: minor cleaning
EulalieCoevoet 0539767
[constraint] JointConstraint: adds en example
EulalieCoevoet 4d88c4c
[constraint] list of changes:
EulalieCoevoet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
examples/component/constraint/JointConstraint/JointConstraint.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
from math import pi | ||
|
||
dirPath = os.path.dirname(os.path.abspath(__file__)) + '/' | ||
|
||
|
||
def createScene(rootNode): | ||
rootNode.addObject('RequiredPlugin', name='SoftRobots') | ||
rootNode.addObject('RequiredPlugin', name='SoftRobots.Inverse') | ||
rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] | ||
rootNode.addObject('RequiredPlugin', name='ArticulatedSystemPlugin') # Needed to use components [ArticulatedHierarchyContainer,ArticulatedSystemMapping,Articulation,ArticulationCenter] | ||
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.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver] | ||
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.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.SolidMechanics.FEM.Elastic') # Needed to use components [BeamFEMForceField] | ||
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.dt = 0.01 | ||
rootNode.gravity = [0., -9810., 0.] | ||
rootNode.addObject('VisualStyle', displayFlags='showBehaviorModels') | ||
rootNode.addObject('FreeMotionAnimationLoop') | ||
rootNode.addObject('GenericConstraintSolver', maxIterations=500, tolerance=1e-4) | ||
|
||
# Simulation node | ||
simulation = rootNode.addChild('Simulation') | ||
simulation.addObject('EulerImplicitSolver') | ||
simulation.addObject('SparseLDLSolver', template="CompressedRowSparseMatrixd") | ||
simulation.addObject('GenericConstraintCorrection') | ||
|
||
object = simulation.addChild('Object') | ||
object.addObject('MechanicalObject', template='Vec1', position=0.) | ||
object.addObject("RestShapeSpringsForceField", points=[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) | ||
|
||
rigid = object.addChild('Rigid') | ||
rigid.addObject('MechanicalObject', template='Rigid3', position=[[0., 0., 0., 0., 0., 0., 1.]]*2) | ||
rigid.addObject('UniformMass', totalMass=0.003) | ||
rigid.addObject('ArticulatedSystemMapping', | ||
input1=object.getMechanicalState().linkpath, | ||
output=rigid.getMechanicalState().linkpath) | ||
|
||
visual = rigid.addChild('VisualModel') | ||
visual.addObject('MeshSTLLoader', name='loader', filename=dirPath + 'mesh/arm.stl', translation=[-45, 0., 0.]) | ||
visual.addObject('MeshTopology', src='@loader') | ||
visual.addObject('OglModel', color=[0.9, 0.9, 0.9, 1.]) | ||
visual.addObject('RigidMapping', index=1) | ||
|
||
articulationCenters = object.addChild('Articulation') | ||
articulationCenter = articulationCenters.addChild('ArticulationCenter') | ||
articulationCenter.addObject('ArticulationCenter', parentIndex=0, childIndex=1, | ||
posOnParent=[0., 0., 0.], | ||
posOnChild=[-45, 0., 0.], articulationProcess=1) | ||
articulation = articulationCenter.addChild('Articulations') | ||
articulation.addObject('Articulation', translation=False, rotation=True, rotationAxis=[0, 0, 1], | ||
articulationIndex=0) | ||
|
||
object.addObject('ArticulatedHierarchyContainer') | ||
|
||
return rootNode |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EulalieCoevoet Could you make sure that this plugin is not required? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups sorry. Not needed indeed.