ScheiklP / sofa_env

Reinforcement learning environments for robot-assisted laparoscopic surgery
MIT License
47 stars 14 forks source link

sofa_env test #9

Closed PiccioFra closed 11 months ago

PiccioFra commented 1 year ago

hi everyone, i installed sofa_env but i get issues while installing the pyDNS. I have read that it does not work with python3, so i tried to install pip3DNS... but when i try to launch the test file, like it is said on the github page, i receive this error, although i can guarantee you that i installed it Traceback (most recent call last): File "C:\Users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\scenes\controllable_object_example\controllable_env.py", line 62, in env.reset() File "C:\Users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\scenes\controllable_object_example\controllable_env.py", line 49, in reset return super().reset() File "c:\users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\base.py", line 149, in reset self._init_sim() File "c:\users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\base.py", line 187, in init_sim self.sofa = importlib.import_module("Sofa") File "C:\Users\franc\anaconda3\envs\sofa\lib\importlib_init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'Sofa'

Thanks in advance for your help

ScheiklP commented 1 year ago

Hi @PiccioFra, thanks for reaching out! :)

Huh, which part does require pyDNS?

Since you are on a Windows system, I will have to do a lot of guess work, sorry for that. :D

Cheers, Paul

PiccioFra commented 1 year ago

Hi, I have installed SOFA from binary. I actually don't have Sofa there...I don't have the last part of the path "/python3.10/site-packages". How do i solve that? Thanks, Francesco

ScheiklP commented 1 year ago

Hi Francesco, ah, I see. When you download the binaries, they do not automatically link to your python environment.

What you could do is the following:

  1. Make sure that your conda environment is using python3.8 (that is the one that the binaries for v23.06 are using)
  2. Download the zip file for Windows: https://www.sofa-framework.org/download/
  3. Create symbolic links from the contents of the extracted zip file to your environment as described here. The command for creating symbolic links under Windos is explained here. Something like
    mklink /d <the extracted zip>/plugins/SofaPython3/lib/python3/site-packages/Sofa C:\Users\franc\anaconda3\envs\sofa/python3.8/site-packages/Sofa
    mklink /d <the extracted zip>/plugins/SofaPython3/lib/python3/site-packages/SofaRuntime C:\Users\franc\anaconda3\envs\sofa/python3.8/site-packages/SofaRuntime
    mklink /d <the extracted zip>/plugins/SofaPython3/lib/python3/site-packages/SofaTypes C:\Users\franc\anaconda3\envs\sofa/python3.8/site-packages/SofaTypes
    mklink /d <the extracted zip>/plugins/SofaPython3/lib/python3/site-packages/splib C:\Users\franc\anaconda3\envs\sofa/python3.8/site-packages/splib

Let me know if that works for you!

Cheers, Paul

PiccioFra commented 1 year ago

Hi, I have made the links and then tried to redo everything step by step following your instructions, but when i try to launch the test scene i get these errors: (sofa) C:\Windows\System32>python "C:\Users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\scenes\controllable_object_example\controllable_env.py" [ERROR] [FileSystem::exists()] "C:\Users\franc\SOFA\v23.06.00\bin": error 123: La sintassi del nome del file, della directory o del volume non è corretta.

[ERROR] [Utils::readBasicIniFile()] Error while trying to read file (C:/Users/franc/anaconda3/envs/sofa) [ERROR] [RequiredPlugin(Sofa.Component.Constraint.Lagrangian.Model)] Plugin not found: "Sofa.Component.Constraint.Lagrangian.Model"

Failed to load: ["Sofa.Component.Constraint.Lagrangian.Model"] [ERROR] [RequiredPlugin(Sofa.Component.Topology.Container.Dynamic)] Plugin not found: "Sofa.Component.Topology.Container.Dynamic"

Failed to load: ["Sofa.Component.Topology.Container.Dynamic"] [ERROR] [RequiredPlugin(Sofa.Component.Topology.Container.Grid)] Plugin not found: "Sofa.Component.Topology.Container.Grid"

Failed to load: ["Sofa.Component.Topology.Container.Grid"] [ERROR] [RequiredPlugin(Sofa.Component.Collision.Geometry)] Plugin not found: "Sofa.Component.Collision.Geometry"

Failed to load: ["Sofa.Component.Collision.Geometry"] [ERROR] [RequiredPlugin(Sofa.Component.Topology.Mapping)] Plugin not found: "Sofa.Component.Topology.Mapping"

