SofaDefrost / SofaGym

Machine Learning framework for Sofa
72 stars 10 forks source link

GL Error #23

Closed Barbany closed 1 year ago

Barbany commented 1 year ago

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 Animationin splib3.animation.animete changed and now requires a realTimeClock boolean as argument.

EtienneMenager commented 1 year ago

Hi,

It seems to be a problem with the visualization. We made some changes in the last RP last night. Can you update and test to see if the problem still exists?

Cheers,

Etienne

Barbany commented 1 year ago

Thanks for your solutions! It looks like it works so I'll close the issue.

Just for the record and in case it is useful for you: I had to do some modifications for the code to work:

  1. Changing splib to splib3 to use the package inside https://github.com/SofaDefrost/STLIB.
  2. LightManager has been moved from SofaOpenglVisual to Sofa.GL.Component.Shader since SOFA v22.06. So I added 'Sofa.GL.Component.Shader' to the RequiredPlugin loaded in sofagym/header.py. With these changes the simulation seems to work (example with cartstemcontact-v0`): github However, I get the following error
    
    [ERROR]   [RequiredPlugin(SofaPlugins)] Plugin not found: "SofaGeneralRigid"                             
    Plugin not found: "SofaSparseSolver"                                                                     
    Plugin not found: "SofaSimpleFem"                                                                        
    Plugin not found: "SofaTopologyMapping"                                                                  
    Plugin not found: "SofaEngine"                                                                           
    Plugin not found: "SofaGeneralLinearSolver"                                                              
    Plugin not found: "SofaRigid"                                                                            
    Plugin not found: "SofaGeneralAnimationLoop"                                                             
    Plugin not found: "SofaBoundaryCondition"                                                                
    Plugin not found: "SofaConstraint"                                                                       
    Plugin not found: "SofaMiscCollision"                                                                    
    Plugin not found: "SofaPreconditioner"                                                                   
    Plugin not found: "SofaDeformable"                                                                       
    Plugin not found: "SofaGeneralEngine"                                                                    
    Plugin not found: "SofaImplicitOdeSolver"                                                                
    Plugin not found: "SofaMeshCollision"                                                                    
    Plugin not found: "SofaOpenglVisual"                                                                     
    Plugin not found: "SofaLoader"                                                                           
    Plugin not found: "SofaGeneralLoader"                                                                    

Failed to load: ["SofaGeneralRigid", "SofaSparseSolver", "SofaSimpleFem", "SofaTopologyMapping", "SofaEngine", "SofaGeneralLinearSolver", "SofaRigid", "SofaGeneralAnimationLoop", "SofaBoundaryCondition", "SofaCo nstraint", "SofaMiscCollision", "SofaPreconditioner", "SofaDeformable", "SofaGeneralEngine", "SofaImplicitOdeSolver", "SofaMeshCollision", "SofaOpenglVisual", "SofaLoader", "SofaGeneralLoader"]

Removing all packages in RequiredPlugin of `sofagym/header.py` except the Shader added in (2) seems to have no effect in the simulation and get rid of the command line error.

Besides, I also got:

[ERROR] [RequiredPlugin(SofaPlugins)] Plugin not found: "SofaRigid"
Plugin not found: "SofaLoader"

Failed to load: ["SofaRigid", "SofaLoader"]
[ERROR] [SofaRuntime] ValueError: Object type BeamHookeLawForceField<> was not created
The object 'BeamHookeLawForceField' is not in the factory.
But the following exits:
: BeamFEMForceField (71% match)
: LinearForceField (63% match)
: SphereForceField (63% match)
: HexahedralFEMForceField (62% match)
: TorsionForceField (61% match)
: FrameSpringForceField (60% match)

which I solved by doing the change: