Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions steps to build libraries in lib? #1

Closed
traversaro opened this issue Mar 31, 2023 · 10 comments
Closed

Instructions steps to build libraries in lib? #1

traversaro opened this issue Mar 31, 2023 · 10 comments

Comments

@traversaro
Copy link

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!

@stillonearth
Copy link
Owner

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

@traversaro
Copy link
Author

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.

@stillonearth
Copy link
Owner

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?

@saran-t
Copy link

saran-t commented Mar 31, 2023

@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.

@stillonearth
Copy link
Owner

@saran-t
Copy link

saran-t commented Mar 31, 2023

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?

@traversaro
Copy link
Author

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.

@stillonearth
Copy link
Owner

stillonearth commented Mar 31, 2023

@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.

@stillonearth
Copy link
Owner

stillonearth commented Apr 4, 2023

Here's a MuJoCo commit enabeling WASM build: google-deepmind/mujoco@main...stillonearth:mujoco:main

Here's instruction to reproduce results:

  1. Apply @traversaro PR from 2020 for libccd: Fix configuration with Emscripten danfis/libccd#70
  2. Disable MUJOCO_BUILD_EXAMPLES, MUJOCO_BUILD_SIMULATE, MUJOCO_BUILD_TESTS build targets
  3. Remove warning option -Wno-int-in-bool-context as incompatible with emscripten (I'm still unsure why)
  4. Remove static check in src/engine/engine_collision_driver.c
  5. Add a qsort implementation that will satisfy emscripten google-deepmind/mujoco@main...stillonearth:mujoco:main#diff-5ae9fa0fdfa5ae7f0eece63a8d575b39b05f441f22329f29391efefeb0374bdfR43
  6. Disable lodepng and ability to load PNG textures google-deepmind/mujoco@main...stillonearth:mujoco:main#diff-b2f485c04e8d05263f6dd913ffc1e1f120af813240a61d302ebf98d9ebd857e5R2062

@stillonearth stillonearth reopened this Apr 4, 2023
@traversaro
Copy link
Author

Thanks @stillonearth !

Apply @traversaro PR from 2022 for libccd: danfis/libccd#70

Cool, I had completely forgot that PR. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants