sofadefrost / sofagym Goto Github PK
View Code? Open in Web Editor NEWMachine Learning framework for Sofa
Machine Learning framework for Sofa
Hi
I've tried to load a sample in test_env.py, but found an error raising when executed to env.reset().
D:\SofaGym-main>python test_env.py
---------------------------------------
Checking SOFA_ROOT and SOFAPYTHON3_ROOT
Using environment variable SOFA_ROOT: D:\sofa
Using environment variable SOFAPYTHON3_ROOT: D:\sofa\plugins\SofaPython3
---------------------------------------
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Geometry.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Detection.Algorithm.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Detection.Intersection.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Response.Mapper.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Response.Contact.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Visual.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Setting.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.LinearSolver.Iterative.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Mass.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Mapping.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.StateContainer.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Container.Constant.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Container.Grid.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Container.Dynamic.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.Spring.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Select.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.ODESolver.Forward.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.ODESolver.Backward.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.IO.Mesh.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Diffusion.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.FEM.Elastic.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Projective.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.MechanicalLoad.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Mapping.MappedMatrix.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Lagrangian.Model.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Lagrangian.Correction.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Lagrangian.Solver.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.AnimationLoop.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.TensorMass.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Analyze.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Generate.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Transform.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Engine.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.LinearSolver.Direct.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Playback.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SceneUtility.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GUI.Component.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Mapping.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Controller.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.FEM.NonUniform.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.FEM.HyperElastic.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Utility.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Haptics.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Rendering2D.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Rendering3D.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Shader.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.LinearSolver.Preconditioner.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/SofaComponentAll.dll
Start env concentrictuberobot-v0
50851
D:\python\lib\site-packages\gym\spaces\box.py:127: UserWarning: WARN: Box bound precision lowered by casting to float32
logger.warn(f"Box bound precision lowered by casting to {self.dtype}")
D:\python\lib\site-packages\gym\utils\passive_env_checker.py:174: UserWarning: WARN: Future gym versions will require that `Env.reset` can be passed a `seed` instead of using `Env.seed` for resetting the environment random number generator.
logger.warn(
D:\python\lib\site-packages\gym\utils\passive_env_checker.py:187: UserWarning: WARN: Future gym versions will require that `Env.reset` can be passed `options` to allow the environment initialisation to be passed additional information.
logger.warn(
All clients are closed. Bye Bye.
{'scene': 'CTR', 'deterministic': True, 'source': [-150, 0, 30], 'target': [0, 0, 30], 'mesh': 'mesh/nasal_cavity.obj', 'scale': 30, 'rotation': [140.0, 0.0, 0.0], 'translation': [0.0, 0.0, 0.0], 'goalList': [[0.0, 0.0, 0.0]], 'goalPos': [0.0, 16.861897843737978, 44.72900560493795], 'scale_factor': 10, 'timer_limit': 50, 'timeout': 3, 'display_size': (1600, 800), 'render': 1, 'save_data': True, 'save_path': 'D:\\SofaGym-main\\sofagym\\envs\\CTR/Results/CTR', 'planning': True, 'discrete': True, 'seed': 0, 'start_from_history': None, 'python_version': 'python3.8', 'zFar': 5000, 'save_path_image': None, 'save_path_results': 'D:\\SofaGym-main\\sofagym\\envs\\CTR/Results/CTR/data', 'dt': 0.01, 'goal_node': 0}
---------------------------------------
Checking SOFA_ROOT and SOFAPYTHON3_ROOT
Using environment variable SOFA_ROOT: D:\sofa
Using environment variable SOFAPYTHON3_ROOT: D:\sofa\plugins\SofaPython3
---------------------------------------
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Geometry.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Detection.Algorithm.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Detection.Intersection.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Response.Mapper.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Collision.Response.Contact.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Visual.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Setting.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.LinearSolver.Iterative.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Mass.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Mapping.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.StateContainer.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Container.Constant.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Container.Grid.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Container.Dynamic.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.Spring.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Select.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.ODESolver.Forward.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.ODESolver.Backward.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.IO.Mesh.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Diffusion.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.FEM.Elastic.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Projective.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.MechanicalLoad.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Mapping.MappedMatrix.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Lagrangian.Model.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Lagrangian.Correction.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Constraint.Lagrangian.Solver.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.AnimationLoop.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.TensorMass.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Analyze.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Generate.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Engine.Transform.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Engine.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.LinearSolver.Direct.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Playback.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SceneUtility.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GUI.Component.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Mapping.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Controller.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.FEM.NonUniform.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.SolidMechanics.FEM.HyperElastic.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Topology.Utility.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.Haptics.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Rendering2D.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Rendering3D.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.GL.Component.Shader.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/Sofa.Component.LinearSolver.Preconditioner.dll
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/SofaComponentAll.dll
SCENE {'scene': 'CTR', 'deterministic': True, 'source': [-150, 0, 30], 'target': [0, 0, 30], 'mesh': 'mesh/nasal_cavity.obj', 'scale': 30, 'rotation': [140.0, 0.0, 0.0], 'translation': [0.0, 0.0, 0.0], 'goalList': [[0.0, 0.0, 0.0]], 'goalPos': [0.0, 16.861897843737978, 44.72900560493795], 'scale_factor': 10, 'timer_limit': 50, 'timeout': 3, 'display_size': (1600, 800), 'render': 1, 'save_data': True, 'save_path': 'D:\\SofaGym-main\\sofagym\\envs\\CTR/Results/CTR', 'planning': True, 'discrete': True, 'seed': 0, 'start_from_history': None, 'python_version': 'python3.8', 'zFar': 5000, 'save_path_image': None, 'save_path_results': 'D:\\SofaGym-main\\sofagym\\envs\\CTR/Results/CTR/data', 'dt': 0.01, 'goal_node': 0}
[INFO] [PluginManager] Loaded plugin: D:/sofa/bin/BeamAdapter.dll
########## SIG 11 - SIGSEGV: segfault ##########
sofa::helper::BackTrace::dump
sofa::helper::BackTrace::sig
exp2f
exp2f
_C_specific_handler
_chkstk
RtlRestoreContext
KiUserExceptionDispatcher
PyObject_GetAttrString
sofapython3::PythonEnvironment::getStaticData
initExternalModule
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
PyCFunction_Call
PyObject_MakeTpCall
Py_FatalError
Py_CheckFunctionResult
PyEval_EvalFrameDefault
Py_CheckFunctionResult
PyEval_EvalFrameDefault
PyEval_EvalCodeWithName
Py_CheckFunctionResult
PyEval_EvalFrameDefault
PyEval_EvalCodeWithName
Py_CheckFunctionResult
PyEval_EvalFrameDefault
PyEval_EvalCodeWithName
PyEval_EvalCodeEx
PyEval_EvalCode
PyArena_New
PyArena_New
PyRun_FileExFlags
PyRun_SimpleFileExFlags
PyRun_AnyFileExFlags
Py_FatalError
Py_RunMain
Py_RunMain
Py_Main
Py_Main
BaseThreadInitThunk
RtlUserThreadStart
Exception in thread Thread-3:
Traceback (most recent call last):
File "D:\python\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "D:\python\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "D:\SofaGym-main\sofagym\rpc_server.py", line 529, in deferredStart
subprocess.run([sys.executable, path+"sofagym/rpc_client.py", sdict, str(nb_actions), str(port_rpc)],
File "D:\python\lib\subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['D:\\python\\python.exe', 'D:\\SofaGym-main/sofagym/rpc_client.py', "{'scene': 'CTR', 'deterministic': True, 'source': [-150, 0, 30], 'target': [0, 0, 30], 'mesh': 'mesh/nasal_cavity.obj', 'scale': 30, 'rotation': [140.0, 0.0, 0.0], 'translation': [0.0, 0.0, 0.0], 'goalList': [[0.0, 0.0, 0.0]], 'goalPos': [0.0, 16.861897843737978, 44.72900560493795], 'scale_factor': 10, 'timer_limit': 50, 'timeout': 3, 'display_size': (1600, 800), 'render': 1, 'save_data': True, 'save_path': 'D:\\\\SofaGym-main\\\\sofagym\\\\envs\\\\CTR/Results/CTR', 'planning': True, 'discrete': True, 'seed': 0, 'start_from_history': None, 'python_version': 'python3.8', 'zFar': 5000, 'save_path_image': None, 'save_path_results': 'D:\\\\SofaGym-main\\\\sofagym\\\\envs\\\\CTR/Results/CTR/data', 'dt': 0.01, 'goal_node': 0}", '12', '50851']' returned non-zero exit status 3.
Hi, thank you for great works for SofaGym!
I currently study SofaGym and make my own environment.
In my reinforcement learning architecture, I want to define image state(or observation) which is related to GUI screen image.
For this, I defined additional camera in Scene python file as follows:
(I thought that InteractiveCamera can realize my wish :))
source = config["source"]
target = config["target"]
rootNode.addObject("InteractiveCamera", name='camera2', position=source, lookAt=target, zFar=500)
Next, I refer to viewer.py and find the code which can make image object as follows:
glViewport(0, 0, self.surface_size[0], self.surface_size[1])
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glEnable(GL_LIGHTING)
glEnable(GL_DEPTH_TEST)
if self.root:
Sofa.SofaGL.glewInit()
Sofa.Simulation.initVisual(self.root)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45, (self.surface_size[0] / self.surface_size[1]), 0.1, self.zFar)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
cameraMVM = self.root.camera.getOpenGLModelViewMatrix()
glMultMatrixd(cameraMVM)
Sofa.SofaGL.draw(self.root)
else:
print("===============> ERROR")
try:
x, y, width, height = glGetIntegerv(GL_VIEWPORT)
except:
width, height = self.surface_size[0], self.surface_size[1]
buff = glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE)
image_array = np.fromstring(buff, np.uint8)
if image_array.shape != (0,):
image = image_array.reshape(self.surface_size[1], self.surface_size[0], 3)
else:
image = np.zeros((self.surface_size[1], self.surface_size[0], 3))
image = np.flipud(image)
image = np.moveaxis(image, 0, 1)
I checked that above image is same as GUI screen image.
By using above code and Interactive camera(defined as camera2), I implemented additional function that returns image in Toolbox python file.
However, there is some multi-thread error(I guess that problem is due to reinitialization such as Sofa.SofaGL.glewInit() and Sofa.SofaGL.draw(self.root)).
So I conclude that this is not good approach.
Is there any method to get screen image in Toolbox and Scene code python without GUI?
Why BeamAdapter and SoftRobots are not optional?
Originally posted by @alxbilger in #6 (comment)
The new rlberry==0.6.0 has been updated in the file structure, causing sofagym to error.
It should uses rlberry==0.5.
After a clean installation following the README, I run python test_env.py
and got the following error regarding the GLSLShader and the viewport:
>> Init cartstem_config...
>> Init CartStem...
>> Init cartstem...
>> Init done.
>> Time before start: 0 steps. Initialization ...
>> ... Done.
Start ...
--------------------------------
EPISODE - 0
--------------------------------
/home/obarbany/miniconda3/envs/ddm/lib/python3.7/site-packages/gym/utils/passive_env_checker.py:220: DeprecationWarning: WARN: Core environment is written in old step API which returns one bool instead of two. It is recommended to rewrite the environment with new step API.
"Core environment is written in old step API which returns one bool instead of two. "
/home/obarbany/miniconda3/envs/ddm/lib/python3.7/site-packages/gym/utils/passive_env_checker.py:142: UserWarning: WARN: The obs returned by the `step()` method was expecting numpy array dtype to be float32, actual type: float64
f"{pre} was expecting numpy array dtype to be {observation_space.dtype}, actual type: {obs.dtype}"
/home/obarbany/miniconda3/envs/ddm/lib/python3.7/site-packages/gym/utils/passive_env_checker.py:165: UserWarning: WARN: The obs returned by the `step()` method is not within the observation space.
logger.warn(f"{pre} is not within the observation space.")
[INFO] >>> Time: 0.033739328384399414
[INFO] >>> RTF: 2.96390013638323
[ERROR] [GLSLShader] ERROR: Link of program shader failed:
[ERROR] [GLSLShader] Vertex info
-----------
(0) : error C5145: must write to gl_Position
[ERROR] [GLSLShader] Fragment shader file: shaders/softShadows/VSM/generate_depth_texture.frag
[ERROR] [GLSLShader] Vertex shader file: shaders/softShadows/VSM/generate_depth_texture.vert
[ERROR] [GLSLShader] ERROR: Link of program shader failed:
[ERROR] [GLSLShader] Vertex info
-----------
(0) : error C5145: must write to gl_Position
[ERROR] [GLSLShader] Fragment shader file: shaders/softShadows/VSM/blur_texture.frag
[ERROR] [GLSLShader] Vertex shader file: shaders/softShadows/VSM/blur_texture.vert
[ERROR] [GLSLShader] ERROR: Link of program shader failed:
[ERROR] [GLSLShader] Vertex info
-----------
(0) : error C5145: must write to gl_Position
[ERROR] [GLSLShader] Fragment shader file: shaders/softShadows/VSM/generate_depth_texture.frag
[ERROR] [GLSLShader] Vertex shader file: shaders/softShadows/VSM/generate_depth_texture.vert
[ERROR] [GLSLShader] ERROR: Link of program shader failed:
[ERROR] [GLSLShader] Vertex info
-----------
(0) : error C5145: must write to gl_Position
[ERROR] [GLSLShader] Fragment shader file: shaders/softShadows/VSM/blur_texture.frag
[ERROR] [GLSLShader] Vertex shader file: shaders/softShadows/VSM/blur_texture.vert
Step 1 action : 1 reward : 1.0 done: False
[INFO] >>> Time: 0.03290152549743652
[INFO] >>> RTF: 3.039372749077892
[ERROR] [SofaRuntime] GLError: GLError(
err = 1281,
description = b'invalid value',
baseOperation = glViewport,
cArguments = (0, 0, 1600, 800)
)
On a side note, it looks like the signature of Animation
in splib3.animation.animete
changed and now requires a realTimeClock
boolean as argument.
Actually, I don't get familiar with the structure of the sofagym, And I try my best to describe my issue.
I think the executeAnimation is the function of operating the gripper, and setPos is to update the position which is gotten from the getPos function to update the value of the position.
I print the value in the executeAnimation.
Why this function is actuated 5 times in one step?
And Why each actuated previous position is initialized? (Not save the previous value)
def executeAnimation(fingers, factor):
# print("In ExecuteAnimation")
# self.dofs.append(self.node.getChild('PneumaticGripper').getChild('PneumaticFinger'+str(i+1)).mecaObj)
results0 = moveRestPos(fingers[0].mecaObj.position.value, -1.0, -1.0, -1.0)
results1 = moveRestPos(fingers[1].mecaObj.position.value, -1.0, -1.0, -1.0)
print("============")
print(fingers[0].mecaObj.position.value[0])
print(results0[0])
fingers[0].mecaObj.position.value = results0
print(fingers[0].mecaObj.position.value[0])
fingers[1].mecaObj.position.value = results1
`
The code may a little different from the Gripper to which I referred.
Moreover, when I run the gripper env, the gripper also not changed position and orientation.
When running simple examples the environments of sofagym, this error happens:
Exception in thread Thread-2 (dispatch):
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/samuelyoussef/Documents/SOFA/Plugins/SofaGym/sofagym/rpc_server.py", line 417, in dispatch
with SimpleThreadedXMLRPCServer(('localhost', port_rpc), requestHandler=RequestHandler) as server:
File "/usr/lib/python3.10/xmlrpc/server.py", line 605, in __init__
socketserver.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
File "/usr/lib/python3.10/socketserver.py", line 452, in __init__
self.server_bind()
File "/usr/lib/python3.10/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
Once we have a binary, use STLIB compiled in the binary and stop porting it here
Hi, I am trying to use sofa-gym in order to train an agent to move a catheter from one area of a model heart to another. Previously I have been using imitation learning techniques which have been relatively successful. My scene is based on this scene in the beam adapter example. This uses 'InterventionalRadiologyController' to move the catheter. Now I am following the CartPole example and am unsure how to implement the class 'ApplyAction' for my purposes, in order to move the catheter. Any help would be appreciated. Thanks, Mark.
With Sofa v22.12, I got on almost all envs an error :
[ERROR] [LinearSolverConstraintCorrection(GCS)] Can not use the solver linearSolver because it is templated on GraphScatteredType
Some idea ?
I got some warnings too :
[WARNING]` [ShewchukPCGLinearSolver(linearSolver)] String data "preconditioners" is now replaced by explicit data link: "preconditioner" (PR #3155)
[SUGGESTION] [SparseLDLSolver(precond)] Template is empty
By default SparseLDLSolver uses blocks with a single scalar (to handle all cases of simulations).
If you are using only 3D DOFs, you may consider using blocks of Matrix3 to speedup the calculations.
If it is the case, add template="CompressedRowSparseMatrixMat3x3d" to this object in your scene
Otherwise, if you want to disable this message, add template="CompressedRowSparseMatrixd" .
[WARNING] [LinearSolverConstraintCorrection(GCS)] String data "solverName" is now replaced by explicit data link: "linearSolver" (PR #3152)
[WARNING] [ShewchukPCGLinearSolver(linearSolver)] String data "preconditioners" is now replaced by explicit data link: "preconditioner" (PR #3155)
[SUGGESTION] [SparseLDLSolver(precond)] Template is empty
By default SparseLDLSolver uses blocks with a single scalar (to handle all cases of simulations).
If you are using only 3D DOFs, you may consider using blocks of Matrix3 to speedup the calculations.
If it is the case, add template="CompressedRowSparseMatrixMat3x3d" to this object in your scene
Otherwise, if you want to disable this message, add template="CompressedRowSparseMatrixd" .
[WARNING] [LinearSolverConstraintCorrection(GCS)] String data "solverName" is now replaced by explicit data link: "linearSolver" (PR #3152)
[SUGGESTION] [SparseLDLSolver(solver)] Template is empty
By default SparseLDLSolver uses blocks with a single scalar (to handle all cases of simulations).
If you are using only 3D DOFs, you may consider using blocks of Matrix3 to speedup the calculations.
If it is the case, add template="CompressedRowSparseMatrixMat3x3d" to this object in your scene
Otherwise, if you want to disable this message, add template="CompressedRowSparseMatrixd" .
[WARNING] [GenericConstraintCorrection(unnamed)] String data "solverName" is now replaced by explicit data link: "linearSolver" (PR #3152)
For the rest there does not seem to be any others breaks.
The GripperEnv work but during the scene initialisation (on sofa), i got an error :
[ERROR] [TetrahedronSetTopologyContainer(container)] Cannot find edge 0 [1, 336] in triangle 0 [0 1 336] in the provided edge list (@/Gripper/Finger1/container.edges). It shows an inconsistency between the edge list (@/Gripper/Finger1/container.edges) and the triangle list (@/Gripper/Finger1/container.triangles). Either fix the topology (probably in a mesh file), or provide only the triangle list to '/Gripper/Finger1/container' and not the edges. In the latter case, the edge list will be computed from triangles.
The error takes root from here.
SofaGym/sofagym/envs/Gripper/Finger.py
Lines 30 to 32 in 66af7d8
Using the binary, and following the acceptation of the paper, clean the tests and examples to showcase the results in the article
Hello all
I'm trying to run sofagym but I'm getting this error as in #12
[ERROR] [SofaRuntime] AttributeError: Missing attribute: addNewData Traceback (most recent call last): File "e:\sofa\sofagym\sofagym/sofagym/rpc_client.py", line 174, in <module> root = init_simulation(config, _startCmd, mode='simu') File "e:\sofa\sofagym\sofagym\sofagym\simulate.py", line 49, in init_simulation create_scene(root, config, mode = mode) File "e:\sofa\sofagym\sofagym\sofagym\envs\Trunk\TrunkScene.py", line 214, in createScene trunk = Trunk(simulation, inverseMode=False) File "E:\SOFA\SOFA_v22.06.00_Win64\plugins\STLIB\lib\python3\site-packages\splib3\objectmodel\__init__.py", line 49, in __call__ o.node.addNewData("Prefab type", "Infos", "","string", str(o.__class__.__name__))
When I change the addNewData to addData inside the splib3 I got this error
[ERROR] [SofaRuntime] TypeError: Invalid Type string: available types are [Edge, Hexa, Link, Mat2x2d, Mat2x2f, Mat3x3d, Mat3x3f, Mat3x4d, Mat3x4f, Mat4x4d, Mat4x4f, Penta, PrefabLink, Quad, Rigid3::VecCoord, Rigid3d::VecCoord, Rigid3f::VecCoord, Tetra, Triangle, Vec2d, Vec2f, Vec3d, Vec3f, Vec4d, Vec4f, Vec6d, Vec6f, bool, double, float, int, string, vector<Edge>, vector<Hexa>, vector<Mat2x2d>, vector<Mat2x2f>, vector<Mat3x3d>, vector<Mat3x3f>, vector<Mat3x4d>, vector<Mat3x4f>, vector<Mat4x4d>, vector<Mat4x4f>, vector<Penta>, vector<Quad>, vector<Tetra>, vector<Triangle>, vector<Vec2d>, vector<Vec2f>, vector<Vec3d>, vector<Vec3f>, vector<Vec4d>, vector<Vec4f>, vector<Vec6d>, vector<Vec6f>, vector<bool>, vector<double>, vector<float>, vector<int>, vector<string>] Traceback (most recent call last): File "e:\sofa\sofagym\sofagym/sofagym/rpc_client.py", line 174, in <module> root = init_simulation(config, _startCmd, mode='simu') File "e:\sofa\sofagym\sofagym\sofagym\simulate.py", line 49, in init_simulation create_scene(root, config, mode = mode) File "e:\sofa\sofagym\sofagym\sofagym\envs\Trunk\TrunkScene.py", line 214, in createScene trunk = Trunk(simulation, inverseMode=False) File "E:\SOFA\SOFA_v22.06.00_Win64\plugins\STLIB\lib\python3\site-packages\splib3\objectmodel\__init__.py", line 49, in __call__ o.node.addData("Prefab type", "Infos", "","string", str(o.__class__.__name__))
Can any one tell how to solve this issue please?
I'm runnign Sofa 22.06 on windows 10
Hello,
python test_env.py -e trunk-v0 -ep 100 -s 100
works fine but when I try:
python rl.py -e trunk-v0 -a PPO
I get the following error:
Traceback (most recent call last):
File "/home/emanuele/Desktop/github/sim/sofa/SofaGym/rl.py", line 112, in
agent = Agent(env_name, algo_name, seed, results_dir, max_episode_steps, n_envs)
File "/home/emanuele/Desktop/github/sim/sofa/SofaGym/agents/SB3Agent.py", line 18, in init
super().init(env_id, seed, output_dir, max_episode_steps, n_envs)
File "/home/emanuele/Desktop/github/sim/sofa/SofaGym/agents/SofaBaseAgent.py", line 79, in init
super().init(env_id, seed, output_dir, max_episode_steps)
File "/home/emanuele/Desktop/github/sim/sofa/SofaGym/agents/SofaTestAgent.py", line 82, in init
self.test_env = self.env_make()
File "/home/emanuele/Desktop/github/sim/sofa/SofaGym/agents/SofaTestAgent.py", line 154, in env_make
self.env_seed(env)
File "/home/emanuele/Desktop/github/sim/sofa/SofaGym/agents/SofaTestAgent.py", line 170, in env_seed
env.action_space.np_random.seed(self.seed)
OS: Ubuntu 22.04.3 LTS
Sofa: v22.12
SofaGym: just cloned from main branch, and followed the installation instructions
Can you help me please?
Hi
I'm trying to compile the example TrunkEnv, using a simple python function:
import gym
import sofagym.envs
import time
import sofagym
env = gym.make('trunk-v0')
observation, info = env.reset()
done = False
while not done:
action = env.action_space.sample() # this is where you would insert your policy
observation, reward, done, info = env.step(action)
env.render()
done = terminated or truncated
env.close()
The terminal output errors are below. The line "observation, info = env.reset()" seems to be causing this. I'm using the SOFA binaries on Windows 10 with Python 3.7.
[INFO] [PluginManager] Loaded plugin: C:/Users/Tom/Documents/sofa_build/sofa_build/bin/Sofa.GL.Component.Shader.dll
[INFO] [PluginManager] Loaded plugin: C:/Users/Tom/Documents/sofa_build/sofa_build/bin/Sofa.Component.LinearSolver.Preconditioner.dll
[INFO] [PluginManager] Loaded plugin: C:/Users/Tom/Documents/sofa_build/sofa_build/bin/SofaComponentAll.dll
[INFO] [PluginManager] Loaded plugin: C:/Users/Tom/Documents/sofa_build/sofa_build/bin/STLIB.dll
[INFO] [PluginManager] Loaded plugin: C:/Users/Tom/Documents/sofa_build/sofa_build/bin/SoftRobots.dll
########## SIG 11 - SIGSEGV: segfault ##########
sofa::helper::BackTrace::dump
sofa::helper::BackTrace::sig
seh_filter_exe
seh_filter_exe
_C_specific_handler
_chkstk
RtlRaiseException
KiUserExceptionDispatcher
PyObject_GetAttrString
sofapython3::PythonEnvironment::getStaticData
initExternalModule
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
sofapython3::PythonEnvironment::getPythonCallingPointAsFileInfo
PyMethodDef_RawFastCallKeywords
PyCFunction_FastCallKeywords
PyMethodDef_RawFastCallKeywords
PyEval_EvalFrameDefault
PyEval_EvalCodeWithName
PyMethodDef_RawFastCallKeywords
PyEval_EvalFrameDefault
PyEval_EvalCodeWithName
PyMethodDef_RawFastCallKeywords
PyEval_EvalFrameDefault
PyEval_EvalCodeWithName
PyEval_EvalCodeEx
PyEval_EvalCode
PyArena_Free
PyRun_FileExFlags
PyRun_SimpleFileExFlags
PyRun_AnyFileExFlags
Py_UnixMain
Py_UnixMain
PyErr_NoMemory
Py_Main
Py_Main
Py_Main
BaseThreadInitThunk
RtlUserThreadStart
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Program Files\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "c:\users\tom\documents\sofagym-main\sofagym\rpc_server.py", line 528, in deferredStart
check=True)
File "C:\Program Files\Python37\lib\subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['C:\\Program Files\\Python37\\python.exe', 'c:\\users\\tom\\documents\\sofagym-main/sofagym/rpc_client.py', "{'scene': 'Trunk', 'deterministic': True, 'source': [300, 0, 80], 'target': [0, 0, 80], 'goalList': [[40, 40, 100], [-10, 20, 80]], 'start_node': None, 'scale_factor': 5, 'timer_limit': 250, 'timeout': 50, 'display_size': (1600, 800), 'render': 1, 'save_data': False, 'save_image': False, 'save_path': 'c:\\\\users\\\\tom\\\\documents\\\\sofagym-main\\\\sofagym\\\\envs\\\\Trunk/Results/Trunk', 'planning': False, 'discrete': True, 'seed': None, 'start_from_history': None, 'python_version': 'python3', 'dt': 0.01, 'save_path_image': None, 'save_path_results': None, 'goal_node': 1, 'goalPos': [-10, 20, 80]}", '16', '62505']' returned non-zero exit status 3.
Maze env outputs an error :
[ERROR] [SofaRuntime] AttributeError: Unable to find attribute: addNewData
Traceback (most recent call last):
File "/home/hunoutl/SOFA/SofaGym/sofagym/rpc_client.py", line 174, in <module>
root = init_simulation(config, _startCmd, mode='simu')
File "/home/hunoutl/SOFA/SofaGym/sofagym/simulate.py", line 49, in init_simulation
create_scene(root, config, mode = mode)
File "/home/hunoutl/SOFA/SofaGym/sofagym/envs/Maze/MazeScene.py", line 201, in createScene
tripod = Tripod(scene.Modelling)
File "/home/hunoutl/SOFA/sofa/build/sofa_gym_v2212/lib/python3/site-packages/splib3/objectmodel/__init__.py", line 47, in __call__
o = self.cls(*args, **kwargs)
File "/home/hunoutl/SOFA/SofaGym/sofagym/envs/Maze/MazeScene.py", line 63, in __init__
arm = ActuatedArm(self.node, name=name,
File "/home/hunoutl/SOFA/sofa/build/sofa_gym_v2212/lib/python3/site-packages/splib3/objectmodel/__init__.py", line 47, in __call__
o = self.cls(*args, **kwargs)
File "/home/hunoutl/SOFA/SofaGym/sofagym/envs/Maze/actuatedarm.py", line 70, in __init__
self.servomotor = ServoMotor(self.node, translation=translation, rotation=eulerRotation, indice=int(name[-1]))
File "/home/hunoutl/SOFA/sofa/build/sofa_gym_v2212/lib/python3/site-packages/splib3/objectmodel/__init__.py", line 49, in __call__
o.node.addNewData("Prefab type", "Infos", "","string", str(o.__class__.__name__))
This comes from sofa prefab obviously when applied to class ServoMotor(SofaObject)
Make SOFA binary and test code with binary
Need to add a SOFA Binary with compiled plugins to allow to test the code and free users from compiling SOFA from scratch
Needed plugins:
SP3
STLIB
SoftRobots
SoftRobots.Inverse
BeamAdapter
Cosserat
MOR
Add reference to AVEC code and stop porting it here
Hi!
I have installed SOFA v22.12 on a virtual machine with Ubuntu 22.04LTS.
I am trying to run the example test script and it throws an error I am not sure how to fix:
(sofa) vboxuser@Sofa:~/Downloads/SofaGym$ python test_env.py -e trunk-v0 -ep 100 -s 100 --------------------------------------- Checking SOFA_ROOT and SOFAPYTHON3_ROOT Using environment variable SOFA_ROOT: /home/vboxuser/SOFA/v22.12.00 --------------------------------------- pygame 2.5.0 (SDL 2.28.0, Python 3.8.17) Hello from the pygame community. https://www.pygame.org/contribute.html [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.so 56975 /home/vboxuser/anaconda3/envs/sofa/lib/python3.8/site-packages/gym/spaces/box.py:73: UserWarning: WARN: Box bound precision lowered by casting to float32 logger.warn( Start env trunk-v0 --------------------------------------- Checking SOFA_ROOT and SOFAPYTHON3_ROOT Using environment variable SOFA_ROOT: /home/vboxuser/SOFA/v22.12.00 --------------------------------------- pygame 2.5.0 (SDL 2.28.0, Python 3.8.17) Hello from the pygame community. https://www.pygame.org/contribute.html [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/plugins/STLIB/lib/libSTLIB.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/plugins/SoftRobots/lib/libSoftRobots.so [DEPRECATED] [SofaSparseSolver] SofaSparseSolver is deprecated. It will be removed at v23.06. Use Sofa.Component.LinearSolver.Direct instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.LinearSolver.Direct.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaSparseSolver/lib/libSofaSparseSolver.so [DEPRECATED] [SofaPreconditioner] SofaPreconditioner is deprecated. It will be removed at v23.06. Use Sofa.Component.LinearSolver.Preconditioner and Sofa.Component.LinearSolver.Iterative instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.LinearSolver.Preconditioner.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.LinearSolver.Iterative.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaPreconditioner/lib/libSofaPreconditioner.so [INFO] [SofaPython3] Initializing with python version 3.8.17 (default, Jul 5 2023, 21:04:15) [GCC 11.2.0] [INFO] [SofaPython3] Shared library name is 'libpython3.8m.so' [INFO] [SofaPython3] Added '/home/vboxuser/SOFA/v22.12.00/plugins/SofaPython3/lib/python3/site-packages' to sys.path [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/plugins/SofaPython3/lib/libSofaPython3.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/plugins/BeamAdapter/lib/libBeamAdapter.so [DEPRECATED] [SofaOpenglVisual] SofaOpenglVisual is deprecated;. Use Sofa.GL.Component.Rendering2D, Sofa.GL.Component.Rendering3D and Sofa.GL.Component.Shader instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.GL.Component.Rendering2D.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.GL.Component.Rendering3D.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.GL.Component.Shader.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaOpenglVisual/lib/libSofaOpenglVisual.so [DEPRECATED] [SofaMiscCollision] SofaMiscCollision is deprecated. It will be removed at v23.06. Use Sofa.Component.Collision.Geometry, Sofa.Component.Collision.Detection.Intersection and Sofa.Component.Collision.Response.Contact instead. [DEPRECATED] [SofaMiscCollision] If you are looking for OBB and Capsule-related components, please use the external plugin CollisionOBBCapsule. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Collision.Geometry.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Collision.Detection.Intersection.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Collision.Response.Contact.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaMiscCollision/lib/libSofaMiscCollision.so [DEPRECATED] [SofaBoundaryCondition] SofaBoundaryCondition is deprecated. It will be removed at v23.06. You may use Sofa.Component.Constraint.Projective and Sofa.Component.MechanicalLoad instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Constraint.Projective.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.MechanicalLoad.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaBoundaryCondition/lib/libSofaBoundaryCondition.so [DEPRECATED] [SofaConstraint] SofaConstraint is deprecated. It will be removed at v23.06. You may use Sofa.Component.Mapping.MappedMatrix, Sofa.Component.Constraint.Lagrangian.Model, Sofa.Component.Constraint.Lagrangian.Correction, Sofa.Component.Constraint.Lagrangian.Solver, Sofa.Component.AnimationLoop, Sofa.Component.Collision.Detection.Intersection and Sofa.Component.Collision.Response.Contact instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Mapping.MappedMatrix.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Constraint.Lagrangian.Model.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Constraint.Lagrangian.Correction.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Constraint.Lagrangian.Solver.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.AnimationLoop.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaConstraint/lib/libSofaConstraint.so [DEPRECATED] [SofaEngine] SofaEngine is deprecated. It will be removed at v23.06. Use Sofa.Component.Engine.Select instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Engine.Select.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaEngine/lib/libSofaEngine.so [DEPRECATED] [SofaImplicitOdeSolver] SofaImplicitOdeSolver is deprecated. It will be removed at v23.06. Use Sofa.Component.ODESolver.Backward instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.ODESolver.Backward.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaImplicitOdeSolver/lib/libSofaImplicitOdeSolver.so [DEPRECATED] [SofaLoader] SofaLoader is deprecated. It will be removed at v23.06. Use Sofa.Component.IO.Mesh instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.IO.Mesh.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaLoader/lib/libSofaLoader.so [DEPRECATED] [SofaSimpleFem] SofaSimpleFem is deprecated;. It will be removed at v23.06. You may use Sofa.Component.Diffusion and Sofa.Component.SolidMechanics.FEM.Elastic instead. [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.Diffusion.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/lib/libSofa.Component.SolidMechanics.FEM.Elastic.so [INFO] [PluginManager] Loaded plugin: /home/vboxuser/SOFA/v22.12.00/collections/SofaSimpleFem/lib/libSofaSimpleFem.so [WARNING] [GenericConstraintCorrection(unnamed)] String data "solverName" is now replaced by explicit data link: "linearSolver" (PR #3152) [DEPRECATED] [BruteForceDetection(BruteForceDetection)] As a replacement, use a BroadPhase component, such as [BruteForceBroadPhase, IncrSAP], AND a NarrowPhase component, such as [BVHNarrowPhase, DirectSAPNarrowPhase, IncrSAP, RayTraceNarrowPhase]. BruteForceBroadPhase and BVHNarrowPhase have been automatically added to your scene for backward compatibility. libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri) libGL error: failed to load driver: swrast X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 148 (GLX) Minor opcode of failed request: 3 (X_GLXCreateContext) Value in failed request: 0x0 Serial number of failed request: 106 Current serial number in output stream: 107 (sofa) vboxuser@Sofa:~/Downloads/SofaGym$ [ERROR] [SofaRuntime] ConnectionRefusedError: [Errno 111] Connection refused Traceback (most recent call last): File "/home/vboxuser/Downloads/SofaGym/sofagym/rpc_client.py", line 181, in <module> task = s.getNextTask(stateId) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/xmlrpc/client.py", line 1109, in __call__ return self.__send(self.__name, args) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/xmlrpc/client.py", line 1450, in __request response = self.__transport.request( File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/xmlrpc/client.py", line 1153, in request return self.single_request(host, handler, request_body, verbose) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/xmlrpc/client.py", line 1165, in single_request http_conn = self.send_request(host, handler, request_body, verbose) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/xmlrpc/client.py", line 1278, in send_request self.send_content(connection, request_body) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/xmlrpc/client.py", line 1308, in send_content connection.endheaders(request_body) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/http/client.py", line 1251, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/http/client.py", line 1011, in _send_output self.send(msg) File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/http/client.py", line 951, in send self.connect() File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/http/client.py", line 922, in connect self.sock = self._create_connection( File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/socket.py", line 808, in create_connection raise err File "/home/vboxuser/anaconda3/envs/sofa/lib/python3.8/socket.py", line 796, in create_connection sock.connect(sa)
Hi! I built a environment and noticed that when the step(action)
function of my environment is called, it actually executes the action twice. I suspect that the problem is with the following code in the function startCmd_EnvName
in the toolbox file:
rootNode.AnimationManager.addAnimation( Animation( onUpdate=executeAnimation, params={"cable": cable, "displacement": displacement}, duration=duration, mode="once"))
I noticed that increasing the value of the variable duration
increases the number of times the action gets executed, and that the number of times the action gets executed depends on environments (For instance, in the Trunk
environment, its displace
function gets called 5 times everytime the function startCmd_Trunk
gets called, but in CartPole
, the function apply_action
gets called 10 times). Could anyone please explain the design idea behind this? Should I setup my environment such that the action is only executed once everytime I call the step
function? If so, how? Thank you!
Hi all, I just installed SofaGym. I tried to run the test_env.py file and got this error:
Traceback (most recent call last):
File "test_env.py", line 23, in
from sofagym.envs import *
File "/home/william/SofaGym/sofagym/envs/init.py", line 1, in
from sofagym.envs.BubbleMotion.BubbleMotionEnv import *
File "/home/william/SofaGym/sofagym/envs/BubbleMotion/BubbleMotionEnv.py", line 11, in
from sofagym.AbstractEnv import AbstractEnv
File "/home/william/SofaGym/sofagym/AbstractEnv.py", line 20, in
import splib3
ModuleNotFoundError: No module named 'splib3'
I have installed all the plugins listed in README. Any idea how I should fix this? Thank you!
Current configuration:
Ubuntu 20.04
Sofa v23.06.00 (From Binary)
Python 3.8.10
When running example (python test_env.py -e concentrictuberobot-v0 -ep 100 -s 100), simulation runs successfully, but when throws this error when training (python rl.py -e concentrictuberobot-v0 -a DQN)
[SofaRuntime] UFuncTypeError: ufunc 'subtract' did not contain a loop with signature matching types (dtype('<U1'), dtype('float64')) -> None
Traceback (most recent call last):
File "rl.py", line 114, in <module>
agent.fit(total_timesteps)
File "/home/ubuntu20_sofa/SofaGym/agents/SB3Agent.py", line 309, in fit
self.model.learn(total_timesteps=total_timesteps, reset_num_timesteps=False,
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/dqn/dqn.py", line 265, in learn
return super().learn(
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/off_policy_algorithm.py", line 334, in learn
rollout = self.collect_rollouts(
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/off_policy_algorithm.py", line 567, in collect_rollouts
new_obs, rewards, dones, infos = env.step(actions)
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/base_vec_env.py", line 163, in step
return self.step_wait()
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_monitor.py", line 76, in step_wait
obs, rewards, dones, infos = self.venv.step_wait()
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_normalize.py", line 197, in step_wait
infos[idx]["terminal_observation"] = self.normalize_obs(infos[idx]["terminal_observation"])
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_normalize.py", line 240, in normalize_obs
obs_ = self._normalize_obs(obs, self.obs_rms).astype(np.float32)
File "/home/ubuntu20_sofa/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vec_normalize.py", line 216, in _normalize_obs
return np.clip((obs - obs_rms.mean) / np.sqrt(obs_rms.var + self.epsilon), -self.clip_obs, self.clip_obs)
Any advice here? I'm pretty sure that I have installed all of the dependencies correctly according to the readme, and this issue is confirmed on multiple installs/machines.
There's an issue in the environments' gui when the render argument is activated, the simulation window crashes with this error:
/home/samuelyoussef/.local/lib/python3.10/site-packages/glfw/__init__.py:916: GLFWError: (65544) b'EGL: Failed to make context current: EGL cannot access a requested resource'
warnings.warn(message, GLFWError)
########## SIG 11 - SIGSEGV: segfault ##########
sofa::helper::BackTrace::sig(int)
glfwCreateWindow
_PyObject_MakeTpCall
_PyEval_EvalFrameDefault
_PyFunction_Vectorcall
_PyEval_EvalFrameDefault
_PyFunction_Vectorcall
_PyObject_FastCallDictTstate
_PyObject_MakeTpCall
_PyEval_EvalFrameDefault
_PyEval_EvalFrameDefault
_PyEval_EvalFrameDefault
PyEval_EvalCode
_PyRun_SimpleFileObject
_PyRun_AnyFileObject
Py_RunMain
Py_BytesMain
__libc_start_main
_start
Segmentation fault (core dumped)
[ERROR] [SofaRuntime] ConnectionRefusedError: [Errno 111] Connection refused
Traceback (most recent call last):
File "/home/samuelyoussef/Documents/SOFA/Plugins/SofaGym/sofagym/rpc_client.py", line 181, in <module>
task = s.getNextTask(stateId)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1122, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1464, in __request
response = self.__transport.request(
File "/usr/lib/python3.10/xmlrpc/client.py", line 1166, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1178, in single_request
http_conn = self.send_request(host, handler, request_body, verbose)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1291, in send_request
self.send_content(connection, request_body)
File "/usr/lib/python3.10/xmlrpc/client.py", line 1321, in send_content
connection.endheaders(request_body)
File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
self.send(msg)
File "/usr/lib/python3.10/http/client.py", line 975, in send
self.connect()
File "/usr/lib/python3.10/http/client.py", line 941, in connect
self.sock = self._create_connection(
File "/usr/lib/python3.10/socket.py", line 845, in create_connection
raise err
File "/usr/lib/python3.10/socket.py", line 833, in create_connection
sock.connect(sa)
I temporarily fixed the issue by moving the glfw create window function before the pygame initialization
Lines 101 to 105 in 5f4a017
now the rendering is working but the simulation window keeps showing a not responding message while running.
Unsure if this is caused by an issue related to #58, but after a seemingly arbitrary number of steps (~60k) in a slightly modified version of the CatheterBeam example, I see this error:
[WARNING] [LCPConstraintSolver(LCPConstraintSolver)] No convergence in unbuilt nlcp gaussseidel function : error =0.000597259 after 1000 iterations
Process ForkServerProcess-3:
Traceback (most recent call last):
File "/usr/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/rbasdeo/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/subproc_vec_env.py", line 34, in _worker
observation = env.reset()
File "/home/rbasdeo/.local/lib/python3.8/site-packages/gym/wrappers/time_limit.py", line 27, in reset
return self.env.reset(**kwargs)
File "/home/rbasdeo/.local/lib/python3.8/site-packages/gym/wrappers/order_enforcing.py", line 16, in reset
return self.env.reset(**kwargs)
File "/home/rbasdeo/sofaGym/sofaGym_catheter/sofagym/envs/CatheterBeamSingle/CatheterBeamSingleEnv.py", line 75, in reset
super().reset()
File "/home/rbasdeo/sofaGym/sofaGym_catheter/sofagym/AbstractEnv.py", line 380, in reset
self.clean()
File "/home/rbasdeo/sofaGym/sofaGym_catheter/sofagym/AbstractEnv.py", line 276, in clean
clean_registry(self.past_actions)
File "/home/rbasdeo/sofaGym/sofaGym_catheter/sofagym/rpc_server.py", line 539, in clean_registry
actions_to_stateId.pop(str(instances[id]['history']))
KeyError: 'history'
Stable_baselines params:
DQN:
init_kwargs:
policy: 'MlpPolicy'
learning_rate: 0.0005
buffer_size: 4000
learning_starts: 1000
batch_size: 32
gamma: 1.0
train_freq: (1, 'step')
gradient_steps: 1
replay_buffer_class: null
replay_buffer_kwargs: null
optimize_memory_usage: False
target_update_interval: 500
exploration_fraction: 0.1
exploration_initial_eps: 1.0
exploration_final_eps: 0.02
max_grad_norm: 10
policy_kwargs: "dict(net_arch=[128, 128], optimizer_class=th.optim.Adam)"
device: "auto"
fit_kwargs:
total_timesteps: 3200000
max_episode_steps: 300
eval_freq: 10000
n_eval_episodes: 10
save_freq: 10000
video_length: 500
I am running a simple code like
import gym import sofagym.envs env = gym.make('trunk-v0') env.reset()
The I get the Error like:
[ERROR] [SofaRuntime] ConnectionRefusedError: [Errno 111] Connection refused
How can I fix it? Thanks.
SimpleMaze contains components that have been removed from Sofa.
I tried some tweaks on the sphere object but it wasn't great and this is only the 1st mistake of this type. I think this scene has others.
The error output:
[ERROR] [SofaRuntime] ValueError: Object type Sphere<> was not created
The object is not in the factory.
This component has been REMOVED since SOFA v20.06 (deprecated since v19.12). Please consider updating your scene. If this component is crucial to you please report that to sofa-dev@ so that we can reconsider this component for future re-integration.
Traceback (most recent call last):
File "/home/hunoutl/SOFA/SofaGym/sofagym/rpc_client.py", line 174, in <module>
root = init_simulation(config, _startCmd, mode='simu')
File "/home/hunoutl/SOFA/SofaGym/sofagym/simulate.py", line 49, in init_simulation
create_scene(root, config, mode = mode)
File "/home/hunoutl/SOFA/SofaGym/sofagym/envs/SimpleMaze/SimpleMazeScene.py", line 86, in createScene
sphere.addObject("Sphere", radius='2.0', name='0', color=[255, 0, 0, 255])
[ERROR] [SofaRuntime] ValueError: Object type Triangle<> was not created
The object is not in the factory.
This component has been REMOVED since SOFA v20.06 (deprecated since v19.12). Please consider updating your scene. If this component is crucial to you please report that to sofa-dev@ so that we can reconsider this component for future re-integration.
Traceback (most recent call last):
File "/home/hunoutl/SOFA/SofaGym/sofagym/rpc_client.py", line 174, in <module>
root = init_simulation(config, _startCmd, mode='simu')
File "/home/hunoutl/SOFA/SofaGym/sofagym/simulate.py", line 49, in init_simulation
create_scene(root, config, mode = mode)
File "/home/hunoutl/SOFA/SofaGym/sofagym/envs/SimpleMaze/SimpleMazeScene.py", line 118, in createScene
maze.addObject("Triangle", group=1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.