Failed to load: ["Sofa.Component.Topology.Mapping"] [ERROR] [RequiredPlugin(ArticulatedSystemPlugin)] Plugin not found: "ArticulatedSystemPlugin"

Failed to load: ["ArticulatedSystemPlugin"] [ERROR] [RequiredPlugin(Sofa.Component.Visual)] Plugin not found: "Sofa.Component.Visual"

Failed to load: ["Sofa.Component.Visual"] [ERROR] [RequiredPlugin(Sofa.Component.Setting)] Plugin not found: "Sofa.Component.Setting"

Failed to load: ["Sofa.Component.Setting"] [ERROR] [RequiredPlugin(Sofa.Component.Engine.Select)] Plugin not found: "Sofa.Component.Engine.Select"

Failed to load: ["Sofa.Component.Engine.Select"] [ERROR] [RequiredPlugin(Sofa.Component.LinearSolver.Iterative)] Plugin not found: "Sofa.Component.LinearSolver.Iterative"

Failed to load: ["Sofa.Component.LinearSolver.Iterative"] [ERROR] [RequiredPlugin(Sofa.Component.Collision.Response.Contact)] Plugin not found: "Sofa.Component.Collision.Response.Contact"

Failed to load: ["Sofa.Component.Collision.Response.Contact"] [ERROR] [RequiredPlugin(Sofa.Component.ODESolver.Backward)] Plugin not found: "Sofa.Component.ODESolver.Backward"

Failed to load: ["Sofa.Component.ODESolver.Backward"] [ERROR] [RequiredPlugin(Sofa.Component.ODESolver.Forward)] Plugin not found: "Sofa.Component.ODESolver.Forward"

Failed to load: ["Sofa.Component.ODESolver.Forward"] [ERROR] [RequiredPlugin(Sofa.Component.SolidMechanics.FEM.Elastic)] Plugin not found: "Sofa.Component.SolidMechanics.FEM.Elastic"

Failed to load: ["Sofa.Component.SolidMechanics.FEM.Elastic"] [ERROR] [RequiredPlugin(Sofa.Component.StateContainer)] Plugin not found: "Sofa.Component.StateContainer"

Failed to load: ["Sofa.Component.StateContainer"] [ERROR] [RequiredPlugin(Sofa.Component.AnimationLoop)] Plugin not found: "Sofa.Component.AnimationLoop"

Failed to load: ["Sofa.Component.AnimationLoop"] [ERROR] [RequiredPlugin(Sofa.Component.SolidMechanics.Spring)] Plugin not found: "Sofa.Component.SolidMechanics.Spring"

Failed to load: ["Sofa.Component.SolidMechanics.Spring"] [ERROR] [RequiredPlugin(Sofa.Component.IO.Mesh)] Plugin not found: "Sofa.Component.IO.Mesh"

Failed to load: ["Sofa.Component.IO.Mesh"] [ERROR] [RequiredPlugin(Sofa.GL.Component.Rendering3D)] Plugin not found: "Sofa.GL.Component.Rendering3D"

Failed to load: ["Sofa.GL.Component.Rendering3D"] [ERROR] [RequiredPlugin(Sofa.Component.Mapping.Linear)] Plugin not found: "Sofa.Component.Mapping.Linear"

Failed to load: ["Sofa.Component.Mapping.Linear"] [ERROR] [RequiredPlugin(SofaEngine)] Plugin not found: "SofaEngine"

Failed to load: ["SofaEngine"] [ERROR] [RequiredPlugin(Sofa.Component.Constraint.Lagrangian.Solver)] Plugin not found: "Sofa.Component.Constraint.Lagrangian.Solver"

Failed to load: ["Sofa.Component.Constraint.Lagrangian.Solver"] [ERROR] [RequiredPlugin(Sofa.Component.Collision.Detection.Algorithm)] Plugin not found: "Sofa.Component.Collision.Detection.Algorithm"

Failed to load: ["Sofa.Component.Collision.Detection.Algorithm"] [ERROR] [RequiredPlugin(Sofa.GL.Component.Shader)] Plugin not found: "Sofa.GL.Component.Shader"

Failed to load: ["Sofa.GL.Component.Shader"] [ERROR] [RequiredPlugin(Sofa.Component.Constraint.Projective)] Plugin not found: "Sofa.Component.Constraint.Projective"

Failed to load: ["Sofa.Component.Constraint.Projective"] [ERROR] [RequiredPlugin(Sofa.Component.Constraint.Lagrangian.Correction)] Plugin not found: "Sofa.Component.Constraint.Lagrangian.Correction"

