From 750a9cb42131663b80c76efb2d8a026ed58f3437 Mon Sep 17 00:00:00 2001 From: aquintan Date: Thu, 12 Nov 2026 10:27:14 +0100 Subject: [PATCH] Add rqt tool - New rqt launcher on its own VNC display (6083), like rviz - Loads the default perspective from RoboticsInfrastructure when the world has none --- .../manager/launcher/launcher_rqt.py | 90 +++++++++++++++++++ .../manager/launcher/launcher_tools.py | 6 ++ 2 files changed, 96 insertions(+) create mode 100644 robotics_application_manager/manager/launcher/launcher_rqt.py diff --git a/robotics_application_manager/manager/launcher/launcher_rqt.py b/robotics_application_manager/manager/launcher/launcher_rqt.py new file mode 100644 index 0000000..b0b9562 --- /dev/null +++ b/robotics_application_manager/manager/launcher/launcher_rqt.py @@ -0,0 +1,90 @@ +""" +RQT Launcher for ROS 2. + +Handles the initialization and lifecycle of the ROS 2 Qt GUI framework (RQT). +Loads a .perspective file with the plugins to show (node graph, topics and +TF tree) and manages the X11 display environment to project the +interface to the web frontend. +""" + +from .launcher_interface import ILauncher +from robotics_application_manager.manager.docker_thread import DockerThread +from robotics_application_manager.manager.vnc import Vnc_server +from robotics_application_manager import LogManager +from typing import List, Any +import subprocess + + +class LauncherRqt(ILauncher): + display: str + internal_port: int + external_port: int + running: bool = False + acceptsMsgs: bool = False + threads: List[Any] = [] + vnc: Any = Vnc_server() + + def run(self, config_file, callback): + """ + Launches an RQT instance with a specific perspective. + + Args: + config_file (str): Path to the .perspective file defining the + plugins and their layout. + callback (function): Lifecycle state-change callback. + """ + DRI_PATH = self.get_dri_path() + ACCELERATION_ENABLED = self.check_device(DRI_PATH) + + if config_file is None: + config_file = "/opt/jderobot/Launchers/rqt/default.perspective" + + config = f"rqt --perspective-file {config_file}" + + if ACCELERATION_ENABLED: + self.vnc.start_vnc_gpu( + self.display, self.internal_port, self.external_port, DRI_PATH + ) + rqt_cmd = f"export VGL_DISPLAY={DRI_PATH}; export DISPLAY={self.display}; vglrun {config}" + else: + self.vnc.start_vnc(self.display, self.internal_port, self.external_port) + rqt_cmd = f"export DISPLAY={self.display};{config}" + + rqt_thread = DockerThread(rqt_cmd) + rqt_thread.start() + + self.threads.append(rqt_thread) + self.running = True + + def pause(self): + pass + + def unpause(self): + pass + + def reset(self, robot_entities=[]): + pass + + def is_running(self): + return self.running + + def terminate(self): + LogManager.logger.info(f"Terminating rqt tool") + self.vnc.terminate() + for thread in self.threads[:]: + if thread.is_alive(): + thread.terminate() + # rqt ignores SIGTERM so join would block forever + subprocess.call( + "pkill -9 -f 'bin/rqt --perspective-file'", + shell=True, + stdout=subprocess.PIPE, + bufsize=1024, + universal_newlines=True, + ) + thread.join() + self.threads.remove(thread) + self.running = False + + def died(self): + pass diff --git a/robotics_application_manager/manager/launcher/launcher_tools.py b/robotics_application_manager/manager/launcher/launcher_tools.py index 3000042..c7b7803 100644 --- a/robotics_application_manager/manager/launcher/launcher_tools.py +++ b/robotics_application_manager/manager/launcher/launcher_tools.py @@ -32,6 +32,12 @@ "external_port": 6081, "internal_port": 5902, }, + "rqt": { + "module": "rqt", + "display": ":4", + "external_port": 6083, + "internal_port": 5903, + }, "web_gui": { "type": "module", "module": "web_gui",