Forum Replies Created
-
AuthorPosts
-
9 December 2021 at 07:49 in reply to: [SOLVED] VS code SofaRuntime.importPlugin cannot be resolved #21093psomersBlocked
I think this will be a very difficult task because any SOFA plugin libraries are loaded at the C++ level, so python and any IDEs would have a hard time knowing what components would become available before runtime. Maybe it’d be possible to hide the importPlugin call to a python wrapping of individual plugins that contain explicit pybinding files. Then a user could just call something like “import SofaComponentAll” at the top of a python script… Would be cool. Honestly sounds like a lot of upkeep work though. 🙁
6 December 2021 at 10:38 in reply to: ModuleNotFoundError … ‘Sofa.Helper’ with Binary install v21.06.02 #21058psomersBlockedI believe the downloadable Sofa binaries are compiled for python 3.7. So if you just downloaded them, that could be the problem.
psomersBlockedHi @Hugo,
I think the problem only occurs when using the Sofa.GL python bindings (not through runSofa). But I am very curious as to how this Blender tutorial will work. Will it retain standalone SOFA in python capabilities or will it need to be used with runSofa?
Thanks,
Peter
psomersBlockedI don’t think the problem here is how to get a hexahedral mesh. I think the end goal is to have a voxelized cube “image” of the simulation environment as if it was a MRI image, correct? In that case, maybe take a look at this project:
or this one
They may do something similar.
As a side note: I apologize if my answer pops up twice. That seems to happen a lot when I post a link here.psomersBlockedHave you been able to run the Python3 GUI examples? For example, the pygame one:
https://github.com/sofa-framework/SofaPython3/blob/master/examples/additional-examples/pygame_example.pypsomersBlockedI personally use pyqt for viewing and have written things to control the camera with the keyboard (so you can look around). If that is something you want to try, here is an example:
https://github.com/psomers3/QSofaGLViewTools/blob/main/examples/example1.pypsomersBlockedI’m pretty sure your camera just isn’t pointing in the right direction. I’m not sure what your model is, so I can’t say what numbers to use, but try setting the the position and lookAt values for the camera such that it is outside your model, but pointing at it. Check the pygame example from the link I shared and see how it is done for the “InteractiveCamera” there.
Unfortunately, if there is a way to get Sofa to automatically best place the camera, I don’t know what it is.psomersBlockedI’m not sure which example you’re following, but what I said still stands as it makes no sense to create a new camera everytime the scene is drawn. Have you tried it?
If you’re not getting errors and just a black screen, I assume the code is rendering a camera view that isn’t pointing at your model.Try moving the addObject(“Camera”…) line to your createScene function.
psomersBlockedyou are adding a new camera to your scene everytime simple_render is called and then using it without initializing it. This is likely your problem 😉
To clarify – you should add the camera where you create your scene. Then it will be initialized when you initialize everything else.
psomersBlockedHave you been able to run the GUI examples in SofaPython3?
https://github.com/sofa-framework/SofaPython3/blob/master/examples/additional-examplespsomersBlockedI think you’ll need to update to the latest master branch version of Sofa so that you can use the version of SofaPython3 that has Sofa.GL. And then you will likely run into the problem that SoftRobotics is not quite updated to work with these versions yet… It is just a guess, but I think you may need to wait a bit before a python GUI will work for the SoftRobotics package.
psomersBlockedHi Eleonora,
I think this is what you could be looking for. I use it to do exactly what you‘re describing.
Cheers,
PeterpsomersBlockedThanks Hugo,
May be worth throwing here that a fix has been added to SofaPython3 for this.
https://github.com/sofa-framework/SofaPython3/pull/109So definitely a closed issue.
Cheers,
PeterpsomersBlockedI haven’t used github discussions before, but the ability to flag helpful comments/discussions with upvoting sounds like 2021 😉
And I know it doesn’t affect me at all, but I can imagine not having to worry about supporting a forum’s mechanics would probably be nice for all of you focusing on Sofa development…+1 for moving to github
5 February 2021 at 12:30 in reply to: [SOLVED] SofaPython3 pygame rendering example not working #18535psomersBlockedHey @jnbrunet
Thanks for clearing this up. For the convenience of those that find this thread and want to do their own hack before someone adds proper bindings, here is what I did:
in SofaPython3\bindings\Sofa\src\SofaPython3\Sofa\Simulation\Submodule_Simulation.cpp add
#ifndef SOFA_NO_OPENGL #include <sofa/gl/DrawToolGL.h> #endif
and
#ifndef SOFA_NO_OPENGL simulation.def("draw", [](Node* n){ auto* vparam = sofa::core::visual::VisualParams::defaultInstance(); vparam->drawTool() = new sofa::gl::DrawToolGL(); vparam->setSupported(sofa::core::visual::API_OpenGL); sofa::simulation::getSimulation()->draw(vparam, n); }); simulation.def("glewInit", []() { glewInit(); }); #endif
in SofaPython3\bindings\Sofa\src\SofaPython3\Sofa\Simulation\CMakeLists.txt add
find_package(Sofa.GL REQUIRED) # in the SP3_add_python_module call: DEPENDS SofaCore SofaSimulationCore SofaSimulationGraph SofaPython3::Plugin Sofa.GL
psomersBlockedHi Sofa team,
I saw that the python3 bindings for implementing the pygame example mentioned in this thread were removed shortly after the conversation here took place (glewinit() and draw()). Is there a plan to re-implement them or replace them? Or maybe I’m missing the replacement. Since Sofa can be driven entirely from a python environment, it is pretty handy to be able to implement a simplified viewer without handing over the main thread. I’ve added back in the bindings in my copy of sofa and it’s pretty easy to have a nice gui using pyqt and python debugging capabilities aren’t lost.
I guess I’m asking more out of curiosity than need at the moment.
Keep up the good work!
Cheers,
Peter
-
AuthorPosts