Forum Replies Created
-
AuthorPosts
-
Damien MarchalBlocked
Hi MA,
Clearly SOFA is not dedicated to fabric simulation, it is a general purpose modeling and simulation framework for deformable object.
The problem with modelling is that you need to know what is the dynamic behavior you want to simulate to select the most appropriate mechanial model. If the dynamic behavior can be approximated well enough with kind of 2D mass-spring system or 2D shell assemblies you have existing components for that. If you need something else you may need to implement it. A lot of people are doing that but sadely they don’t put the results in open-source…so to bad for us. Now, as long as you have the equations there is no problem in implementing a specific fabric/yarn oriented model in SOFA allowing it to interact with the other simulated object. If you need help on that I think there is some people that can guide you.
Regards,
Damien MarchalBlockedHi all,
There is also a plugin called SofaEulerianFluid 2D & 3D.
I’m not sure it is very active yet but if you try it please tell us and in all case it is probably a good starting point for fluid simulation.Damien MarchalBlockedHi @nicklj,
Sorry to reply late.
My first guess with the failure to import SofaPython is that it may be because you specify the -DCMAKE_INSTALL_PREFIX=/home/liuj/opt/SOFA/master. I’m not sure to understand why you are specifying it. But this is supposed to be the location where sofa is installed and not the path to the source code.
The need for the workaround by setting manually the python path indicates somethings goes wrong at this step.
Now about the failure in STLIB. This is interesting and many thanks for the report.
This correspond to the lines:
@staticmethod
def createPrefab(self,…
Which up to my knowledge is fully valid python code. I will try to reproduce the lines you gave to see what happens on my system.EDIT: I opened an issue for that in https://github.com/SofaDefrost/STLIB/issues/29
Damien MarchalBlockedHi,
If you use sofa-spm it will generate the CMakeLists.txt for you 🙂
Here is a cut & past from one of my CMakeLists.txt:
sofa_add_plugin(SofaPython3 SofaPython3) sofa_add_plugin(STLIB STLIB) sofa_add_plugin(SoftRobots SoftRobots) sofa_add_plugin(SoftRobots.Inverse SoftRobots.Inverse) sofa_add_plugin(SofaQtQuick SofaQtQuick)
Then I add the directory that contains this CMakeLists.txt in the EXTERNAL_DIRECTORIES at the configuration to compile Sofa.
Damien MarchalBlockedHi all,
I tend to be rather busy so forgot to reply immediately so thank for the poke,
About STLIB, Thank for the poke, STLIB is an external plugin available at
https://github.com/SofaDefrost/STLIBIt should be installed in the same way as you did for SoftRobots.
To ease installation of plugins with dependencies recommand the use of sofa-spm which will track the dependencies for you.
Documentation is here:
https://github.com/SofaDefrost/SPMDamien MarchalBlockedHi MA,
About mesh generation, CGAL is rather hard to use.
If you prefer it is possible to rely on GMESH for meshing.
Stefan Escaida and I made helping function for that STLIB/SoftRobots plugins.It is undocumented feature in:
https://github.com/SofaDefrost/STLIB/tree/master/python/splib/geometricBut there is “createScene” function that will behave as an example if the .py files are loaded in Sofa.
If you need more help please tell.
Damien MarchalBlockedHello,
I’m glad to hear about people trying the SoftRobot plugins.
My first advice is that if you don’t need to compile your self the plugin we are now providing binary version of Sofa+SoftRobot+SoftRobots.Inverse+STLIB. They are available at: https://project.inria.fr/softrobot/install-get-started-2/download/But if these version are not recent or complete enough for your needs and you require to compile everything yourself it seems to me that the problem is somewhere in the build process.
With Sofa there is two build process for plugins, one is “in-tree” and the other is “out-of -tree”. The in-tree build requires you to compile the plugin at the same time as Sofa, for that you need to register the plugin in the Sofa’s cmake configuration.
The other, the ‘out-of-tree’, allows you to compile Sofa (or take a compiled version of it) and apply cmake to the plugin only. For this process to work you need to specify where Sofa is.
I’m not sure but it seems to me you are using an out-of-tree build (can you confirm ?). Out of tree are a rather new way to handle compilation and there may still have bug.
In all cases you should see the following when starting Sofa:
[INFO] [SofaPython] Added '/home/dmarchal/projects/DEFROST/dev/sofa3/src/applications/plugins/SofaTest/python' to sys.path [INFO] [SofaPython] Added '/home/dmarchal/projects/DEFROST/dev/sofa3/plugins/STLIB/python' to sys.path [INFO] [SofaPython] Added '/home/dmarchal/projects/DEFROST/dev/sofa3/src/applications/plugins/SofaPython/python' to sys.path [INFO] [PluginManager] Loaded plugin: /home/dmarchal/projects/DEFROST/dev/sofa3/builds/release/lib/libSofaPython.so
The important lines is the registration of the python path by the different plugins. In your case this is was is missing in the reports you are making. But it is unclear to me why they are missing.
Damien MarchalBlockedHi Binesh,
Thanks a lot for the video you made. It is very helpful to anyone.
Damien.
4 March 2019 at 10:13 in reply to: How to constraint objects inside a closed mesh without using collision models? #13143Damien MarchalBlockedHi Wong,
I’m not surprised there is a lot of bug in the DistanceField plugins because it is not often used. As SOFA is developed by volunteers if you know c++ and have the willing you are welcome to submit patches fixing things (https://github.com/sofa-framework/sofa/pulls), and we would be pleased to help you if needed. If you are not a c++ programmer it would be very helpful if you could open “issues” in our issues tracker so we can keep track on what is wrong and what to fix (when we have time). The issue tracker is there: https://github.com/sofa-framework/sofa/issues
Now about the last question regarding the TetrahedronFEMFOrceField vs HexahedronFEMforceField. If the component does not support TetrahedronFEMFOrceFied it shouldn’t be too hard to implement such behavior.
I have not looked at the code but I thinks that the only requirement is the ability to create a map function transfromating the un-deformed space to the deformed one. HexaderonFEMFF have trilinear interpolation for that…while Tetrahedron have their Bacyentric coordinates. So my suggestion is that if this is important to you I’m sure there is people that would be willing to help you to implement that if you ask for help on github.
Damien.
3 March 2019 at 08:08 in reply to: How to constraint objects inside a closed mesh without using collision models? #13138Damien MarchalBlockedHello Wong,
Did you made some progress on that topic ?
22 February 2019 at 14:55 in reply to: How to constraint objects inside a closed mesh without using collision models? #13105Damien MarchalBlockedHi Wong,
You can have Distance Field collisions by activating the SofaDistanceGrid plugin.
I don’t know if this plugin is available in the binary release of Sofa; If this is not the case you will need to re-compile Sofa by activating the plugin in the cmake build process.When the plugin is on you will be able to execute the example that is in applications/plugins/SofaDistanceGrid/examples/FFDDistanceGridCollisionModel.scn
This example illustrate the use of the FFDDistanceGridCollisionModel component.
This component allows to do collision with Distance Field (a function that returns <0 if inside, 0 on the boundary and 1 outside) or a DistanceGrid (a discreet grid storing a sampled Distance Field). In the example the DistanceGrid can be deformed using a FFD while a second object (a tissue) is interacting with it.
Additional details:
– the distance grid is generated by the FFDDistanceGridCollisionModel at startup from a triangle mesh but we also have an external tool to generate it.– depending on the complexity of the shape you need to represent you may need to increase the grid resolution (thus consuming a lot more memory).
– in your case you will need to flip the sign of the distance field as you want to “free space” to be the “inside” part. I’m not sure but this can probably be done by flipping the normals of the source mesh.
Hope this helps you.
Damien MarchalBlockedHi Fatima,
I just looked at and TetrahedronFEMForceField does not expose the stiffnessMatrix so it is not surprising it does not work.
Adding a new Data to a component is not hard, assuming you know c++ and that the data you want to expose is available in the component. I don’t know for TetrahedronFEMFOrceField so I advice you to open an issue on that topic on github: https://github.com/sofa-framework/sofa/issues
This is where the Sofa developers are.
Damien.
Damien MarchalBlockedHi all,
To have the graphical user interface it is important to compile sofa with Qt5. It may happens that, depending on how it is installed on your systems, it is not detected.
In that case I know two options:
The first one is to stop using cmake but instead use qtcreator (you need a recent version of it) to load the CMakeLists.txt, in that case it will correctly provide the Qt5 installation packages.
The second one is to manually specify to cmake where Qt5 is install on your system as said in this part of the doc: https://www.sofa-framework.org/community/doc/getting-started/build/linux/#qt-detection-errors
It is possible to do that either with cmake-gui or on the cmake command line
like that:cmake ../sofa -G Ninja -DCMAKE_PREFIX_PATH=/opt/Qt/5.12.0/gcc_64/lib/cmake/Qt5
(replacing /opt/Qt/5.12.0/gcc_64/lib/cmake/Qt5 with your own install path)
Hope this will work for you and thanks for the idea of making video tutorial on the build process…any volunteer ?
Damien MarchalBlockedHello,
There is two issues… The first problem I see is that the build system still don’t find Qt5. This is why it is written
SoftRobots: Using Qt4 for some controllers
which appears when Qt5 is not found. I think it is much better to make it compile with Qt5.For the other error. Are you restarting the script in an non-empty directory (with already sofa/plugins directories ?) If this is the case this may be the problem.
Between the two scripts the difference is that I don’t use the same git branches/repository and if something fail the directory may be in an inconsistent state.
So could you try to run the scripts from a fresh directory and after adding the CMAKE_PREFIX_PATH=/YOURQT5PATH as I said in my previous post ?
19 February 2019 at 19:45 in reply to: [SOLVED] How do i a map an omni button to a python function #13084Damien MarchalBlockedIf you think that shorter is better you can also write:
state_button1 = your_GeomagicDriver.button_1
This works because the python binding search for each “MyComponent.xxxx” if there is a data with the xxxx name.
19 February 2019 at 19:40 in reply to: How to constraint objects inside a closed mesh without using collision models? #13083Damien MarchalBlockedHi outtt,
I remember that, few years ago, some have implemented collisions based on distance field representation to simulate a catheter moving into blood vessels while the vessels moving to follow heart movement. The advantage of this distance field approach was excellent performances of the collision pipeline even with a very big blood vessel model.
If you think this use case is close enough to you I can provide more details about that (but I need to refresh my memory on which distance field collision are available in the open-source of Sofa).
Damien MarchalBlockedTo Shiva,
From your logs your problem seems rather different so to me you need to continue the compilation process by typing ninja or Make as said in the guidlines: https://www.sofa-framework.org/community/doc/getting-started/build/linux/
In case this is still not working and you need more help can you please open a new issue of your own so it is easier to manage.To csullivan07,
Don’t worry, from your logs it seems that cmake does not find your Qt5 installation. The solution to this problem different depending on how Qt5 is installed on your system. In the following I will assume that you made a manual install of Qt5 from the Qt website.On my system having manually installed qt resulted in having Qt installed at the following location: /opt/Qt/5.12.0/
So I need to specify this location to cmake I need to change the two following lines
cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins -DPLUGIN_STLIB=1 -DPLUGIN_SOFTROBOTS=1
To add options to force qt location like that:
cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins -DCMAKE_PREFIX_PATH=/opt/Qt/5.12.0/gcc_64/lib/cmake/Qt5 cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins -DCMAKE_PREFIX_PATH=/opt/Qt/5.12.0/gcc_64/lib/cmake/Qt5 -DPLUGIN_STLIB=1 -DPLUGIN_SOFTROBOTS=1
There is other alternatives to fix this issues in the section
“Qt detection error” of the compilation guidelines https://www.sofa-framework.org/community/doc/getting-started/build/linux/#qt-detection-errorsDamien,
Damien MarchalBlockedHi,
I don’t know which forcefield you are using but if the stiffness matrix of the force field you are using is exposed as a Data then yes it can be accessed at each time step using a PythonScriptController.
Eg taken from the previous python script controller
def onBeginAnimationStep(self, dt): '''This method is called automatically by Sofa at each timestep''' # Print the "position" Data field of the 'dofs' object. print(self.dofs.position) # Assuming there is a forcefield with a stiffness matrix exposed as Data named 'stiffnessMatrix' print(self.forcefield.stifnessMatrix)
Now if the forcefield you are using does not have such data field…then you may consider adding it by adding it in C++ and making a PR. Please tells us if you are planning to do so as we may help in digging into the c++ code.
Good lucks,
DamienDamien MarchalBlockedHi all,
Is this issue solved ?
Damien.
Damien MarchalBlockedHi,
I think the answer from stefan is right if you have installed qt libraries with the apt package manager.
If you used the package manager/installer from the qt web site you have to check the QtWebEngine boxes in the packages list of the installer GUI
Best,
Damien MarchalBlockedIn the previous script, everything is based on the master “branches” so despite all the scenes are working the html tutorials will not be displayed properly.
To have good rendering of the tutorials you need to use the Documentation branch
# Step 0: download and install the latest qt version, # http://download.qt.io/official_releases/online_installers/ # During installation of Qt, don't forget o install the optional QtWebEngine (CHANGE HERE) # Step 1: install all the dependencies sudo apt-get install build-essential sudo apt-get install cmake cmake-qt-gui sudo apt-get install ninja-build sudo apt-get install libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-regex-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev sudo apt-get install python2.7-dev python-numpy python-scipy sudo apt-get install libpng-dev libjpeg-dev libtiff-dev zlib1g-dev libglew-dev sudo apt-get install libxml2-dev libcgal-dev libblas-dev liblapack-dev libsuitesparse-dev libassimp-dev # Step 2: clone Sofa (CHANGE HERE) git clone --branch Documentation https://github.com/SofaDefrost/sofa.git sofa # Step 3: clone plugins mkdir plugins cd plugins git clone https://github.com/SofaDefrost/STLIB.git STLIB # (CHANGE HERE) git clone --branch Documentation https://github.com/SofaDefrost/SoftRobots.git SoftRobots # Step 4: Make a CMakeLists to avoid manual settings of the plugins. echo "set(CMAKE_BUILD_TYPE RelWithDebInfo)" > CMakeLists.txt echo "#EXTERNAL DIRECTORY's plugins" >> CMakeLists.txt echo "sofa_add_plugin(STLIB STLIB)" >> CMakeLists.txt echo "sofa_add_plugin(SoftRobots SoftRobots)" >> CMakeLists.txt cd ../ # Step 4: setup build directory mkdir build cd build cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins -DPLUGIN_STLIB=1 -DPLUGIN_SOFTROBOTS=1 ninja
Damien MarchalBlockedHi @csullivan107,
Here is more or less what I’m doing in a .sh script when I’m preparing a new machine for Sofa:
# Step 0: download and install the latest qt version # http://download.qt.io/official_releases/online_installers/ # Step 1: install all the dependencies sudo apt-get install build-essential sudo apt-get install cmake cmake-qt-gui sudo apt-get install ninja-build sudo apt-get install libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-filesystem-dev libboost-locale-dev libboost-regex-dev libboost-system-dev libboost-thread-dev libboost-program-options-dev sudo apt-get install python2.7-dev python-numpy python-scipy sudo apt-get install libpng-dev libjpeg-dev libtiff-dev zlib1g-dev libglew-dev sudo apt-get install libxml2-dev libcgal-dev libblas-dev liblapack-dev libsuitesparse-dev libassimp-dev # Step 2: clone Sofa git clone https://github.com/sofa-framework/sofa.git sofa # Step 3: clone plugins mkdir plugins cd plugins git clone https://github.com/SofaDefrost/STLIB.git STLIB git clone https://github.com/SofaDefrost/SoftRobots.git SoftRobots # Step 4: Make a CMakeLists to avoid manual settings of the plugins. echo "set(CMAKE_BUILD_TYPE RelWithDebInfo)" > CMakeLists.txt echo "#EXTERNAL DIRECTORY's plugins" >> CMakeLists.txt echo "sofa_add_plugin(STLIB STLIB)" >> CMakeLists.txt echo "sofa_add_plugin(SoftRobots SoftRobots)" >> CMakeLists.txt cd ../ # Step 4: setup build directory mkdir build cd build cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins cmake ../sofa -G Ninja -DPLUGIN_SOFAPYTHON=1 -DSOFA_BUILD_METIS=1 -DSOFA_EXTERNAL_DIRECTORIES=../plugins -DPLUGIN_STLIB=1 -DPLUGIN_SOFTROBOTS=1 ninja
when the compilation is done you can try to run something like the ones in the ‘docs’ directory.
Eg:bin/runSofa ../plugins/SoftRobots/docs/tutorials/Tripod/details/step5.pyscn
You can then press on the Animate button to start simulation
Damien,
Damien MarchalBlockedHi Pierre,
Good to hear, and feel free to ask when you have questions or see bugs or behavior change in Sofa.
These feedback are really useful to improve our code base.
Damien.
7 February 2019 at 00:12 in reply to: get signal when Scene file is closed and display a graph (QtableWidget) #13011Damien MarchalBlockedHi @rubab123,
Are you displaying the graph using PyQt I think the closest you can do is to use the cleanup method of PythonScriptController as in the following example:
import Sofa class MyController(Sofa.PythonScriptController): def __init__(self, node): pass def cleanup(self): print("This is called on cleanup...so do what you want") def createScene(root): MyController(root)
If you are working in c++ you can override the same BaseObject::cleanup method in your component.
In case you want more in-depth interaction with runSofa I think there is in RealGUI.cpp some QT signal to connect to be notified when file is changed.
Hope this helps,
Regards,
Damien.Damien MarchalBlockedH Fayad,
Is this problem solved ?
Regards,
Damien -
AuthorPosts