Skip to content

Commit 1f57e91

Browse files
committed
Update launcher_o3de_api.py
1 parent e9884a9 commit 1f57e91

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

manager/manager/launcher/launcher_o3de_api.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
from manager.manager.launcher.launcher_interface import ILauncher, LauncherException
88
from manager.manager.docker_thread.docker_thread import DockerThread
9+
from manager.manager.vnc.vnc_server import Vnc_server
10+
from manager.libs.process_utils import (
11+
wait_for_process_to_start,
12+
check_gpu_acceleration,
13+
)
914
import subprocess
1015

1116
import logging
@@ -16,14 +21,41 @@ class LauncherO3deApi(ILauncher):
1621
module: str
1722
launch_file: str
1823
threads: List[Any] = []
24+
gz_vnc: Any = Vnc_server()
1925

2026
def run(self, callback):
2127
DRI_PATH = self.get_dri_path()
2228
ACCELERATION_ENABLED = self.check_device(DRI_PATH)
2329

2430
#TODO: add run here
2531

32+
xserver_cmd = f"/usr/bin/Xorg -quiet -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xdummy.log -config ./xorg.conf :0"
33+
xserver_thread = DockerThread(xserver_cmd)
34+
xserver_thread.start()
35+
self.threads.append(xserver_thread)
36+
37+
if ACCELERATION_ENABLED:
38+
# Starts xserver, x11vnc and novnc
39+
self.gz_vnc.start_vnc_gpu(
40+
self.display, self.internal_port, self.external_port, DRI_PATH
41+
)
42+
# Write display config
43+
o3decmd = f"export DISPLAY={self.display}; data/workspace/ROS2Demo/build/linux/bin/profile/ROS2Demo.GameLauncher"
44+
else:
45+
# Starts xserver, x11vnc and novnc
46+
self.gz_vnc.start_vnc(self.display, self.internal_port, self.external_port)
47+
# Write display config
48+
o3decmd = f"export DISPLAY={self.display}; data/workspace/ROS2Demo/build/linux/bin/profile/ROS2Demo.GameLauncher"
49+
50+
gzclient_thread = DockerThread(o3decmd)
51+
gzclient_thread.start()
52+
self.threads.append(gzclient_thread)
53+
54+
process_name = "data/workspace/ROS2Demo/build/linux/bin/profile/ROS2Demo.GameLauncher"
55+
wait_for_process_to_start(process_name, timeout=360)
56+
2657
def terminate(self):
58+
self.gz_vnc.terminate()
2759
if self.threads is not None:
2860
for thread in self.threads:
2961
if thread.is_alive():

0 commit comments

Comments
 (0)