Forum Replies Created
-
AuthorPosts
-
dlouisBlocked
Sorry for the late reply, I was trying other stuff.
CharlieD, can you just launch the file, or can you also click on “animate” in the GUI, without having any problem ?
I can also execute the file with the same info/warnings as you, the problem only appears when I animate.I have python 3.8.10 and SOFA 21.12 binaries, but as stated above, I don’t think it is a problem with my installation since other scenes work.
@Hugo do you have an idea ?dlouisBlockedHello @hugo
Thanks for the reply.
I tried again with SOFA binaries (v 21.12 ) and activated the associated SofaPython3 with the plugin manager, and nothing changes (same error).Anyway, I think this is not a compilation issue, since I can run the examples located in plugins/SofaPython3/share/SofaPython3/examples without any problem (even when I click on animate, which is not the case with the script I showed you above). Hence, I think the problem comes indeed from my script, isn’t it ?
For the rest, I managed with another simple scene to assign position to a point, but I couldn’t try this with my own scene, obviously, since I cannot make it run.
Best
LouisdlouisBlockedHi @Hugo,
Thanks for your help !
Indeed it seems to work, but I need to adapt it to my use case because I want to control the end with the plate, as if the plate was a gripper.But in the meantime, I came across another and (I think) simpler way to do what I want: using beamFEMForceField.
I can run this simple seen, modified from “BeamForceField.scn” (I just removed some lines):
<?xml version="1.0"?> <!-- BeamFEMForceField example --> <Node name="root" dt="0.01"> <RequiredPlugin pluginName="SofaOpenglVisual"/> <RequiredPlugin pluginName='SofaMiscMapping'/> <RequiredPlugin pluginName='SofaGeneralLinearSolver'/> <RequiredPlugin pluginName='SofaGeneralTopology'/> <RequiredPlugin pluginName='SofaImplicitOdeSolver'/> <RequiredPlugin pluginName='SofaGeneralSimpleFem'/> <RequiredPlugin pluginName='SofaBoundaryCondition'/> <RequiredPlugin pluginName='SofaDenseSolver'/> <RequiredPlugin pluginName='SofaMeshCollision'/> <RequiredPlugin pluginName='SofaRigid'/> <RequiredPlugin pluginName='SofaConstraint'/> <RequiredPlugin pluginName='SofaLoader'/> <VisualStyle displayFlags="showBehaviorModels hideForceFields showCollisionModels hideVisual showInteractionForceFields" /> <DefaultPipeline depth="6" verbose="0" draw="0" /> <BruteForceBroadPhase/> <BVHNarrowPhase/> <MinProximityIntersection name="Proximity" alarmDistance="0.3" contactDistance="0.2" /> <DefaultContactManager name="Response" response="default" /> <Node name="beam-withPointCollision"> <EulerImplicitSolver rayleighStiffness="1.0" printLog="false" rayleighMass="0.2" /> <BTDLinearSolver template="BTDMatrix6d" printLog="false" verbose="false" /> <MechanicalObject template="Rigid3d" name="DOFs" position="0 0 0 0 0 0 1 1 0 0 0 0 0 1 2 0 0 0 0 0 1 3 0 0 0 0 0 1 4 0 0 0 0 0 1 5 0 0 0 0 0 1 6 0 0 0 0 0 1 7 0 0 0 0 0 1" /> <MeshTopology name="lines" lines="0 1 1 2 2 3 3 4 4 5 5 6 6 7" /> <FixedConstraint name="FixedConstraint" indices="0" /> <UniformMass vertexMass="1 1 0.01 0 0 0 0.1 0 0 0 0.1" printLog="false" /> <BeamFEMForceField name="FEM" radius="0.1" youngModulus="20000000" poissonRatio="0.49"/> </Node> </Node>
Now, I’d like to do the same with SofaPyton3:
import Sofa # Choose in your script to activate or not the GUI USE_GUI = True def main(): import SofaRuntime import Sofa.Gui SofaRuntime.importPlugin("SofaComponentAll") root = Sofa.Core.Node("root") createScene(root) Sofa.Simulation.init(root) if not USE_GUI: for iteration in range(10): Sofa.Simulation.animate(root, root.dt.value) else: Sofa.Gui.GUIManager.Init("myscene", "qglviewer") Sofa.Gui.GUIManager.createGUI(root, __file__) Sofa.Gui.GUIManager.SetDimension(1080, 1080) Sofa.Gui.GUIManager.MainLoop(root) Sofa.Gui.GUIManager.closeGUI() def createScene(root): root.dt = 0.01 root.name = 'root' root.gravity = [0.0, 0.0, -9.81] root.addObject('DefaultAnimationLoop') root.addObject("EulerImplicitSolver", rayleighStiffness=1.2, rayleighMass= 0.1) root.addObject("CGLinearSolver", tolerance=1e-12, threshold=1e-12, iterations=25) # root.addObject('BTDLinearSolver', template="BTDMatrix6d" , printLog="false" , verbose="false") # root.addObject("SparseLDLSolver") beam = root.addChild('Beam') beam.addObject('MechanicalObject', template="Rigid3d", name="dofs", position = "0 0 0 0 0 0 1 1 0 0 0 0 0 1 2 0 0 0 0 0 1 3 0 0 0 0 0 1 4 0 0 0 0 0 1 5 0 0 0 0 0 1 6 0 0 0 0 0 1 7 0 0 0 0") beam.addObject('MeshTopology', name="lines" , lines="0 1 1 2 2 3 3 4 4 5 5 6 6 7") beam.addObject('FixedConstraint', name="FixedConstraint" , indices="0" ) beam.addObject('BeamFEMForceField', name="FEM", poissonRatio=0.4, youngModulus=100000) beam.addObject('UniformMass', totalMass='1', printLog="False" ) # beam.init() return root if __name__ == '__main__': main()
Using python3 myscript.py , I can load the scene, but as soon as I click “animate”, I obtain the following errors:
--------------------------------------- Checking SOFA_ROOT and SOFAPYTHON3_ROOT Using environment variable SOFA_ROOT: /home/louis/Documents/sofa/build/ Warning: environment variable SOFAPYTHON3_ROOT is empty. Trying to guess it. Guessed SOFAPYTHON3_ROOT: /home/louis/Documents/sofa/build --------------------------------------- [WARNING] [qt.conf.h] Cannot open file /home/louis/Documents/sofa/build/bin/qt.conf [WARNING] [Sofa.Gui] Failed loading and/or customizing qt.conf from /home/louis/Documents/sofa/build/bin/qt.conf qt_resource_data: [INFO] [PluginManager] Loaded plugin: /home/louis/Documents/sofa/build/lib/libSofaComponentAll.so [WARNING] [Simulation] Default Visual Manager Loop will be used. Add DefaultVisualManagerLoop to the root node of scene file to remove this warning [INFO] [TopologyHandler] Topology: lines is not dynamic, topology engine on Data 'indices' won't be registered. [INFO] [TopologyHandler] Topology: lines is not dynamic, topology engine on Data 'beamsData' won't be registered. [WARNING] [SofaEigen2Solver] SofaEigen2Solver is deprecated; Eigen classes are now located in Sofa.LinearAlgebra and SVDLinearSolver in SofaDenseSolver.You can remove SofaEigen2Solver from your scene, and if using SVDLinearSolver, please load SofaDenseSolver instead. The constructor with a QGLFormat is deprecated, use the regular contructor instead. [WARNING] [RealGUI] Global Bounding Box seems very small; Your viewer settings (based on the bbox) are likely invalid, switching to default value of [-1,-1,-1,1,1,1].This is caused by using component which does not implement properly the updateBBox function.You can remove this warning by manually forcing a value in the parameter bbox="minX minY minZ maxX maxY maxZ" in your root node [WARNING] [SofaViewer] Could not create file '/home/louis/Documents/sofa/src/share/textures/SOFA_logo.bmp' Valid extensions: ["dds"] GLib (gthread-posix.c): Unexpected error from C library during 'pthread_setspecific': Invalid argument. Aborting. ########## SIG 6 - SIGABRT: usually caused by an abort() or assert() ########## sofa::helper::BackTrace::sig(int) gsignal abort g_private_set g_thread_self g_main_context_iteration QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) QCoreApplication::exec() sofa::gui::qt::RealGUI::mainLoop() sofa::gui::GUIManager::MainLoop(boost::intrusive_ptr<sofa::simulation::Node>, char const*) PyCFunction_Call _PyObject_MakeTpCall _PyEval_EvalFrameDefault _PyFunction_Vectorcall _PyEval_EvalFrameDefault _PyEval_EvalCodeWithName PyEval_EvalCode PyRun_SimpleFileExFlags Py_RunMain Py_BytesMain __libc_start_main _start Aborted (core dumped)
Would you have an idea how to translate the .scn scene into a .py correctly please?
Also, once this will work, I would like to replace the line
beam.addObject('FixedConstraint', name="FixedConstraint" , indices="0" )
by a position and orientation assigned “dynamically ” to this same node (with indice “0”) at each time step. What is the best way ?Lastly, how can I “read” the position and orientation of the last node (the 7th one) ?
Thanks for the support!
dlouisBlockedHello @hugo,
Are you still doing these meetings twice a month ? Is there a schedule with all the dates somewhere?6 December 2021 at 18:23 in reply to: ModuleNotFoundError … ‘Sofa.Helper’ with Binary install v21.06.02 #21067dlouisBlockedThanks for the answers,
Yes I noticed this was the problem. If I compile myself V21.06, it works with my python 3.8 installation and I get no errors. Unfortunately, to use the binaries (for instance I want to use the DEFROST binaries V19.06), it is not possible to install python 3.7 on ubuntu 20.04 LTS using
sudo apt install python3-dev
. Ubuntu 20.04 allows only versions starting from python 3.8 as far as I know.To solve this, I tried using anaconda, but then other problems arose. For instance, I get the errors “no module named numpy” even if numpy is installed in my envrionment, and others like “no module named SofaRuntime.SofaRuntime”. Such errors do not arise outside anaconda. Could you please help me to set up an anaconda env properly to use Sofa ? I feel it’s the easiest way to use different versions of the software.
Louis
3 December 2021 at 15:28 in reply to: ModuleNotFoundError … ‘Sofa.Helper’ with Binary install v21.06.02 #21056 -
AuthorPosts