Skip to content

Commit cd8d28f

Browse files
committed
Add rviz
1 parent cb7d055 commit cd8d28f

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from manager.manager.launcher.launcher_interface import ILauncher
2+
from manager.manager.docker_thread.docker_thread import DockerThread
3+
from manager.manager.vnc.vnc_server import Vnc_server
4+
from manager.libs.process_utils import check_gpu_acceleration
5+
import os
6+
import stat
7+
from typing import List, Any
8+
9+
10+
class LauncherRviz(ILauncher):
11+
display: str
12+
internal_port: int
13+
external_port: int
14+
running: bool = False
15+
acceptsMsgs: bool = False
16+
threads: List[Any] = []
17+
console_vnc: Any = Vnc_server()
18+
19+
def run(self, config_file, callback):
20+
DRI_PATH = self.get_dri_path()
21+
ACCELERATION_ENABLED = False
22+
23+
if ACCELERATION_ENABLED:
24+
self.console_vnc.start_vnc_gpu(
25+
self.display, self.internal_port, self.external_port, DRI_PATH
26+
)
27+
# Write display config and start the console
28+
console_cmd = f"export VGL_DISPLAY={DRI_PATH}; export DISPLAY={self.display}; vglrun ros2 run rviz2 rviz2"
29+
else:
30+
self.console_vnc.start_vnc(
31+
self.display, self.internal_port, self.external_port
32+
)
33+
# Write display config and start the console
34+
console_cmd = f"export DISPLAY={self.display};ros2 run rviz2 rviz2"
35+
36+
console_thread = DockerThread(console_cmd)
37+
console_thread.start()
38+
self.threads.append(console_thread)
39+
40+
self.running = True
41+
42+
def pause(self):
43+
pass
44+
45+
def unpause(self):
46+
pass
47+
48+
def reset(self):
49+
pass
50+
51+
def is_running(self):
52+
return self.running
53+
54+
def terminate(self):
55+
self.console_vnc.terminate()
56+
for thread in self.threads:
57+
if thread.is_alive():
58+
thread.terminate()
59+
thread.join()
60+
self.threads.remove(thread)
61+
self.running = False
62+
63+
def died(self):
64+
pass

manager/manager/launcher/launcher_tools.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
"external_port": 6080,
3333
"internal_port": 5900,
3434
},
35+
"rviz": {
36+
"module": "rviz",
37+
"display": ":3",
38+
"external_port": 6081,
39+
"internal_port": 5902,
40+
},
3541
"web_gui": {
3642
"type": "module",
3743
"module": "web_gui",

0 commit comments

Comments
 (0)