SofaDefrost / SofaGym

Machine Learning framework for Sofa
68 stars 10 forks source link

[envs] Maze, sofa prefab error #12

Closed hunoutl closed 1 year ago

hunoutl commented 1 year ago

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)

alxbilger commented 1 year ago

I think addNewData is the old SofaPython2 API, while we now use SofaPython3. Could you try to use addData instead? The doc is here: https://github.com/sofa-framework/SofaPython3/blob/master/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Base_doc.h#L125

hunoutl commented 1 year ago

I think the problem comes from splib like for issue #13. Need investigation

alxbilger commented 1 year ago

Can you try if https://github.com/SofaDefrost/STLIB/pull/92 fixes the problem?