Home › Forum › SOFA › Programming with SOFA › [SOLVED] ERROR in Simulation::animate() while testing
Tagged: 64_bits, Linux_ubuntu, SOFA_1706, test animate
- This topic has 7 replies, 2 voices, and was last updated 6 years, 9 months ago by ErwanDouaille.
-
AuthorPosts
-
17 October 2017 at 12:16 #10077ErwanDouailleBlocked
Hey,
I’m writing test but i had an error. Here is my source :
std::stringstream scene1 ; scene1 << "<?xml version='1.0' ?> \n" "<Node name='Root' gravity='0 0 0' time='0' animate='0' > \n" " <MyComponent name='aComponent' /> \n" "</Node> \n"; Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene", scene1.str().c_str(), scene1.str().size()) ; root->init(ExecParams::defaultInstance()) ; for(unsigned int i=0; i<100; i++) { sofa::simulation::getSimulation()->animate(root.get(), 0.01); }
The result of running it is a warning error :
`[WARNING] [DAGSimulation(Simulation)] ERROR in Simulation::animate(): AnimationLoop expected at the root node’Did I forget something ? My root scene isn’t correct ?
Thanks for helping 😉
19 February 2018 at 11:27 #10547ErwanDouailleBlockedup.
I need help 🙂19 February 2018 at 11:50 #10548GuillaumeKeymasterWoaw this has been pending for a way too long time!
I’m on it!Did you try to reproduce the problem with latest SOFA?
Cheers,
Guillaume.19 February 2018 at 13:40 #10549ErwanDouailleBlockedI’m using a recent one maybe not the latest version (2/3 weeks old).
Here is the source code I’m using :std::stringstream scene1 ; scene1 << "<?xml version='1.0' ?> \n" "<Node name='root'> \n" " <RequiredPlugin name='Communication' /> \n" " <ServerCommunicationZMQ name='zmqSender' job='sender' port='6000' refreshRate='1000'/> \n" " <CommunicationSubscriber name='sub1' communication='@zmqSender' subject='/test' source='@zmqSender' arguments='x'/>" "</Node> \n"; Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene", scene1.str().c_str(), scene1.str().size()) ; root->init(ExecParams::defaultInstance()); for(unsigned int i=0; i<100; i++) { sofa::simulation::getSimulation()->animate(root.get(), 0.01); }
And here is the result :
[ RUN ] Communication_testZMQ.checkArgumentCreation
[INFO] [PluginManager] Loaded plugin: /home/douaille/SOFA/build-communication-Desktop_Qt_5_9_2_GCC_64bit-Debug/lib/libCommunication_d.so
[WARNING] [DAGSimulation(Simulation)] ERROR in Simulation::animate(): AnimationLoop expected at the root node
[WARNING] [DAGSimulation(Simulation)] ERROR in Simulation::animate(): AnimationLoop expected at the root node*100 didn’t copy everything.
Am I doing something wrong ?
19 February 2018 at 16:20 #10550GuillaumeKeymasterOk I searched for all
sofa::simulation::getSimulation()->animate
calls in tests and it seems thatSceneLoaderXML::loadFromMemory
does not have any default component creation behavior.Solution 1: simply add a
<DefaultAnimationLoop/>
in your graph.
Solution 2: use another scene loading method to profit from default component creation. Using a file and loading it withsofa::simulation::getSimulation()->load
does the trick.
Solution 3: implement default component creation inSceneLoaderXML::loadFromMemory
.Hope that helps,
Guillaume.20 February 2018 at 13:19 #10551ErwanDouailleBlockedI tested the solution 1 and it works like a charm !
As I understood,
sofa::simulation::getSimulation()->animate(root.get(), 0.01);
may works correctly. But something is not well initialize, right ?
Just trying to understand what is wrong with the animate call.
I will add the solved flag since it works.Thanks !
20 February 2018 at 14:25 #10552GuillaumeKeymasterWhat happens is that
sofa::simulation::getSimulation()->animate
needs an AnimationLoop as you can see here.
Usually with XML scenes, a DefaultAnimationLoop (and other components) is added to the simulation if none found. This is not the case when usingSceneLoaderXML::loadFromMemory
.Guillaume.
20 February 2018 at 14:32 #10553ErwanDouailleBlockedThanks for the explanation.
-
AuthorPosts
- You must be logged in to reply to this topic.