Home › Forum › SofaPython3 › Using SofaPython3 › [SOLVED] Springs not working
Tagged: SOFA_2012, SofaPython3, springs, Windows_10
- This topic has 3 replies, 2 voices, and was last updated 4 years, 3 months ago by
chiarasapo.
-
AuthorPosts
-
19 July 2021 at 09:14 #20039
chiarasapo
BlockedGood 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,
Chiara28 July 2021 at 16:13 #20089chiarasapo
BlockedDoes anyone have a suggestion?
28 July 2021 at 17:34 #20093jnbrunet
ModeratorHey Chiara
That’s because your
StiffSpringForceFieldmust 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
17 August 2021 at 11:30 #20177chiarasapo
BlockedThank you very much, it works perfectly!
-
AuthorPosts
- You must be logged in to reply to this topic.
