- This topic has 3 replies, 2 voices, and was last updated 3 years, 4 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Home › Forum › SofaPython3 › Using SofaPython3 › [SOLVED] Springs not working
Tagged: SOFA_2012, SofaPython3, springs, Windows_10
Good morning,
I have a problem with my project that I am developing with sofapython3.
I am trying to attach a needle to a patch of skin via springs as one of the steps to simulate a suturing process. The simplified version of the code is at https://drive.google.com/drive/folders/1iFCfvDJEsb1RgscltzMcOi4EoHYjfOka?usp=sharing together with a video of the simulation.
In this code I have:
– the patch of skin. It is fixed with a boxROI and has another boxROI to compute indices in a specific region (I need those indices to attach the springs).
– the needle. It has a sphere collision model to which i attach the springs.
– a controller. It creates the springs between skin and needle as soon as animation begins.
My problem is: the springs just elongate but do not pull that area of the skin with the needle. Is it possible to so so with this component (StiffSpringForceField with LinearSprings)? If not, do you know how I could achieve the same result?
Any suggestion would be really appreciated.
Thank you in advance,
Chiara
Does anyone have a suggestion?
Hey Chiara
That’s because your StiffSpringForceField
must be on the same level as the mechanical object that receives the forces (ie the skin). In your case, you added it inside the root node. Something like this should work :
def Skin(parentNode=None, name=None, rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0],
scale3d=[0.0, 0.0, 0.0], fixingBox=[0.0, 0.0, 0.0], importFile=None):
# (...)
# Data
Skin.node = name
# (...)
# (...)
# Controller
class SutureTrainingContactController(Sofa.Core.Controller):
def __init__(self, name, rootNode):
Sofa.Core.Controller.__init__(self, name, rootNode)
# Define spring force field (Skin-Needle)
self.spring_force_field = Skin.node.addObject("StiffSpringForceField", name="LeftFF", object1 = Skin.MO, object2=SutureNeedle.COLL_BACK_MO)
# (...)
Also, you will probably need to drop down a bit the stiffness on those springs when you test this out 😉
J-N
Thank you very much, it works perfectly!
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.