Skip to content

Commit e9884a9

Browse files
committed
Add base o3de files
1 parent a4d9fe6 commit e9884a9

4 files changed

Lines changed: 136 additions & 0 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import sys
2+
from manager.manager.launcher.launcher_interface import ILauncher
3+
from manager.manager.docker_thread.docker_thread import DockerThread
4+
from manager.manager.vnc.vnc_server import Vnc_server
5+
from manager.libs.process_utils import (
6+
wait_for_process_to_start,
7+
check_gpu_acceleration,
8+
)
9+
import subprocess
10+
import time
11+
import os
12+
import stat
13+
from typing import List, Any
14+
from manager.ram_logging.log_manager import LogManager
15+
16+
class LauncherO3de(ILauncher):
17+
display: str
18+
internal_port: int
19+
external_port: int
20+
height: int
21+
width: int
22+
running: bool = False
23+
threads: List[Any] = []
24+
acceptsMsgs: bool = False
25+
gz_vnc: Any = Vnc_server()
26+
27+
def run(self, config_file, callback):
28+
29+
process_name = "gz sim"
30+
wait_for_process_to_start(process_name, timeout=60)
31+
32+
self.running = True
33+
34+
def check_device(self, device_path):
35+
try:
36+
return stat.S_ISCHR(os.lstat(device_path)[stat.ST_MODE])
37+
except:
38+
return False
39+
40+
def is_running(self):
41+
return self.running
42+
43+
def terminate(self):
44+
self.running = False
45+
46+
def died(self):
47+
pass
48+
49+
def pause(self):
50+
#TODO: add pause
51+
pass
52+
53+
def unpause(self):
54+
#TODO: add resume
55+
pass
56+
57+
def reset(self):
58+
#TODO: add reset
59+
pass
60+
61+
def get_dri_path(self):
62+
directory_path = "/dev/dri"
63+
dri_path = ""
64+
if os.path.exists(directory_path) and os.path.isdir(directory_path):
65+
files = os.listdir(directory_path)
66+
if "card1" in files:
67+
dri_path = os.path.join("/dev/dri", os.environ.get("DRI_NAME", "card1"))
68+
else:
69+
dri_path = os.path.join("/dev/dri", os.environ.get("DRI_NAME", "card0"))
70+
return dri_path
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
import sys
3+
from typing import List, Any
4+
import time
5+
import stat
6+
7+
from manager.manager.launcher.launcher_interface import ILauncher, LauncherException
8+
from manager.manager.docker_thread.docker_thread import DockerThread
9+
import subprocess
10+
11+
import logging
12+
13+
14+
class LauncherO3deApi(ILauncher):
15+
type: str
16+
module: str
17+
launch_file: str
18+
threads: List[Any] = []
19+
20+
def run(self, callback):
21+
DRI_PATH = self.get_dri_path()
22+
ACCELERATION_ENABLED = self.check_device(DRI_PATH)
23+
24+
#TODO: add run here
25+
26+
def terminate(self):
27+
if self.threads is not None:
28+
for thread in self.threads:
29+
if thread.is_alive():
30+
thread.terminate()
31+
thread.join()
32+
self.threads.remove(thread)
33+
34+
# TODO: processes to kill
35+
to_kill = ["launch.py"]
36+
37+
kill_cmd = "pkill -9 -f "
38+
for i in to_kill:
39+
cmd = kill_cmd + i
40+
subprocess.call(
41+
cmd,
42+
shell=True,
43+
stdout=subprocess.PIPE,
44+
bufsize=1024,
45+
universal_newlines=True,
46+
)

manager/manager/launcher/launcher_tools.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
"external_port": 6080,
3333
"internal_port": 5900,
3434
},
35+
"o3de": {
36+
"type": "module",
37+
"width": 1024,
38+
"height": 768,
39+
"module": "o3de",
40+
"display": ":2",
41+
"external_port": 6080,
42+
"internal_port": 5900,
43+
},
3544
"rviz": {
3645
"module": "rviz",
3746
"display": ":3",
@@ -61,6 +70,7 @@
6170
simulator = {
6271
"gazebo": {"tool": "gazebo"},
6372
"gz": {"tool": "gzsim"},
73+
"o3de": {"tool": "o3de"},
6474
}
6575

6676

manager/manager/launcher/launcher_world.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
}
2727
],
2828
},
29+
"o3de": {
30+
"2": [
31+
{
32+
"type": "o3de",
33+
"module": "o3de_api",
34+
"parameters": [],
35+
"launch_file": [],
36+
}
37+
],
38+
},
2939
"physical": {},
3040
}
3141

0 commit comments

Comments
 (0)