sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
871 stars 297 forks source link

How to reset the simulation #4704

Open candi4 opened 2 weeks ago

candi4 commented 2 weeks ago

Hello, thank you for good simulator.

I'm attempting to utilize SOFA for RL. I'd like to create a function for resetting the simulation, but I'm not sure how to go about it.

I have tried the following methods to reset the simulation with SofaPython3, but they have been unsuccessful:

del root
del Sofa
import Sofa
root = Sofa.Core.Node("root")
createScene()
Sofa.Simulation.init(root)
del root
import importlib
importlib.reload(Sofa)
root = Sofa.Core.Node("root")
createScene()
Sofa.Simulation.init(root)
del root
import sys
del sys.modules['Sofa']
root = Sofa.Core.Node("root")
createScene()
Sofa.Simulation.init(root)

Thank you.