From 958d3379f43cb3fd0eaa534d88da4bc6b4f5b6b7 Mon Sep 17 00:00:00 2001 From: ReyDoran Date: Fri, 16 Jun 2023 09:28:38 +0200 Subject: [PATCH] Added ROS2 applications compatibility --- .../compatibility/robotics_application_wrapper.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/manager/libs/applications/compatibility/robotics_application_wrapper.py b/manager/libs/applications/compatibility/robotics_application_wrapper.py index ac9249d..bbcf38c 100644 --- a/manager/libs/applications/compatibility/robotics_application_wrapper.py +++ b/manager/libs/applications/compatibility/robotics_application_wrapper.py @@ -28,6 +28,8 @@ def __init__(self, update_callback): self.start_console() self.user_process = None self.entrypoint_path = None + self.python_command = "python" + self.check_python_version() def _create_process(self, cmd): #print("creando procesos") @@ -45,7 +47,7 @@ def load_code(self, path: str): self.entrypoint_path = path def run(self): - self.user_process = self._create_process(f"DISPLAY=:2 python {self.entrypoint_path}") + self.user_process = self._create_process(f"DISPLAY=:2 {self.python_command} {self.entrypoint_path}") self.running = True def stop(self): @@ -94,4 +96,12 @@ def suspend_resume(self, signal): if(signal == "resume"): p.resume() except psutil.NoSuchProcess: - pass \ No newline at end of file + pass + + def check_python_version(self): + output = subprocess.check_output(['bash', '-c', 'echo $ROS_VERSION']) + output_str = output.decode('utf-8') + if (output_str == 1): + self.python_command = "python" + else: + self.python_command = "python3"