Difference between revisions of "MuJoCo WASM"

From Humanoid Robots Wiki
Jump to: navigation, search
(Update build instructions)
Line 1: Line 1:
 
== Building ==
 
== Building ==
 +
 
=== 1. Install emscripten ===
 
=== 1. Install emscripten ===
 
First, you need to install emscripten, which is a compiler toolchain for WebAssembly.
 
First, you need to install emscripten, which is a compiler toolchain for WebAssembly.
  
==== 1.1. Get the emsdk repo ====
+
==== Get the emsdk repo ====
 
<code>
 
<code>
 
git clone https://github.com/emscripten-core/emsdk.git
 
git clone https://github.com/emscripten-core/emsdk.git
 
</code>
 
</code>
  
==== 1.2. Enter that directory ====
+
==== Enter that directory ====
 
<code>
 
<code>
 
cd emsdk
 
cd emsdk
 
</code>
 
</code>
  
==== 1.3. Download and install the latest SDK tools ====
+
==== Download and install the latest SDK tools ====
 
<code>
 
<code>
 
./emsdk install latest
 
./emsdk install latest
 
</code>
 
</code>
  
==== 1.4. Make the "latest" SDK "active" ====
+
==== Make the "latest" SDK "active" ====
 
<code>
 
<code>
 
./emsdk activate latest
 
./emsdk activate latest
 
</code>
 
</code>
  
==== 1.5. Activate PATH and other environment variables ====
+
==== Activate PATH and other environment variables ====
 
<code>
 
<code>
 
source ./emsdk_env.sh
 
source ./emsdk_env.sh
Line 31: Line 32:
  
 
The environment variables:
 
The environment variables:
 
 
<code>
 
<code>
 
EMSDK = < path to emsdk dir >
 
EMSDK = < path to emsdk dir >
Line 40: Line 40:
 
</code>
 
</code>
  
==== 1.6. Now just try it! ====
+
==== Now just try it! ====
 
<code>
 
<code>
 
emcc
 
emcc
Line 48: Line 48:
 
<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>
 +
 +
=== 2. Build the mujoco_wasm Binary ===
 +
Next, you'll build the MuJoCo WebAssembly binary.
 +
 +
==== On Linux ====
 +
<code>
 +
mkdir build
 +
cd build
 +
emcmake cmake ..
 +
make
 
</code>
 
</code>
  

Revision as of 19:40, 19 May 2024

Building

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

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

2. Build the mujoco_wasm Binary

Next, you'll build the MuJoCo WebAssembly binary.

On Linux

mkdir build cd build emcmake cmake .. make


2. Build the mujoco_wasm Binary

Next, you'll build the MuJoCo WebAssembly binary.

On Linux

mkdir build cd build emcmake cmake .. make