Giter VIP home page Giter VIP logo

sofa_env's Introduction

Where to find me

Projects

  • sofa_env: Reinforcement learning environments for robot-assisted laparoscopic surgery.
  • sofa_zoo: Reinforcement learning scripts for sofa_env environments.
  • sofa_godot: A Godot plugin to create SOFA scenes in Godot.

Code for papers

Educational projects

Contributing to

  • SOFA: Real-time multi-physics simulation with an emphasis on medical simulation.
  • SofaPython3: Python bindings for SOFA.
  • MP_PyTorch: Movement Primitives in PyTorch.
  • qmk: Keyboard firmware.

sofa_env's People

Contributors

badhon1512 avatar klre avatar mikelitu avatar scheiklp avatar taharchettaoui avatar tomeckardt avatar viet2503 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sofa_env's Issues

Units of measurements

Hi,

I would like to ask you what units of measurement are used in these environments as I haven't found anything in the documentation;
in particular, I would like to know the unit of measurement used for Young's modulus.
Thanks

Francesco

Problems with Python3.8

Hi @ScheiklP,

I have been trying the repository in the last few days, and I saw that you have update the minimum required python version to 3.8. Even though the tests pass using this verion and the simple scene controllable_object_example would work, people will experience problems in other scenes. For example, if you try running environment deflect_spheres, an error will raise regarding the impossibility of performing the bitwise OR (|) operator between defaultdict and dict. This is coming from line 290 on deflect_spheres_env.py.

self.reward_amount_dict = defaultdict(float) | reward_amount_dict

This was solved in Python3.9 on PEP 584. Not sure if you were aware about this, but it may lead to some confusion for future users. Maybe it will be a good idea to talk with the people from SOFA so they update the binaries with a newer version of Python to solve this issue and have full compatibility with this repository. Another solution would be to create a Docker Image to self contain the requirements to run this repository from any computer. I hope his comment helps.

Best,
Mikel

Error File Repository

hi,
i have been running successfully a simulation in a new environment i have created myself... now that i have changed the meshes involved i am encountering this error though :
[ERROR] [FileRepository] File kidney-3786-0.01.comp NOT FOUND in :C:/Users/franc/anaconda3/envs/sofasource/sofa/src/share:C:/Users/franc/anaconda3/envs/sofasource/sofa/src/examples:C:/Users/franc/anaconda3/envs/sofasource/sofa/build:C:/Users/franc/anaconda3/envs/sofasource/sofa/build

actually this file is not in the right folder, but i have noticed that in C:/Users/franc/anaconda3/envs/sofasource/sofa/src/share there are the others .comp files of the previous meshes, without me having done anything.

how can i solve this problem? thanks in advance for your help

SOFA_ZOO Observation Space Type Assertion Error

python ~/sofa/sofa_zoo/sofa_zoo/envs/reach/ppo.py

I ran the code above and ended up with an Assertion Error.

image

It seemed that type(env.observation_space) = <class 'gymnasium.spaces.box.Box'>, which is not gym.spaces.Box that the code required.

image

Do you know how to fix this problem?
I really appreciate any help you can provide.

CANNOT build SOFA

I'm installing the SOFA environment following this link https://github.com/ScheiklP/sofa_env/blob/d0d197d4bda74338e8b6aa1e5a72a9c715f7f73e/docs/source/setting_up_sofa.rst

Follow the instructions from top to bottom until the build SOFA in the Compile SOFA part. I received a thousand lines of error.


Environment

Context

  • System: Ubuntu 18.04.5 LTS
  • Version of SOFA: master branch at commit d0d197d

Command called

cmake --build $FOLDER_TARGET -j --target install

I will show you a first few lines of the error messages.

In file included from /bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.cpp:22:0:
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:28:23: error: variable 'sofa::helper::visual::SOFA_EXPORT_DYNAMIC_LIBRARY sofa::helper::visual::Transformation' has initializer but incomplete type
 class SOFA_HELPER_API Transformation
                       ^~~~~~~~~~~~~~
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:30:1: error: expected primary-expression before 'public'
 public:
 ^~~~~~
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:30:1: error: expected '}' before 'public'
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:30:1: error: expected ',' or ';' before 'public'
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:32:5: error: 'SReal' does not name a type
     SReal   scale[3];
     ^~~~~
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:33:5: error: 'SReal' does not name a type
     SReal   rotation[4][4];
     ^~~~~
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:34:5: error: 'SReal' does not name a type
     SReal   objectCenter[3];
     ^~~~~
/bigdata/users/kleelakunwet/sofa/src/Sofa/framework/Helper/src/sofa/helper/visual/Transformation.h:36:21: error: expected constructor, destructor, or type conversion before ';' token
     Transformation();
                     ^

sofa_env test question

Hi, I met a problem while testing the installation python3 sofa_env/scenes/controllable_object_example/controllable_env.py
And I got out put like this

