Skip to content

Commit f1383d6

Browse files
committed
launcher for ros2 teleoperable model
Signed-off-by: Blanca <blancasoriaru@gmail.com>
1 parent 2af957f commit f1383d6

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

manager/libs/applications/compatibility/exercise_wrapper_ros2_teleop.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ def __init__(self, exercise_command, gui_command, teleop_command, update_callbac
6262
self.teleop_connection.start()
6363
else:
6464
self.teleop_server.kill()
65-
raise RuntimeError(f"Exercise GUI {teleop_command} could not be run")
65+
raise RuntimeError(f"Exercise Teleop {teleop_command} could not be run")
6666

6767
self.running = True
68-
6968
self.start_send_freq_thread()
7069

7170

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from src.manager.manager.launcher.launcher_interface import ILauncher
2+
from src.manager.manager.docker_thread.docker_thread import DockerThread
3+
import time
4+
import os
5+
import stat
6+
7+
8+
class LauncherTeleoperatorRos2(ILauncher):
9+
model_plugin_port: str
10+
running = False
11+
threads = []
12+
13+
def run(self, callback):
14+
DRI_PATH = os.path.join("/dev/dri", os.environ.get("DRI_NAME", "card0"))
15+
ACCELERATION_ENABLED = self.check_device(DRI_PATH)
16+
17+
if (ACCELERATION_ENABLED):
18+
teleop_cmd = f"export VGL_DISPLAY={DRI_PATH}; vglrun /opt/jderobot/utils/model_teleoperator.py 0.0.0.0 {model_plugin_port}"
19+
else:
20+
teleop_cmd = f"/opt/jderobot/utils/model_teleoperator.py 0.0.0.0 {model_plugin_port}"
21+
22+
print("\n\n LAUNCHING TELEOPERATOR\n\n")
23+
teleop_thread = DockerThread(teleop_cmd)
24+
teleop_thread.start()
25+
self.threads.append(teleop_thread)
26+
27+
self.running = True
28+
29+
def check_device(self, device_path):
30+
try:
31+
return stat.S_ISCHR(os.lstat(device_path)[stat.ST_MODE])
32+
except:
33+
return False
34+
35+
def is_running(self):
36+
return self.running
37+
38+
def terminate(self):
39+
for thread in self.threads:
40+
thread.terminate()
41+
thread.join()
42+
self.running = False
43+
44+
def died(self):
45+
pass

0 commit comments

Comments
 (0)