-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Wrenjs
This page explains how to compile Wrenjs and test locally the streaming viewer and the animation player.
To compile Wrenjs, you will need:
- Python 3
- Emscripten to compile WREN in webassembly.
- pyclibrary to extract the enumerations and functions' names from the C headers.
On Linux there are two solutions. In both cases you need to restart the terminal after installing the dependencies but before compiling Wrenjs.
- Install the dependencies automatically with
sudo ./scripts/install/linux_optional_compilation_dependencies.sh
from webots home. - Install them manually. To do so, follow these instructions:
Enter the following command in a terminal: pip install pyclibrary
Run the following commands in a terminal:
# 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" for the current user. (writes .emscripten file)
./emsdk activate latest
Add the following line in your .bashrc source "path_to_emsdk_folder/emsdk_env.sh" >/dev/null 2>&1
.
Follow the instructions in the Optional Dependencies for Windows.
Follow the instructions in the Optional Dependencies for MacOS.
Wrenjs is automatically compiled when you execute make
either in Webots home or in webots/src/wren
if all the dependencies are correctly installed.
Warning: if you already make
Webots before installing the dependencies needed for Wrenjs, you will need to make clean
either in Webots home or in webots/src/wren
in order for Wrenjs to be built the next time you execute make
.
To test the streaming viewer:
- Launch webots with --stream option
- Change the link to
https://cyberbotics.com/wwi/wrenjs/WebotsStreaming.js
inwebots/resources/web/streaming_viewer/index.html
to point towards the local file. This file is located inwebots/resources/web/wwi/
. - Change the links in
webots/resources/web/wwi/WebotsStreaming.js
to point towards the local files. The links to change are: wwi.css, enum.js, Wrenjs/, wrenjs.js. Those files are located inwebots/resources/web/wwi/
. - Create a local http server with these instructions. The server should be able to reach webots/resources/web/wwi and webots/resources/web/streaming_viewer.
- Open webots/resources/web/streaming_viewer/index.html in the local server.
To test the animation player you have two solutions
- Change the links in
animation_file_name.html
to point towards the local files. The links to change are: wwi.css, enum.js, Wrenjs/, wrenjs.js and init_animation.js. Those files are located inwebots/resources/web/wwi/
. - Create a local http server with these instructions. The server should be able to reach webots/resources/web/wwi but also the place where the animations files are.
- Open animation_file_name.html in the local server.
- Create a local http server with CORS support that should be able to reach webots/resources/web/wwi. Code example:
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
import sys
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':
test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
- Change the link to
WebotsAnimation
inanimation_file_name.html
to point towards the file on the local server. This file is located inwebots/resources/web/wwi/
. So the resulting link will be for example:http://localhost:8000/wwi/WebotsAnimation.js
- Change the links in
webots/resources/web/wwi/WebotsAnimation.js
to point towards the files on the local server. The links to change are: animation.css, enum.js, Wrenjs/, wrenjs.js and init_animation.js. Those files are located inwebots/resources/web/wwi/
. So the resulting links will be for example:http://localhost:8000/wwi/wrenjs.js
- Open animation_file_name.html. You may need to change the configuration of your browser (instructions here)