diff --git a/Dockerfile b/Dockerfile index 86c6b82..7ed7e47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ -# FROM ubuntu:16.04 -# FROM ubuntu:18.04 -FROM autoware/autoware:1.13.0-melodic-cuda +FROM ubuntu:18.04 # Make all NVIDIA GPUS visible, but I want to manually install drivers ARG NVIDIA_VISIBLE_DEVICES=all @@ -115,16 +113,11 @@ rm -rf /var/lib/apt/lists/* # sound driver and GTK library -# ALSA系のエラーがでる時は、pulseaudioをインストールして -# X起動後にpulseaudio --start でdaemonを開始させる。 +# If you want to use sounds on docker, try `pulseaudio --start` RUN apt-get update && apt-get install -y --no-install-recommends \ alsa pulseaudio libgtk2.0-0 && \ - # alsa pulseaudio && \ rm -rf /var/lib/apt/lists/* -USER root -WORKDIR / - # novnc # download websockify as well RUN wget https://github.com/novnc/noVNC/archive/v1.1.0.zip && \ @@ -140,31 +133,6 @@ libdbus-c++-1-0v5 && \ rm -rf /var/lib/apt/lists/* -# install nodejs and npm -# https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04 -RUN curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh \ - && bash nodesource_setup.sh \ - && apt-get update \ - && apt-get install nodejs - -COPY control.js /simlauncher/ -COPY package.json /simlauncher/ -WORKDIR /simlauncher -RUN npm install -WORKDIR / - -RUN apt-get update && apt-get install -y --no-install-recommends \ - xdotool && \ - rm -rf /var/lib/apt/lists/* - -# setup python api -WORKDIR / -RUN git clone https://github.com/lgsvl/PythonAPI \ - && cd PythonAPI \ - && pip3 install --user -e . - -COPY test-api-move.py /api.py - # (3) Run Xorg server + x11vnc + X applications # see run.sh for details COPY run.sh /run.sh diff --git a/README.md b/README.md index c0e7086..a96ae11 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,18 @@ 具体的には、Unityで作られたソフト本体の自動テスト環境やそれを使ったCI環境を、GPUインスタンスを含んだkubernetesクラスタ上に構築したい時に使える。 + +## Update: support AWS and noVNC + +- AWSのg4インスタンスでの動作を確認しました。 +- noVNCを使用しブラウザからアクセスできるようにしました。 + +実行するには: +``` +bash server.sh +``` + + ## Background 自動テストサーバーを作るために、 https://github.com/lgsvl/simulator をKubernetes上で動かしたかった。 diff --git a/control.js b/control.js deleted file mode 100644 index 8e57963..0000000 --- a/control.js +++ /dev/null @@ -1,52 +0,0 @@ -const axios = require('axios') -const request = require('request') -const client = axios.create({ - baseURL: 'http://localhost:8082', - responseType: 'json', - withCredentials: true, -}) -const username = process.env.LG_USERNAME -const password = process.env.LG_PASSWORD - -function control_simulation (mode) { - return new Promise((resolve, reject) => { - const source = axios.CancelToken.source() - request.post({ - uri: 'https://account.lgsvlsimulator.com/users/signin', - headers: {'Content-Type': 'application/json'}, - json: { - 'username': username, - 'password': password, - } - }, (err, res, data) => { - const token = data.token - client.put(`/users/${encodeURIComponent(token)}`) - .then(res => { - const cook = res.headers['set-cookie'][0].split(';')[0] - client.request({ - method: 'post', - cancelToken: source.token, - url: mode === 'stop' ? '/simulations/5/stop' : '/simulations/5/start', - headers: { - Cookie: cook - }, - }) - .then(res => { - console.log('done', res.data) - resolve() - }) - .catch(err => { - console.log('error', err) - reject(err) - }) - }) - }) - }) -} - -control_simulation('start') - .then((res) => { console.log('kicked') }) - -module.exports = { - control_simulation, -} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 704b8df..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -# WIP -version: '3' -services: - x11gl: - build: . - runtime: nvidia - command: /bin/bash - ports: - - "8080:8080" # aaa - environment: - - BUSID: PCI:0:4:0 - - SCREEN_RESOLUTION: 1280x1024 - - VNC_PASSWORD: ryought - privileged: true - autoware: - image: autoware/autoware:latest-kinetic diff --git a/local.sh b/local.sh deleted file mode 100644 index f8a5191..0000000 --- a/local.sh +++ /dev/null @@ -1 +0,0 @@ -ssh -i "$KEYFILE" -L 5900:localhost:5900 $USERNAME@$GCP_PUBLIC_IP -N diff --git a/package.json b/package.json deleted file mode 100644 index 8fd32f8..0000000 --- a/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "simulator", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "axios": "^0.19.0", - "axios-cookiejar-support": "^0.5.0", - "express": "^4.17.1", - "request": "^2.88.0" - } -} diff --git a/run.sh b/run.sh index 42cf007..a3d37a9 100644 --- a/run.sh +++ b/run.sh @@ -1,77 +1,30 @@ # inside docker script -trap 'sudo kill $(jobs -p)' EXIT +trap 'kill $(jobs -p)' EXIT -# 0. generate xorg.conf if not copied -# [ ! -e /etc/X11/xorg.conf ] && nvidia-xconfig -a --virtual=$SCREEN_RESOLUTION --allow-empty-initial-configuration --enable-all-gpus --busid $BUSID -# nvidia-xconfig -a --virtual=800x600 --allow-empty-initial-configuration --enable-all-gpus --busid 0:4:0 +# 0. generate xorg.conf BUS_ID=$(nvidia-xconfig --query-gpu-info | grep 'PCI BusID' | sed -r 's/\s*PCI BusID : PCI:(.*)/\1/') -echo $BUS_ID -sudo nvidia-xconfig -a --virtual=1280x720 --allow-empty-initial-configuration --enable-all-gpus --busid $BUS_ID +nvidia-xconfig -a --virtual=$RESOLUTION --allow-empty-initial-configuration --enable-all-gpus --busid $BUS_ID # 1. launch X server -sudo Xorg :0 & +Xorg :0 & sleep 1 # wait for the server gets ready # 2. start x11 and vnc connection -# --verbose -sudo x11vnc -display :0 -passwd pass -forever -rfbport 5900 & +# to inspect logs in detail, use --verbose +x11vnc -display :0 -passwd $VNCPASS -forever -rfbport 5900 & sleep 2 # wait for the server gets ready # 2.5 start audio # this is not required. -# sudo pulseaudio --start +# pulseaudio --start # sleep 2 # 3. start noVNC -sudo /noVNC-1.1.0/utils/launch.sh --vnc localhost:5900 --listen 8081 & +/noVNC-1.1.0/utils/launch.sh --vnc localhost:5900 --listen 8081 & sleep 2 -# remove sudo group -# gpasswd -d miyazaki unyo - echo 'running noVNC at http://localhost:8081/vnc.html?host=localhost&port=8081' # 3. start simulator export DISPLAY=:0 -# # xeyes -# glxgears -# glxinfo -# vulkan -# firefox -# xterm -# openbox & - -# launch lgsim and its api server -cd /lg -# ./simulator -p 8082 -screen-height 480 -screen-width 640 -screen-quality Beautiful -screen-fullscreen 0 & -./simulator -p 8082 & -sleep 3 -xdotool key Tab -xdotool key Tab -xdotool key Tab -xdotool key Tab -xdotool key Tab -xdotool key Return -sleep 3 - -# kick api mode -node /simlauncher/control.js - -# launch autoware -cd ~/Autoware -. install/setup.bash -roslaunch rosbridge_server rosbridge_websocket.launch & - -sleep 5 -# run simulation -git clone https://github.com/lgsvl/PythonAPI -cd PythonAPI -pip3 install --user -e . -python3 /api.py - -# sleep 10 -# echo 'finishing the simulation' -# echo 'uploading rosbag to S3' - -# wait -# sudo kill $(jobs -p) +openbox diff --git a/server.sh b/server.sh index 6b93e82..e426c2a 100644 --- a/server.sh +++ b/server.sh @@ -2,12 +2,8 @@ docker build -t sim . && \ # docker run --device=/dev/tty0:rw -it --rm --gpus all \ docker run --privileged -it --rm --gpus all \ - -v $HOME/lgsvlsimulator-linux64-2019.11:/lg \ - -v $HOME/container-unity3d-2:/home/autoware/.config/unity3d:rw \ -p 8081:8081 \ - -p 8082:8082 \ - -e USER_ID=$(id -u) \ + -e RESOLUTION=1280x720 \ + -e VNCPASS=pass \ --name sim sim - -# 8081: noVNC port -# 8082: simulator + # -v $HOME/hoge:/hoge:ro \ diff --git a/test-api-move.py b/test-api-move.py deleted file mode 100755 index 89ed828..0000000 --- a/test-api-move.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (c) 2019 LG Electronics, Inc. -# -# This software contains code licensed as described in LICENSE. -# - -import os -import lgsvl - -sim = lgsvl.Simulator(os.environ.get("SIMULATOR_HOST", "127.0.0.1"), 8181) -if sim.current_scene == "BorregasAve": - sim.reset() -else: - sim.load("BorregasAve") - -spawns = sim.get_spawn() - -state = lgsvl.AgentState() -state.transform = spawns[0] -a = sim.add_agent("Lincoln2017MKZ (Apollo 5.0)", lgsvl.AgentType.EGO, state) - -state = lgsvl.AgentState() - -forward = lgsvl.utils.transform_to_forward(spawns[0]) -right = lgsvl.utils.transform_to_right(spawns[0]) - -# 10 meters ahead, on left lane -state.transform.position = spawns[0].position + 10.0 * forward -state.transform.rotation = spawns[0].rotation - -npc1 = sim.add_agent("Sedan", lgsvl.AgentType.NPC, state) - -state = lgsvl.AgentState() - -# 10 meters ahead, on right lane -state.transform.position = spawns[0].position + 4.0 * right + 10.0 * forward -state.transform.rotation = spawns[0].rotation - -npc2 = sim.add_agent("SUV", lgsvl.AgentType.NPC, state) - -# If the passed bool is False, then the NPC will not moved -# The float passed is the maximum speed the NPC will drive -# 11.1 m/s is ~40 km/h -npc1.follow_closest_lane(True, 11.1) - -# 5.6 m/s is ~20 km/h -npc2.follow_closest_lane(True, 5.6) - -sim.run()