Changes

Jump to: navigation, search

MuJoCo WASM

1,189 bytes added, 23:09, 27 May 2024
no edit summary
== Building == === 1. Install emscripten ===
First, you need to install emscripten, which is a compiler toolchain for WebAssembly.
==== Get the emsdk repo ====
<code>
git clone https://github.com/emscripten-core/emsdk.git
</code>
==== Enter that directory ====
<code>
cd emsdk
</code>
==== Download and install the latest SDK tools ====
<code>
./emsdk install latest
</code>
==== Make the "latest" SDK "active" ====
<code>
./emsdk activate latest
</code>
==== Activate PATH and other environment variables ====
<code>
source ./emsdk_env.sh
</code>
==== Now just try it! ====
<code>
emcc
</code>
 
 
 
== Build the mujoco_wasm Binary ==
 
First git clone
<code> https://github.com/zalo/mujoco_wasm </code>
 
Next, you'll build the MuJoCo WebAssembly binary.
<syntaxhighlight lang="bash">
mkdir build
cd build
emcmake cmake ..
make
</syntaxhighlight>
 
 
 
[[File:Carbon (1).png|800px|thumb|none|emcmake cmake ..]]
 
 
[[File:Carbon (2).png|400px|thumb|none|make]]
'''Tip:''' If you get an error with "undefined symbol: saveSetjmp/testSetjmp" at the build step, revert to:
</code>
==Running in Browser = 2= Run this in your mujoco folder to start a server. Build the mujoco_wasm Binary ===Next, you'll build the MuJoCo WebAssembly binary<code>python -m http.server 8000</code> Then navigate to:
==== On Linux ====
<code>
mkdir buildcd buildemcmake cmake http://localhost:8000/index..makehtml
</code>
[[File:Wasm screenshot13-40-40.png|800px|thumb|none|MuJoCo running in browser]]
== Running in Cloud/Cluster and Viewing on Local Machine ==
Add extra parameter to your ssh command:
=== 2<code>ssh -L 8000:127.0.0. Build 1:8000 my_name@my_cluster_ip</code> Then you can open it on the mujoco_wasm Binary browser on your local machine! ==Adding New Models ==All the models are stored in the folder examples/scenes, as seen below:Next[[File:Example folder.png|400px|thumb|none]]You can add your own model XML and meshes here. For example, you'll build here we add the MuJoCo WebAssembly binarystompy folder.
==== On Linux ====After adding the model files, run
<code>
mkdir buildcd buildemcmake cmake python generate_index..makepy
</code>
to update file indexes.
 
Then copy all the content in <code>index.json</code> to <code> mujocoUtils.js</code>, as shown below:
[[File:Add model1.png|400px|thumb|none]]
 
In the end, again at file <code> mujocoUtils.js</code>, add the name and scene file
[[File:Add model2.png|600px|thumb|none]]
 
Then reload again and you can see new models have been added:
[[File:Add model3.png|800px|thumb|none]]
11
edits

Navigation menu