Forum Replies Created
-
AuthorPosts
-
jnbrunetModerator
Hey Alex,
What version of Qt are you using?
Also, can you try with both viewer to see if they both have a black output?
QtViewer:
runSofa -g qtviewer
QglViewer:
runSofa -g qglviewer
jnbrunetModeratorHey @ztjsofa
On macos with Qt5 installed using the Qt installer in $HOME/Qt/5.15.2, I usually build SOFA using:
git clone https://github.com/sofa-framework/sofa.git cmake -S sofa -B sofa/build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DQt5_DIR=$HOME/Qt/5.15.2/clang_64/lib/cmake/Qt5 cmake --build sofa/build cmake --install sofa/build
You will have to change
$HOME/Qt/5.15.2
for your Qt path. I have not tested it with Qt6, but Qt5 works.JN
jnbrunetModeratorHey @ateixeira
Following caribou documentation, let
SOFA_ROOT
be the env variable pointing to your SOFA build installation path (usually$SOFA_BUILD/install
).Can you try adding the following additional environment path before starting python:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SOFA_ROOT/lib python >>> import Sofa >>> import SofaRuntime >>> import Caribou >>> import SofaCaribou
I think the documentation is a bit outdated since this was not required before. Let me know if it work, I will update the doc.
J-N
jnbrunetModeratorHey @Hugo and @Jan,
Yes, sorry for the late reply rate. I have some time issues these days, but who doesn’t right? ^^
I’ve created an issue here to follow the development. It is on my top priority for caribou, I hope I’ll find some time in the next 2 weeks to look at it. But if someone wants to tackle it (could be a good opportunity to learn about the constraint solving and matrix assembly process in SOFA), that would be awesome. I will of course offer my full support.
J-N
jnbrunetModeratorHey Jan,
Could you try replacing the
BackwardEulerODESolver
of Caribou by aEulerImplicitSolver
of SOFA, but keep theLDLTSolver
solver of Caribou. Does it work? If not, can you replace theLDLTSolver
of Caribou with theSparseLDLSolver
of SOFA. Does it work now?I’m just trying to determine which component of Caribou makes it fail. This will help me debug the issue.
J-N
jnbrunetModeratorHey @anthony,
Unfortunately, I haven’t come up with a solution yet. I also tried @froy ‘s suggestion without success. I’m failing to see where the issue is coming from…
I’m running a bit low on time these days. You could try Arthur’s solution (using SOFA’s GUI screenshot functionality). Or, if you got some c++ knowledge, try to debug the SofaOffscreenCamera plugin, that would be of great help.
I’ll keep you updated if I find something.
J-N
jnbrunetModeratorHey @arsalan,
PythonScriptController is a SofaPython(2) component, it doesn’t exists in the python 3 plugin.
To use a controller in SofaPython3, have a look at some of the example scenes.
J-N
jnbrunetModeratorHey Chiara
That’s because your
StiffSpringForceField
must be on the same level as the mechanical object that receives the forces (ie the skin). In your case, you added it inside the root node. Something like this should work :def Skin(parentNode=None, name=None, rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0], scale3d=[0.0, 0.0, 0.0], fixingBox=[0.0, 0.0, 0.0], importFile=None): # (...) # Data Skin.node = name # (...) # (...) # Controller class SutureTrainingContactController(Sofa.Core.Controller): def __init__(self, name, rootNode): Sofa.Core.Controller.__init__(self, name, rootNode) # Define spring force field (Skin-Needle) self.spring_force_field = Skin.node.addObject("StiffSpringForceField", name="LeftFF", object1 = Skin.MO, object2=SutureNeedle.COLL_BACK_MO) # (...)
Also, you will probably need to drop down a bit the stiffness on those springs when you test this out 😉
J-N
jnbrunetModeratorThat’s probably because VTK/VTU loader/exporter in SOFA haven’t been updated for a while. That’s why I suggest loading/exporting your meshes using an external tool such as
meshio
and fill-up the loaded vertex positions and indices directly into SOFA’s data field in python.jnbrunetModeratorHey Serkan,
Indeed, as you said in your edit, you just need to translate the content of “HexahedronSetTopology.xml” into python commands. Just for future readers that would come by this topic, what Serkan here found out is that the following xml lines:
<RegularGridTopology name="grid" min="0 0 0" max="5 5 20" n="5 5 20"/> <include href="Objects/HexahedronSetTopology.xml" src="@../grid" drawHexa="1" />
is basically equivalent to
<RegularGridTopology name="grid" min="0 0 0" max="5 5 20" n="5 5 20" /> <Node name="Group"> <HexahedronSetTopologyContainer name="Container" src="@../grid" tags=" " /> <HexahedronSetTopologyModifier name="Modifier" /> <HexahedronSetGeometryAlgorithms name="GeomAlgo" template="Vec3d" /> </Node>
and would become the following in python:
root.addObject('RegularGridTopology', name='grid', min=[-7.5, -7.5, 0], max=[7.5, 7.5, 80], n=[9, 9, 21]) root.addObject('HexahedronSetTopologyContainer', name='Container', src='@grid') root.addObject('HexahedronSetTopologyModifier', name='Modifier') root.addObject('HexahedronSetGeometryAlgorithms', name='GeomAlgo', template='Vec3d')
J-N
jnbrunetModeratorHi,
Are you using python scene? If so, you can use meshio to import meshes. For example:
import meshio mesh = meshio.read('/path/to/mesh.vtu') def createScene(root): root.addObject('MechanicalObject', position=mesh.points.tolist()) root.addObject('TetrahedronSetTopologyContainer', name='topology', tetrahedra=mesh.cells_dict['tetra'].tolist()) # (...)
You can read more about using python with SOFA here.
J-N
jnbrunetModeratorjnbrunetModeratorHey Jan,
Are you really converging? Note that the EulerImplicitSolver is a linear ODE solver, i.e. it is only doing one Newton iteration. It is quite possible that you would need a lot more than this to really converge. Stiffer material are harder to converge. Finally, linear elements (tetrahedral) might not be adequate here, especially if your material is close to incompressible.
You can check out the Caribou plugin, which offers an Euler implicit solver compatible with non-linear materials, and also quadratic tetrahedral elements.
J-N
jnbrunetModeratorHey Anthony,
I’m sorry for the delay, I did not find the source of the problem yet, and I’m running a little bit low on time this week. I reduced your example to a very minimal scene:
import Sofa def createScene(rootNode): rootNode.addObject('RequiredPlugin', pluginName='SofaPython3 SofaOpenglVisual SofaLoader SofaOffscreenCamera') rootNode.addObject('MeshSTLLoader', filename='Ellipse_cylinder_tas.stl', name="loader") rootNode.addObject('OglModel', src="@loader", color=[1, 0, 0, 1]) rootNode.addObject('OffscreenCamera', name='camera_offscreen', filepath='%s_%i.png', widthViewport=3840, heightViewport=2160, save_frame_before_first_step=True, save_frame_after_each_n_steps=1, position=[123, 21, 101], orientation=[-0.0980628, 0.535538, -0.0488142, 0.837377], distance=151)
I will try to debug this further in the next couple of days.
@froy : do you have something OpenGL related that pops into your head when you see these two images:Expected result:
Actual result:
Jean-Nicolas
14 July 2021 at 15:26 in reply to: [SOLVED] Accessing deformations, force states, etc using Python #20028jnbrunetModeratorHey Serkan,
You can easily get the displacement of a mesh using the SofaPython3 plugin. Here’s a quick example of a cantilever bending simulation where the mesh is exported in a vtu file alongside its current displacement and nodal Von mises stress.
https://gist.github.com/jnbrunet/79a3a9d493d2dc4458433356bc037e04
To visualize the meshes, you can open up an exported mesh file in Paraview and add the “Wrap by vector” filter (using the “u” data field) to visualize the displacement, and color the wrapped result using the “von_mises” data field.
Let me know if you run into some issues.
Jean-Nicolas13 July 2021 at 14:58 in reply to: [SOLVED] Accessing deformations, force states, etc using Python #20019jnbrunetModeratorHey Serkan,
What data are you looking to extract from your scene? And what forcefield are you using?
Not all data are accessible from within python (and even c++), it really depends on which components your are using in your scene and if these were made to easily export such data.
Jean-Nicolas
jnbrunetModeratorHey Jan,
Are you using a very fine mesh and/or large time steps?
NeoHookean materials cannot handle element inversions (unless some very specific numerical schemes are set up, which SOFA doesn’t have). If you are using large time steps or a very fine mesh, the solver could find an intermediate solution where one or more elements are inverted. This is because there are no hard constraints (i.e. degrees of freedom) that prevent element inversions. The simulation then crashes.
You could try to reduce the size of the time steps, or use a coarser mesh, or both, and see if it improves.
Jean-Nicolas
jnbrunetModeratorHum I tried to run your scene but I’m not sure what point of view you need for the offscreen camera. Can you launch your scene with
runSofa -g qt
(using theqt
GUI of SOFA), then position your view to the one you want for the offscreen camera, and hit the “Save View” button. This will save a “Ellipse_axial_load (1).pyscn.view” file.Can you paste here:
1. This Ellipse_axial_load (1).pyscn.view file
2. A screenshot of this point of view (simple screen shot of SOFA’s GUI with the good positionjnbrunetModeratorHum I’m not sure what’s going on by looking at your mp4. Can you share the mesh files so that I try it?
7 July 2021 at 19:40 in reply to: [SOLVED] Issue with the update of the stiffness variable in StiffSpringFF #19987jnbrunetModeratorAwesome, thanks for your feedback Benjamin. I’ll mark this topic as resolved then.
jnbrunetModerator29 June 2021 at 18:49 in reply to: [SOLVED] Questions regarding the installation of SofaPython3 plugin #19899jnbrunetModeratorHey xiaochaosui,
Could you create your own forum discussion with your issue since it doesn’t look related to the initial issue?
I will mark this thread as solved since I think @mdubied successfully made it work.
Thanks a lot
jnbrunetModeratorHey xiaochaosui
Could you tell us which version of SOFA you are compiling? If you got the source code from git, you can also tell us the git commit hash with:
$ cd $SOFA_SRC $ git rev-parse --short HEAD
29 June 2021 at 18:21 in reply to: During installation of sofa in Cmke-gui I have got following Configuration error #19897jnbrunetModeratorHey Jake,
Did you correctly installed the Windows’s dependencies ? Especially the part Windows dependency pack in the Additional libraries part:
Note that you need to unzip this archive into the source directory of SOFA, as stated in the Setup your source and build directories sub section:
Let us know if that helped.
29 June 2021 at 17:20 in reply to: [SOLVED] Determining if the include file pthread.h exists failed #19895jnbrunetModeratorHey @matscisteph
I’m not on Windows unfortunately so I cannot test it, but could you try to replace the following lines in the file
sofa\src\applications\plugins\SensableEmulation\CMakeLists.txt
:set(SOURCE_FILES OmniDriverEmu.cpp initSensableEmulation.cpp )
with
set(SOURCE_FILES OmniDriverEmu.cpp initSensableEmulation.cpp ) if(MSVC) list(APPEND SOURCE_FILES "pthread/pthread.h") endif()
-
AuthorPosts