Home › Forum › SOFA › Using SOFA › [SOLVED] End simulation from a python script controller
Tagged: 64_bits, Linux_ubuntu, SOFA_1608
- This topic has 8 replies, 3 voices, and was last updated 7 years, 8 months ago by mmoge.
-
AuthorPosts
-
8 February 2017 at 15:05 #8524mmogeBlocked
Hi everyone !
I want to stop my simulation after a given number of time steps.
To do this I am trying to use a python script controller that counts the number of iterations indef onBeginAnimationStep(self,dt)
and then ends the simulation in
def onEndAnimationStep(self,dt)
How can I properly tell Sofa to end the simulation at the end of the animation step ?
Thanks !
Maxime8 February 2017 at 18:08 #8528maxBlockedHello,
Try setting the ‘animate’ attribute of the root node to False in the script.
Best,
10 February 2017 at 09:47 #8550mmogeBlockedThank you but that just stops the animation, runSofa is still running. What I want if to quit runSofa completely.
10 February 2017 at 10:37 #8552HugoKeymasterHi Maxime (Moge),
The hint of Max (Tournier) was good for pausing the animation. But if you want to end it, then you need to send an exit command in python.
At each step of the simulation, you can check with a step counter how many steps have been computed. And when you want to quit, just do something like:
sys.exit(0)
(need to import sys)Hope this helps.
Hugo
10 February 2017 at 12:59 #8556mmogeBlockedHi Hugo,
That is what I am doing for now, but this is not a good solution for me : I want to profile sofa simulations (using external profilers such as Gprof), and to do that I need my run to end properly. Here is what I get when using
sys.exit(0)
:[FATAL] [SofaPython] SP_CALL_MODULEFUNC [WARNING] [SofaSimulationGraph] the library has not been cleaned up (sofa::simulation::graph::cleanup() has never been called, see sofa/helper/init.h) [WARNING] [SofaSimulationTree] the library has not been cleaned up (sofa::simulation::tree::cleanup() has never been called, see sofa/helper/init.h) [WARNING] [SofaSimulationCommon] the library has not been cleaned up (sofa::simulation::common::cleanup() has never been called, see sofa/helper/init.h) [WARNING] [SofaSimulationCore] the library has not been cleaned up (sofa::simulation::core::cleanup() has never been called, see sofa/helper/init.h) [WARNING] [SofaCore] the library has not been cleaned up (sofa::core::cleanup() has never been called, see sofa/helper/init.h) [WARNING] [SofaDefaultType] the library has not been cleaned up (sofa::defaulttype::cleanup() has never been called, see sofa/helper/init.h) ########## SIG 11 – SIGSEGV: segfault ########## -> /home/moge/Work/Libraries/sofa/master/build_profiling/lib/libSofaHelper.so.16.dev.0(sofa::helper::BackTrace::dump()+0x2e) [0x7ffb7d3b5c5e] -> /home/moge/Work/Libraries/sofa/master/build_profiling/lib/libSofaHelper.so.16.dev.0(sofa::helper::BackTrace::sig(int)+0x197) [0x7ffb7d3b5fc7] -> /lib/x86_64-linux-gnu/libc.so.6(+0x354a0) [0x7ffb7c7cf4a0] -> /home/moge/Work/Libraries/sofa/master/build_profiling/lib/libSofaHelper.so.16.dev.0(sofa::helper::logging::MessageDispatcher::process(sofa::helper::logging::Message&)+0x46) [0x7ffb7d4861a6] -> /home/moge/Work/Libraries/sofa/master/build_profiling/lib/libSofaHelper.so.16.dev.0(sofa::helper::logging::MessageDispatcher::LoggerStream::~LoggerStream()+0x27) [0x7ffb7d4868a7] -> /home/moge/Work/Libraries/sofa/master/build_profiling/lib/libSofaHelper.so.16.dev.0(sofa::helper::printLibraryNotCleanedUpWarning(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x10d) [0x7ffb7d43b01d] -> /home/moge/Work/Libraries/sofa/master/build_profiling/lib/libSofaHelper.so.16.dev.0(sofa::helper::CleanupCheck::~CleanupCheck()+0xf5) [0x7ffb7d43b2a5] -> /lib/x86_64-linux-gnu/libc.so.6(__cxa_finalize+0x9a) [0x7ffb7c7d435a] -> /home/moge/Work/Libraries/sofa/master/build_profiling/lib/libSofaHelper.so.16.dev.0(+0x5f273) [0x7ffb7d3a2273] Erreur de segmentation (core dumped)
I hoped there was a way to do a clean exit using a sofa function, and I think it would be useful.
Anyway, using the batch mode is more adapted for performance analysis, and I can control the number of iterations easily using the ‘-n” command line argument, so I don’t really need to use the python plugin.Thank you Maxime and Hugo
Maxime
10 February 2017 at 16:40 #8562maxBlockedHello again,
Sorry for misunderstanding your request.
It turns out I have the exact same problem as yours, and a fix is being discussed here.
So you need a little more patience 🙂
Best,
13 February 2017 at 19:26 #8571HugoKeymasterHi Max(s),
The PR #168 has just been merged. Checkout the latest version of SOFA master branch. It should work now. Using
sys.exit(0)
you will get the following exception message from SOFA:[FATAL] [SofaPython] SP_CALL_MODULEFUNC_BOOL
Thank you max !
24 February 2017 at 10:57 #8700HugoKeymasterAny news about it Maxime?
Cheers,Hugo
27 February 2017 at 09:24 #8709mmogeBlockedHi !
Sorry, I forgot to close this topic.
Yes the termination is much cleaner now :
[FATAL] [SofaPython] SP_CALL_MODULEFUNC
Thanks Max & Hugo !Maxime
-
AuthorPosts
- You must be logged in to reply to this topic.