Closed traversaro closed 1 year ago
I used emscripten to build wasm targets: https://emscripten.org/docs/compiling/Building-Projects.html
I didn't include recipe to reproduce the result, so some tinkering was required to make it work. As far as I can remember it require some monkey patching
As far as I can remember it require some monkey patching
Yes, I was expecting that, that is why I asked if by chance you something of those patches still around. Anyhow, thanks a lot for the info.
I demonstrated that MuJoCo simulations are possible in a browser using a proof of concept. While developing Rust Mujoco bindings and a Bevy plugin, I aimed to target wasm for my Rust project. However, the Rust wasm target and the emscripten wasm target were incompatible. To work around this, I used a separate wasm runtime to communicate with the Rust renderer. Currently, one can compile simulate.c with emscripten to have Mujoco running in a browser. What is your specific use case for this technology?
@stillonearth Can you elaborate on the compilation of simulate
? I'm surprised that this can work given that we're using legacy OpenGL rather than OpenGL ES 2.
@saran-t I may be mistaken but there's limited support for legacy opengl in emscripten https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html#opengl-support-legacy-and-mobile
Here's emscripten headers for glfw https://github.com/emscripten-core/emscripten/blob/main/system/include/GL/glfw.h
This is new and exciting, I'm reasonably sure last time I looked this wasn't a thing :)
Do you have a screenshot/video capture of what it looks like when simulate
is running in the browser?
What is your specific use case for this technology?
I work in a research instution, so long term it would be cool to have demos like https://kevinzakka.github.io/robopianist-demo/ . However, tipically our demos have several non-trivial C++ dependencies, a bit like the one of mujoco that you have in https://github.com/stillonearth/MuJoCo-WASM/tree/main/lib . That is why I was curious if there was some script ready to use to compile more libraries and put them in https://github.com/stillonearth/MuJoCo-WASM/tree/main/lib, but if the process was done manually I completely get why there is no such script.
@saran-t no, in fact I didn't compile simulate.c, but I was under impression that it's doable @traversaro I could try to make a CI script for MuJoCo to reproduce the binaries early next week.
Here's a MuJoCo commit enabeling WASM build: https://github.com/deepmind/mujoco/compare/main...stillonearth:mujoco:main
Here's instruction to reproduce results:
MUJOCO_BUILD_EXAMPLES
, MUJOCO_BUILD_SIMULATE
, MUJOCO_BUILD_TESTS
build targets-Wno-int-in-bool-context
as incompatible with emscripten (I'm still unsure why)Thanks @stillonearth !
Apply @traversaro PR from 2022 for libccd: https://github.com/danfis/libccd/pull/70
Cool, I had completely forgot that PR. :D
Hello @stillonearth, thanks a lot for great work! I was wondering if somewhere you have the instructions that you used to build the libraries in https://github.com/zalo/mujoco_wasm/tree/main/lib. Thanks a lot in advance!