---------------------------------------
Checking SOFA_ROOT and SOFAPYTHON3_ROOT
Using environment variable SOFA_ROOT: /home/yhf/sofa/build/install
---------------------------------------
Traceback (most recent call last):
  File "/home/yhf/sofa/sofa_env/sofa_env/scenes/controllable_object_example/controllable_env.py", line 65, in <module>
    env.reset()
  File "/home/yhf/sofa/sofa_env/sofa_env/scenes/controllable_object_example/controllable_env.py", line 53, in reset
    return super().reset(seed)
  File "/home/yhf/sofa/sofa_env/sofa_env/base.py", line 206, in reset
    self._init_sim()
  File "/home/yhf/sofa/sofa_env/sofa_env/base.py", line 229, in _init_sim
    self.sofa = importlib.import_module("Sofa")
  File "/home/yhf/anaconda3/envs/sofa_try/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/yhf/anaconda3/envs/sofa_try/lib/python3.9/site-packages/Sofa/__init__.py", line 140, in <module>
    import Sofa.Helper
ModuleNotFoundError: No module named 'Sofa.Helper'

What should I do to solve this problem? Thank you.

improve texture

Hi,
i'm using a .png image texture for the objects in my simulations, but the image doesn't wrap around the mesh like i want and there's always a marked line that creates problems. There is a way to solve my problem in Sofa? or maybe to import the information about the texture mapping from another program?
thanks a lot

Updating gym to gymnasium and cleaning some imports

Hello,

I am working a lot with Sofa in the last few years for my PhD and I have found this repository as @ScheiklP mentioned one code snapshot from it when I was struggling with a grasping simulation. I have to say that this repository is really impressive and I would be really interested to use some of the environments to train some DNN for my PhD and add some extra functionalities along with my work.

However, I came across some problem when trying to install the python package on my computer. I found the error was coming from the Gym package. As I could read at the official repository from OpenAI about Gym, they stopped maintainance on this repository on 2021. The development was moved to Gymnasium and now the recommended form of use is import gymnasium as gym. I think it will be good for new users to have this updated on the main branch. Do you want me to submit a pull request with the necessary changes?

Regards,
Mikel

Installation Error: Could not find GLEW (missing: GLEW_LIBRARIES)

Hi,

I had problem installing the sofa_env with cmake code

cmake -Wno-dev \
-S $FOLDER_SRC -B $FOLDER_TARGET \
-DCMAKE_BUILD_TYPE=Release \
-DSOFA_FETCH_SOFAPYTHON3=OFF \
-DPLUGIN_SOFAPYTHON3=ON \
-DPython_EXECUTABLE=$PYTHON_EXE \
-DPython_ROOT_DIR=$PYTHON_ROOT_DIR \
-DSP3_LINK_TO_USER_SITE=ON \
-DSP3_PYTHON_PACKAGES_LINK_DIRECTORY=$PYTHON_PKG_PATH \
-DPLUGIN_SOFACARVING=ON \
-DSP3_BUILD_TEST=OFF \
-DSOFA_BUILD_TESTS=OFF
<font color="#C01C28">  Could NOT find GLEW (missing: GLEW_LIBRARIES) (found version &quot;2.2.0&quot;)</font>
<font color="#C01C28">Call Stack (most recent call first):</font>
<font color="#C01C28">  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)</font>
<font color="#C01C28">  /usr/share/cmake-3.22/Modules/FindGLEW.cmake:215 (find_package_handle_standard_args)</font>
<font color="#C01C28">  Sofa/framework/Config/cmake/SofaMacrosConfigure.cmake:382 (find_package)</font>
<font color="#C01C28">  Sofa/GL/CMakeLists.txt:7 (sofa_find_package)</font>
</pre>```

Do you have any idea how to fix it?

Thank you so much!

sofa_env test

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

Implement CPU based offscreen rendering

Pyglet supports offscreen rendering through EGL, but PyGame does not.
The combination of RenderFramework.PYGAME and RenderMode.HEADLESS thus currently not work.

For the future, we should fallback to LLVMpipe and OSMesa for this case.

import os
import numpy as np
from PIL import Image
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.raw.osmesa import mesa as osmesa

# Use LLVMpipe for rendering
os.environ['LIBGL_ALWAYS_SOFTWARE'] = '1'
os.environ['GALLIUM_DRIVER'] = 'llvmpipe'

# create a context
ctx = osmesa.OSMesaCreateContextExt(osmesa.OSMESA_RGBA, 32, 0, 0, None)
if not ctx:
    print('Could not create OSMesa context')
    exit(1)

# create a framebuffer
width, height = 640, 480
buffer = np.zeros([height, width, 4], dtype=np.uint8)

# make the context current
if not osmesa.OSMesaMakeCurrent(ctx, buffer, GL_UNSIGNED_BYTE, width, height):
    print('Could not make the OSMesa context current')
    exit(1)

# setup viewport
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(-1, 1, -1, 1, -1, 1)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()

# render a red triangle
glBegin(GL_TRIANGLES)
glColor3f(1, 0, 0)  # Red color
glVertex2f(-0.5, -0.5)
glVertex2f(0.5, -0.5)
glVertex2f(0, 0.5)
glEnd()

# unbind the context before deletion
osmesa.OSMesaMakeCurrent(None, None, GL_UNSIGNED_BYTE, 0, 0)

# clean up
osmesa.OSMesaDestroyContext(ctx)

# flip the buffer vertically (origin is different in OSMesa and PIL)
buffer = np.flipud(buffer)

# convert the buffer to an image and save it
img = Image.fromarray(buffer, 'RGBA')
img.save('output.png')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.