Failed to load: ["Sofa.Component.Constraint.Lagrangian.Correction"] [ERROR] [RequiredPlugin(Sofa.Component.Collision.Detection.Intersection)] Plugin not found: "Sofa.Component.Collision.Detection.Intersection"

Failed to load: ["Sofa.Component.Collision.Detection.Intersection"] [ERROR] [RequiredPlugin(SofaBoundaryCondition)] Plugin not found: "SofaBoundaryCondition"

Failed to load: ["SofaBoundaryCondition"] [ERROR] [RequiredPlugin(Sofa.Component.SceneUtility)] Plugin not found: "Sofa.Component.SceneUtility"

Failed to load: ["Sofa.Component.SceneUtility"] [ERROR] [RequiredPlugin(Sofa.Component.Mass)] Plugin not found: "Sofa.Component.Mass"

Failed to load: ["Sofa.Component.Mass"] [ERROR] [RequiredPlugin(Sofa.Component.Mapping.NonLinear)] Plugin not found: "Sofa.Component.Mapping.NonLinear"

Failed to load: ["Sofa.Component.Mapping.NonLinear"] [ERROR] [RequiredPlugin(Sofa.Component.LinearSolver.Direct)] Plugin not found: "Sofa.Component.LinearSolver.Direct"

Failed to load: ["Sofa.Component.LinearSolver.Direct"] [ERROR] [RequiredPlugin(Sofa.Component.Topology.Container.Constant)] Plugin not found: "Sofa.Component.Topology.Container.Constant"

Failed to load: ["Sofa.Component.Topology.Container.Constant"] Error in sys.excepthook: Traceback (most recent call last): File "C:\Users\franc\anaconda3\envs\sofa\lib\site-packages\SofaRuntime__init__.py", line 135, in sofaExceptHandler Sofa.msg_error("SofaRuntime", h + '\n' + s) AttributeError: module 'Sofa' has no attribute 'msg_error'

Original exception was: Traceback (most recent call last): File "C:\Users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\scenes\controllable_object_example\controllable_env.py", line 63, in env.reset() File "C:\Users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\scenes\controllable_object_example\controllable_env.py", line 51, in reset return super().reset() File "c:\users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\base.py", line 177, in reset self._init_sim() File "c:\users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\base.py", line 271, in _init_sim self.scene_creation_result = getattr(self._scene_description_module, "createScene")(self._sofa_root_node, **self.create_scene_kwargs) File "C:\Users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\scenes\controllable_object_example\scene_description.py", line 21, in createScene add_scene_header( File "c:\users\franc\anaconda3\envs\sofa\sofa_env-main\sofa_env\sofa_templates\scene_header.py", line 172, in add_scene_header root_node.addObject("BackgroundSetting", color=background_color) ValueError: Object type BackgroundSetting<> was not created The object 'BackgroundSetting' is not in the factory. This component has been MOVED from SofaBaseVisual to Sofa.Component.UserInterface.ConfigurationSetting since SOFA v22.06. To continue using this component you may need to update your scene by adding

Thanks for yout help Francesco

ScheiklP commented 1 year ago

Hi Francesco, would it be possible for you to compile sofa from source as described in the instructions? I have documented the last tested commits for Sofa and SofaPython3. If that works, we can try do find out why the downloaded binaries do not.

If that also does not work, we can figure out how to do that on Windows. Maybe @TaharChettaoui could help us with that.

Cheers, Paul

TaharChettaoui commented 1 year ago

Hi everyone, I remember facing a similar problem. However, my issue was due to an older version of SOFA "v21.12" that was not adapted with the latest plugins. I would also suggest compiling from source as @ScheiklP recommended. If that doesn't work, you might consider working on WSL.

ScheiklP commented 1 year ago

Hi @TaharChettaoui, oh that would be probably the easiest solution. Did you ever try using the Ubuntu binaries on WSL?

TaharChettaoui commented 1 year ago

Hi @ScheiklP, Sadly never tried the binaries. I followed installation steps similar to the ones described in "docs/source/setting_up_sofa.rst" and that worked for me.

ScheiklP commented 1 year ago

Hi @PiccioFra, were you able to resolve the issue?

Cheers, Paul

ScheiklP commented 11 months ago

Hi @PiccioFra, I'll close the issue for now. Feel free to reach out again, if you have any more questions.

Cheers, Paul