ami-iit / jaxsim

A differentiable physics engine and multibody dynamics library for control and robot learning.
https://jaxsim.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
57 stars 9 forks source link

Restore Colab support for example notebooks #154

Closed flferretti closed 1 month ago

flferretti commented 1 month ago

This PR restore the support for Google Colab for the example notebooks previously removed in #152.


📚 Documentation preview 📚: https://jaxsim--154.org.readthedocs.build//154/

flferretti commented 1 month ago

I had a small issue on the visualization that has been solved in https://github.com/ami-iit/jaxsim/pull/154/commits/bea65bc1a7ac331ae52a2219fe02e58fe3406a30. Apparently in Colab, libGL requires a DISPLAY environment variable to be set. For this reason I used xvfb to create a dummy one.

Ready for review

traversaro commented 1 month ago

Apparently in Colab, libGL requires a DISPLAY environment variable to be set. For this reason I used xvfb to create a dummy one.

That is strange, as long as you use egl that should not be necessary. Not blocking the PR, but what was the error?

flferretti commented 1 month ago

Apparently in Colab, libGL requires a DISPLAY environment variable to be set. For this reason I used xvfb to create a dummy one.

That is strange, as long as you use egl that should not be necessary. Not blocking the PR, but what was the error?

image

traversaro commented 1 month ago

Thanks, I wonder why this is not happening in official mujoco colabs. Anyhow, no problem.

flferretti commented 1 month ago

Thanks, I wonder why this is not happening in official mujoco colabs. Anyhow, no problem.

I have no idea to be honest, I have also seen that in Mujoco it works

traversaro commented 1 month ago

Thanks, I wonder why this is not happening in official mujoco colabs. Anyhow, no problem.

I have no idea to be honest, I have also seen that in Mujoco it works

Probably the difference is due to the fact that glfw is also installed or somehow is selected as backend?

traversaro commented 1 month ago

Thanks, I wonder why this is not happening in official mujoco colabs. Anyhow, no problem.

I have no idea to be honest, I have also seen that in Mujoco it works

Probably the difference is due to the fact that glfw is also installed or somehow is selected as backend?

I think I got it. MUJOCO_GL=egl should be set before the first import mujoco , as MUJOCO_GL is used in the import code, see https://github.com/google-deepmind/mujoco/blob/2f19941fcfb2b5c87f0832b88cabb551cb6deb56/python/mujoco/__init__.py#L47 and https://github.com/google-deepmind/mujoco/blob/2f19941fcfb2b5c87f0832b88cabb551cb6deb56/python/mujoco/gl_context.py . If we more MUJOCO_GL=egl earlier I guess there will be no need for creating a fake X server.