Struggling with FixingBox for Constraining Mechanical Model in SOFA #4965
-
Hi I am a beginner in using SOFA and I am currently learning how to add fixed constraints to a mechanical model in my simulation. I have been trying to use FixingBox, but I haven't been able to get it to work as expected. I followed some tutorials and tried to use FixingBox to apply fixed constraints to certain areas of my model, but the model still moves freely in the simulation instead of being fixed. Here is the code snippet I am using: from stlib.scene import Scene
from fixingbox import FixingBox
def createScene(rootNode):
scene = Scene(rootNode, gravity=[0.0, -9810.0, 0.0], plugins=["SofaSparseSolver"])
rootNode.dt = 0.01
# Graphic modelling of the legends associated to the servomotors
scene.Config.createObject("MeshSTLLoader", name="loader", filename="data/mesh/blueprint.stl")
scene.Config.createObject("OglModel", src="@loader")
elasticbody = rootNode.createChild("ElasticBody")
elasticbody.createObject('GIDMeshLoader',
name='loader',
filename="data/mesh/tripod_high.gidmsh")
elasticbody.createObject('TetrahedronSetTopologyContainer',
src='@loader',
name='container')
elasticbody.createObject("MechanicalObject",
name="dofs",
position=elasticbody.loader.position,
rotation=[90.0, 0.0, 0.0],
showObject=True,
showObjectScale=5.0)
elasticbody.createObject("UniformMass", totalMass=0.032)
elasticbody.createObject("EulerImplicitSolver")
elasticbody.createObject("SparseLDLSolver")
elasticbody.createObject("TetrahedronFEMForceField",
youngModulus=800,
poissonRatio=0.45)
# Visual model
visual = elasticbody.createChild("Visual")
visual.createObject("MeshSTLLoader",
name="loader",
filename="data/mesh/tripod_mid.stl",
rotation=[90, 0, 0])
visual.createObject("OglModel",
src="@loader",
name="renderer",
color=[1.0, 1.0, 1.0, 0.5])
visual.createObject("BarycentricMapping",
input=elasticbody.dofs.getLinkPath(),
output=visual.renderer.getLinkPath())
# Adding FixingBox to constrain part of the mechanical model
fix = FixingBox(rootNode,
elasticbody.ElasticMaterialObject,
translation=[0, 0, 0],
scale=[30., 30., 30.])
fix.BoxROI.drawBoxes = True As shown above, I used FixingBox at the end of the code to apply fixed constraints to certain areas of the model. However, no matter how I adjust the translation and scale parameters, the object in the simulation is still not fixed. I have a few questions: What is the correct usage of FixingBox? Am I making a mistake somewhere? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, you can use a SelectEngine like BoxROI, SphereROI, etc.. to select the area of points you want to fix and then give the input to your FixedConstraint. Best regards |
Beta Was this translation helpful? Give feedback.
Hi,
you can use a SelectEngine like BoxROI, SphereROI, etc.. to select the area of points you want to fix and then give the input to your FixedConstraint.
You can check an example here: https://github.com/sofa-framework/sofa/blob/master/examples/Component/Engine/Select/BoxROI.scn
Best regards