Difference between revisions of "MuJoCo WASM"
(→Build the mujoco_wasm Binary) |
|||
Line 64: | Line 64: | ||
<code> | <code> | ||
./emsdk install 3.1.56 && ./emsdk activate 3.1.56 && source ./emsdk_env.sh | ./emsdk install 3.1.56 && ./emsdk activate 3.1.56 && source ./emsdk_env.sh | ||
+ | </code> | ||
+ | |||
+ | == Running in Browser == | ||
+ | |||
+ | Now just do in the root of your mujoco folder | ||
+ | |||
+ | <code> | ||
+ | python -m http.server 8000 | ||
+ | </code> | ||
+ | |||
+ | Then navigate to: | ||
+ | <code> | ||
+ | http://localhost:8000/index.html | ||
</code> | </code> |
Revision as of 20:33, 19 May 2024
Contents
Install emscripten
First, you need to install emscripten, which is a compiler toolchain for WebAssembly.
Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git
Enter that directory
cd emsdk
Download and install the latest SDK tools
./emsdk install latest
Make the "latest" SDK "active"
./emsdk activate latest
Activate PATH and other environment variables
source ./emsdk_env.sh
These variables are set for the current terminal. If you want to make it for all terminals, you can add them to any terminal profile. Here they are:
The environment variables:
EMSDK = < path to emsdk dir >
EM_CONFIG = ~/.emscripten
EMSDK_NODE = < path to emsdk dir >/node/12.9.1_64bit/bin/node
Now just try it!
emcc
Build the mujoco_wasm Binary
Next, you'll build the MuJoCo WebAssembly binary.
mkdir build
cd build
emcmake cmake ..
make
Tip: If you get an error with "undefined symbol: saveSetjmp/testSetjmp" at the build step, revert to:
./emsdk install 3.1.56 && ./emsdk activate 3.1.56 && source ./emsdk_env.sh
Running in Browser
Now just do in the root of your mujoco folder
python -m http.server 8000
Then navigate to:
http://localhost:8000/index.html