Forum Replies Created
-
AuthorPosts
-
YannieBlocked
Thanks Hugo, I looked into the code, it seems I have to write things in code, I can’t achieve it by just writing the scene file.
YannieBlocked*Could you let me know or message me?*,Sorry for the typo
YannieBlockedThanks, I can’t find where to private message you, could like me know or message me?
YannieBlockedThanks Hugo for the reply. Yes, I’m interested to use it for research. Please let me know how to proceed to get access.
YannieBlockedThanks Hugo!
I did use the PluginManager to load the SofaPython as well as adding RequiredPlugin node, not sure why it didn’t call loadscript with that setting.
Thanks, the FreeMotionAnimationLoop does help, now I can move object around!
Best,
YannieYannieBlockedThanks Hugo,
Well, I debugged for some time and found that the PythonScripController.cpp constructor doesn’t call loadscript(), so I write add a new constructor and rebuilt sofaPython and it worked. I seems that the PythonScripController was written for use cases that read scene files instead of constructor the object in code, because it does work if I just load the .scn file for runsofa. I could be wrong as I don’t know the platform well enough. Does it work for you if you just assign filename and classname?
Additional question. So I tried the keyboardcontrol.py again, but my object doesn’t move and the error is mechanicalState.free_position index out range. And I print out free_position, it is empty, when and where this free_position is initiated?
Thanks again!
YannieYannieBlockedThe script I posted above is the whole script. For this script, I didn’t add m_classname as there is no class name in it.
I also tried the PythonScriptController_Placeholders.py in the sofaPython examples folder and set the m_classname to ExampleController, same problem!
Thanks!
YannieBlockedThanks Hugo!
I’ve play around a bit, it still has this problem, I’m able to locate where the error come but not sure how to solve it. So the code run into the python error at this line:sofa::simulation::getSimulation()->init(groot.get());
And I can trace it to PythonScriptController::script_initGraph(Node *node), it gave the exception at here.
Does it has something to do with the m_classname? I assume it should be the classname in Python script. Then I tried to just type some simple code in python, like
def createScene(node): def hello(): print 'hello !'
But still, no luck.
Any thoughts? Thanks!YannieBlockedThanks Hugo for the reply.
I did add sofaPython plugin. But it always gives the above error. It looks the the pythonscriptcontroller instance can’t read in the .py file.
Here is my code:
const char* filename = “keyboardControl.py”; sofa::component::controller::PythonScriptController::SPtr pyContr = sofa::core::objectmodel::New<sofa::component::controller::PythonScriptController>(); pyContr->m_filename.setValue(filename);
I suppose the class can parse the .py file automatically once it read in?
YannieBlockedThanks jnbrunet for the help! It worked!
-
AuthorPosts